Where is a good permanent place to install custom bash scripts?
Solution 1:
(Note: ~
translates as /home/user
in this post)
Personally, I put all of my custom-made system scripts in /usr/local/bin
and all of my personal bash scripts in ~/bin
. Very few programs I install place themselves in /usr/local/bin
directory so it's not very cluttered and it was already in the $PATH
variable on most of my machines.
To add /usr/local/bin
to your system path (if it's not already there) add this to /etc/profile
:
PATH=$PATH:/usr/local/bin
export PATH
To add ~/bin
to your user's path add this to ~/.bash_profile
:
PATH=$PATH:$HOME/bin
export PATH
Sometimes the default .bash_profile
file will have an if statement that automatically adds ~/bin
to $PATH
if it exists, so create the ~/bin
and open a new terminal to see if yours already does this.
Solution 2:
/usr/local/ is really the right place, while /opt is really for third party applications; "/opt is reserved for the installation of add-on application software packages." This is part of the Filesystem Hierarchy Standard.
See http://www.pathname.com/fhs/pub/fhs-2.3.html for discussion on /opt.
For /usr/local/, it is for "use by the system administrator". Just don't forget about stuff in there -- document it.
Solution 3:
Historically you'd use something like /opt. Anything is fine as long as it's updated in $PATH for the users who are supposed to have it (hence anything in /home being a bad idea).
Solution 4:
/usr/share/clojure
seems like a common place to put clojure's binaries and libraries — why I don't know, it seems a natural for /usr/local/share/clojure
— so creating a site
subdirectory under this for these bash scripts seems fine.
The general point is that it makes more sense to organise scripts by function, not have all bash scripts in the same place.
Solution 5:
/usr/local
, I believe there's some confusion to the meaning of "local".
As I understand it, "local" doesn't mean "originating on/from the local machine" but, more simply, "specific to the local machine", which may or may not originate on/from the local machine.