Linux – Unix standard directory to put custom executables or scripts?


If I have a custom shell script or programs, that I created myself or downloaded from the web, and I want to be able to execute this from the CLI, is there the standard location to put this in Linux/Unix directory structure?

/usr/bin ?
/usr/local/bin ?
/usr/lib ?
/usr/sbin ?
/bin ?
/sbin ?
/var ?

I usually put it under my ~/bin folder and put it in PATH, but it doesn't seem clean. And everytime I downloaded a new program, I have to put it in the PATH again.

Best Solution

/usr/local/bin exists precisely for this purpose, for system-wide installation. For your own private use, ~/bin is the de facto standard.

If you want to keep each binary in its own subdirectory, you can do that, and add a symlink to a directory already in your PATH. So, for example

curl -o $HOME/downloads/fnord
ln -s $HOME/downloads/fnord $HOME/bin/

provided $HOME/bin is in your PATH. (There are tools like stow which do this -- and much more -- behind the scenes for you.)