Where to Install Custom Programs in Linux

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

1027 views
d

By. Jacob

Edited: 2020-08-19 08:49

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.

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. How to search a directory and subdirectories for a given string of text in Linux with the grep command.
  3. Worth knowing in order to make a bootable USB memory stick with Windows on from Linux.
  4. This is why I decided to encrypt my new Flash Drive, and why I think you should too.
  5. About the problem with using sudo with graphical programs in Linux.

More in: Linux Tutorials