How to Change the Path Variable in Linux

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

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.

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/

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.

Test application program operation with the temporary path to assure the all works well.

WH.shared.addScrollLoadItem(‘b8d068b88097269022affe7f36caad09’)

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.

Leave a Comment