I'm beginning to write a bunch of bash scripts to automate some stuff, and I'm not sure where to put them. If I make a ~/SCRIPTS directory to put all the scripts in, should I symlink it to somewhere on the $PATH, or should I just add ~/SCRIPTS to the path itself? Is a directory for scripts a bad idea? Are there any best practices/rules for this?
Asked
Active
Viewed 1.7k times
8
-
2Seems opinion-based to me, but there's https://unix.stackexchange.com/q/201768/117549 – Jeff Schaller Aug 16 '20 at 18:27
1 Answers
12
There are no best practices, only opinions in regard to this and with that here's mine:
- If your scripts are intended to run by a single user you can place them in
~/bin
- If your scripts are system-wide you can probably place them in
/usr/local/bin
- If your scripts are meant to be only used under special circumstances or environments you can put them even in
/opt/myscripts
and add this directory to$PATH
- In case of multiple servers you can mount
/usr/local/bin
viaNFS
/SSHFS
/CIFS
/whatever from another PC/server. That's generally a bad idea and instead you should deploy scripts directly (rsync, chef, ansible, etc.) in case your network connection goes down.
I see no good reasons to use symbolic links whatsoever but no one will prevent you from doing that.
TLDR: do as you please the way that seems logical to you and other people who might be involved.

Artem S. Tashkinov
- 29,025
-
5I find it very convenient to just have ~/bin containing symbolic links. I keep each of my utilities in its own directory -- versioning, manpage, notes, test files etc. SymLinks are effectively my release/reversion mechanism. – Paul_Pedant Aug 16 '20 at 22:22