X
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time.
This article has been viewed 219,845 times.
Learn more...
Operating systems commonly use environment variables to define various global settings for parts of your operating system or to control how applications run. The PATH variable is one of these environment variables and is constantly used without the user realizing it. The variable stores a list of directories where applications (most commonly, your shell) should look for a program whenever you run it as a command.
Steps
-
1Find the current path by typing "echo $PATH" at the bash shell prompt. A list of directories will be provided such as in the example below:
- uzair@linux:~$ echo $PATH/home/uzair/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games
- Note: Linux $PATH responds with ":" separators between entries.
-
2Temporarily add the :/sbin and :/usr/sbin paths to the current path list by typing the following command at the bash shell prompt:
- uzair@linux:~$ export PATH=$PATH:/sbin/:/usr/sbin/
Advertisement -
3Echo the contents of PATH to confirm the changes are reflected in the variable.
- uzair@linux:~$ echo $PATH/home/uzair/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
- Remember, the above is only temporary and will be lost at reboot.
-
4Test application program operation with the temporary path to assure the all works well.
-
5Permanently change the path setting by adding the same line to your ~/.bashrc file
Advertisement
Community Q&A
-
QuestionWhat would I use to redefine existing system variable PATH?Community AnswerTo change the PATH variable, type export PATH="$PATH:/path/to/new/executable/directory". Or, if you want to make it permanent, edit the .bashrc to say something like this: # what this location has export PATH="$PATH:/path/to/new/executable/directory"
Advertisement
Warnings
- Changing your PATH variable can potentially cause your operating system to not work properly. Operating system and application programs commonly refer to the path variable to find files. If the variable is not configured properly, programs will not run or run incorrectly. ALWAYS TEST the temporary setting using the method described above BEFORE STORING the new path permanently in your ~/.bashrc.⧼thumbs_response⧽
Advertisement
About This Article
Advertisement