8

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?

1 Answers1

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 via NFS/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.

  • 5
    I 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