How to Modify a Path Permanently in Linux
The Linux PATH environment variable contains the directories where executable programs are found. The operating system looks in the directories contained in the variable to find the command or script typed at the command line. If executable scripts are located in a directory that is not in the default PATH, you can add them to the variable using the "export" command. If you want to make the change permanent, you must add the command to a special text file in your home directory.
Instructions
-
-
1
Open a terminal window or log in to the computer via an SSH session.
-
2
Type the command "vi .bash_profile" to open the .bash_profile file in the Vi text editor. You can replace "vi" with your preferred text editor.
-
-
3
Type the lines
PATH=$PATH:/home/your_username/scripts
export PATH
to add the directory "/home/your_username/scripts" to the PATH variable. Replace "/home/your_username/scripts" with the directory that you want to add to the PATH.
-
4
Save and close the .bash_profile file.
-
5
Log out and log back in to change the $PATH variable.
-
1
Tips & Warnings
To change the PATH for all users except root, add the lines to the "/etc/profile" file. The root user has its own ".bash_profile" file.