Share via:

Where to Install Custom Programs in Linux

Find out where to place scripts and programs to make them available from a terminal in Linux.


Edited: 2019-08-24 17:35

I got many different scripts and small programs that I made over the years, and even made my own location in my /home/ directory where I keep them all. Recently I realized that Linux already has a location for "local" user programs, and you can even replace default system executables with your own versions, without having them interfere with other users on the system.

By placing a script or program in ~/local/bin and making it executable, it will automatically become available from terminal. You can even autocomplete by pressing [TAB] after typing the first few characters of the program name.

Note. The "~" character is a shorthand pointing to the users home directory.

The ~/local/bin shorthand corresponds to the /home/YourUser/local/bin location.

You can also read the manual (man) page for the file system hierarchy. Simply type man hier in a terminal. This works for many programs as well.

Historically, the bin folders would only contain executable binaries, but now they may also contain executable scripts, often this will be in the shape of shell (.sh) scripts.

/usr/bin vs ~/local/bin

Both the /usr/bin and ~/local/bin should be fairly safe locations to place your own files. The difference is that executables placed in the local location is only available to the user it belongs to, while those in the usr location will work for all users on the system.

Theoretically the system might still overwrite your program if suddenly a program with the same name is introduced, but this is unlikely and fairly easy to fix.

Alternatively, you can simply keep your files in your own location to avoid it completely. I currently have my stuff in a personal folder in /home, and I tend to just link things using symbolic links whenever I need easy access from terminal.