How to change Path variable in Linux: 5 steps

Table of contents:

How to change Path variable in Linux: 5 steps
How to change Path variable in Linux: 5 steps
Anonim

Operating systems usually use environment variables to define global settings or to control the operation of programs. The Path variable is one of the environment variables and is constantly used without your knowledge. The variable stores a list of directories where executable files are located.

Steps

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

Step 1. Find the current path by entering the echo $ PATH command

A directory listing will open as shown below (example):

  • uzair @ linux: ~ $ echo $ PATH / home / uzair / bin: / usr / local / sbin: / usr / local / bin: / usr / bin: / bin: / usr / games
  • Note: directories are separated by colons.
Change the Path Variable in Linux Step 2
Change the Path Variable in Linux Step 2

Step 2. Temporarily add:/ sbin and: / usr / sbin: to the current path by entering the command:

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. Enter the command to confirm that the PATH variable has been changed

  • uzair @ linux: ~ $ echo $ PATH / home / uzair / bin: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin: / usr / games
  • Remember that the changes you make are temporary and will be canceled when you reboot your system.
Change the Path Variable in Linux Step 4
Change the Path Variable in Linux Step 4

Step 4. Check the correct operation of programs with a temporary variable.

Change the Path Variable in Linux Step 5
Change the Path Variable in Linux Step 5

5 To make permanent changes to the PATH variable add the same line to the ~ /.bashrc file

Popular by topic