If I have a custom shell script or program 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 directory and add it to the PATH, but it doesn’t seem clean. And every time I download a new program, I have to add it to the PATH again.
/usr/local/binexists precisely for this purpose: for system-wide installation. For your own private use,~/binis 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:This assumes
$HOME/binis in yourPATH.There are tools like
stowwhich do this — and much more — behind the scenes for you.