Where should I put my script?

32

11

Say I have created a bash script, which will make an ftp user, mount some paths for that user, etc. Where in the file system it would be proper to place? It would be good to have some resource clearly explaining the file system hierarchy.

Pablo

Posted 2010-09-06T07:23:30.063

Reputation: 4 093

Answers

49

A Google search for "Linux file system hierarchy" will turn up several documents, including this one.

Where you put your script depends on who the intended user is. If it is just you, put it in ~/bin and make sure ~/bin is in your PATH. If any user on the system should be able to run the script, put it in /usr/local/bin.

Don't put scripts you write yourself in /bin or /usr/bin. Those directories are intended for programs managed by the operating system.

garyjohn

Posted 2010-09-06T07:23:30.063

Reputation: 29 085

4I'm using Ubuntu and found that ~/bin will be automatically included in your $PATH once the folder is created. There are lines in .profile: if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi – Kenneth L – 2014-08-26T09:11:33.753

Thanks! For others as inexperienced as me: (1) you either need to log out and back in after creating ~/bin , or run source ~/.profile before ~/bin gets added to your PATH (2) you also have to run chmod u+x ~/bin/<your script> to give yourself privilege to execute it. – WillC – 2017-04-06T00:28:15.100

6

Here is a direct link to the home of the documentation.

– Paused until further notice. – 2010-09-06T08:37:56.860