Linux.com

Home Learn Linux Linux Answers Applications What is the purpose of the PATH variable'?'
Answers
  • When you use system variables, you make a lot of things easier.

    First of all, when you make a change in the system like changing the Java which you use, you do not have to update every program that use Java. it just check it with JAVA_HOME system variable.

    And, the PATH variable has the paths to every binary you use in your system, so when you are in a terminal you do not have to input /bin/ls, just ls

    Answered by nailson
    2 years ago
    0 0
  • When you type a command into the shell, the shell needs to find that program. If you say "/bin/ls" then the shell goes to the /bin directory to find it. If you just say "ls" then it needs to look for it. There are too many places it could be, and possibly multiple things with that name, so you must give the shell a list of places to look. That list is the PATH variable. The PATH variable is a list of directories, separated by the colon character. The shell looks in those directories, in order, to find the command you just typed.

    It is needed to both allow the shell to find a command and to direct the shell to the version of the command you want it to choose, sometimes.

    You can see the value of your PATH variable by doing "echo $PATH". In teh BASH shell, the most common on on Linux, you can add a new directory to your PATH variable like so: PATH=/home/kevin/bin:$PATH

    Now each time I type a command name without specifying a directory, the shell will first look in /home/kevin/bin. If you want the shell to look for a command in the directory you happen to be in at the time you type the command, then include "." as a directory in the PATH. For example,

    PATH=.:$PATH

    Now the shell will first look in the directory you are in before any other.

    Answered by kevind
    2 years ago
    0 0
  • In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. It is an environmental variable that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user. It increases both the convenience and the safety of such operating systems and is widely considered to be the single most important environmental variable. Environmental variables are a class of variables.
    U can use the command like: env | grep PATH

    Answered by rechil_colin
    2 years ago
    0 0
Please register/login to answer this question. Click here to login
Similar Questions Found
Questions from category Applications

Upcoming Linux Foundation Courses

  1. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  2. LFS425 Linux Performance Tuning Crash Course
    16 Oct » 16 Oct - Düsseldorf, Germany
    Details
  3. LFS220 Linux System Administration
    20 Oct » 23 Oct - Virtual
    Details

View All Upcoming Courses

Community Answers - Search


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board