C
C
coffeehoock2018-01-31 18:42:51
linux
coffeehoock, 2018-01-31 18:42:51

What is the $PATH variable and what is it for?

you can add paths to a variable
$PATH
, but what is it? an array with the data or there is a concatenation to a line?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
InoMono, 2018-01-31
@InoMono

Essentially an array of strings.
Separated by the symbol ":" (in Windows - everything is similar, only separated by the symbol ";")
Used when starting programs first of all (sometimes for other things)
A list of directories where the program will be searched if it is not found in the current directory.
Is just a string. One line.
But some GUI utilities separate it into separate elements when editing. For ease of editing.

S
Saboteur, 2018-01-31
@saboteur_kiev

This is a normal string variable.
Linux has only
numeric variables: $VARIABLE
string variables: $VARIABLE
arrays: $VARIABLE[x]
all.
PATH is a regular string variable whose values ​​are separated by colons.
It contains a list of directories in which you should look for an executable file if you do not write the full path to it on the command line.

I
Ingvar, 2018-02-08
@take

that is why scripts from a directory not specified in PATH, as well as executable files, should be launched like this: ./file_name with a dot and a slash. This means to run the file from the current directory. If this is not done, firstly, there will be an unnecessary search for this file in all directories specified in $ PATH, and secondly, if the name of the file to be launched completely matches, the system will launch not the desired file from the directory, but a similar one found in $PATH directories

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question