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

  1. 1
    Find 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.
  2. 2
    Temporarily 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
  3. 3
    Echo 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.
  4. 4
    Test application program operation with the temporary path to assure the all works well.
  5. 5
    Permanently change the path setting by adding the same line to your ~/.bashrc file
  6. Advertisement

Community Q&A

  • Question
    What would I use to redefine existing system variable PATH?
    Community Answer
    Community Answer
    To 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

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.
How helpful is this?
Co-authors: 7
Updated: October 13, 2019
Views: 219,845
Categories: Linux
Advertisement