How to Change the System Variable Path in Linux

Table of contents:

How to Change the System Variable Path in Linux
How to Change the System Variable Path in Linux
Anonim

Operating systems use environment variables that define certain settings useful for running the operating system itself, and for managing the execution of installed programs. The 'PATH' variable is one of them, and is used constantly even if the end user is not aware of it. This variable stores a list of directories where applications (most commonly the 'Shell') will be able to identify the program to run for a given command.

Steps

Change the Path Variable in Linux Step 1
Change the Path Variable in Linux Step 1

Step 1. Locate the current contents of the 'path' variable using the following 'echo $ PATH' command (without quotes) within the 'bash' shell

A directory listing should appear as in the example given below:

  • uzair @ linux: ~ $ echo $ PATH / home / uzair / bin: / usr / local / sbin: / usr / local / bin: / usr / bin: / bin: / usr / games
  • Note: Linux uses the ':' separator to separate directories stored in the '$ PATH' variable.
Change the Path Variable in Linux Step 2
Change the Path Variable in Linux Step 2

Step 2. Temporarily add the following directories to the current path variable:

': / sbin', ': / usr / sbin'. To do this use the following command from the 'bash' shell:

uzair @ linux: ~ $ export PATH = $ PATH: / sbin /: / usr / sbin /

Change the Path Variable in Linux Step 3
Change the Path Variable in Linux Step 3

Step 3. Re-type the 'echo $ PATH' command (without quotes) to check that the changes made to the variable contents are correct

  • uzair @ linux: ~ $ echo $ PATH / home / uzair / bin: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin: / usr / games
  • Remember that the change made to the path variable is only temporary and will be lost the next time the system is restarted.

Recommended: