If you've made a terminal program on Linux, then sometimes you want to use that program from any directory on the system. The concept of making this happen is usually called "installing a program."
Once you build your executable, you can move it to a directory that's in your system's PATH
. A common location for user-installed programs is:
sudo install -m 755 fibber /usr/local/bin/fibber
The install
command is used instead of mv
because:
- It ensures the file is copied with correct permissions (
-m 755
sets it as executable). - It checks if the destination file already exists and will safely overwrite it only if permitted.
- It avoids accidentally removing or corrupting existing programs by mistake.
The above command makes sure that the executable you're trying to create doesn't already exist in a critical system directory without your awareness, and it handles setting executable permissions properly.
To uninstall the program, we run the following command:
sudo rm /usr/local/bin/fibber
This simply removes the executable from the system-wide binary directory, effectively uninstalling the program.