How to Set the PATH in Ubuntu

The PATH environment variable in Ubuntu, as well as all other forms of Linux and Unix, is used to define the locations where the system looks for installed programs. Directory paths such as "/usr/bin" and "/usr/sbin" are already defined in the PATH, but if users want to define other directories, such as a "/home/USER/bin" directory, to allow each user to install his own set of programs, they can do so easily.

Video of the Day


Open the terminal by clicking "Applications," "Accessories" and "Terminal."


Type the following command into the terminal to define a new PATH:

PATH=$PATH:/home/USER/bin export PATH

This will append the directory "/home/USER/bin" to the end of the PATH variable. The order of the directories in the PATH variable matters; the order of the directories is the order in which Ubuntu will look for programs.

Unfortunately, this change takes effect only so long as the current terminal is open.


Type one of the following to edit the "profile" configuration file that defines commands to be run every time the terminal is started:

nano ~/.bash_profile sudo nano /etc/profile

The first will edit the profile of the current user and the changes will take effect only for that user. The latter will alter the profile for the entire system and the changes will take effect for all users. Since this is potentially dangerous, it requires the "super user do" (sudo) command and will prompt you for an administrator's password.


Add the first line from Step 2 to the text file and save your work. The changes will take effect as soon as you restart the terminal program.

Show Comments