How to change Path variable in Linux

Author: Gregory Harris
Date Of Creation: 7 August 2021
Update Date: 1 July 2024
Anonim
Path Variable and How to Change it - Linux
Video: Path Variable and How to Change it - Linux

Content

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

  1. 1 Find the current path by typing echo $ PATH. 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.
  2. 2 Temporarily add:/ sbin and: / usr / sbin: to the current path by entering the command:
    • uzair @ linux: ~ $ export PATH = $ PATH: / sbin /: / usr / sbin /
  3. 3 To confirm that the PATH variable has been changed, enter the command:
    • 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.
  4. 4 Check that programs with a temporary variable are working correctly.
  5. 5To make permanent changes to the PATH variable, add the same line to your ~ / .bashrc file

Warnings

  • Changing the PATH variable can lead to unstable operation of the operating system. The variable is used to find executable files. If the variable is not configured correctly, then programs will malfunction or will not work at all. Always check that temporary variable programs are working correctly before writing changes to the ~ / .bashrc file.