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.

Step

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

Step

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

Step

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

Step

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.

Step

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

Step

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

Step

nano ~/.bash_profile sudo nano /etc/profile

Step

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.

Step

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.