PATH: Difference between revisions
pc>Yuron No edit summary |
Yuron [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) m (1 revision imported) |
(No difference)
|
Revision as of 12:46, 26 July 2019
On path: User |
---|
Depends on | Environment Variables • Shell • Concepts |
---|
Several operating systems include the principle of a search path to look for commands. “Commands” are often (maybe even “usually” in many operating systems) executable files which need to be located, loaded and executed.
A $PATH
in Unix, %PATH%
in Windows is a list of directories which
are searched, in order, when a command like my_prog
is executed.
The first encountered match will be selected; a mismatch in every
possible place will generate an error.
A path search is only performed if the command does not explicitly
specify the path, as in cases such as ./my_prog
or
/home/joe/bin/my_prog
.
In Unix the outcome of a PATH
search can be determined by: which my_prog
without executing the utility. This is useful to check that
the expected version of some software is being discovered.
The principle of a search path is not limited to searching for files
to execute. Your Unix shells probably has a MANPATH
set
for example – which the man
command uses to find appropriate
documentation. It is not uncommon to set up a path to find shared
libraries etc.
Did you know …
A Unix shell will return the result of a command as an argument for
another command by bracketing with `
characters. For example (on the
system this was typed, at least) more
`which firefox`
will find and dump the appropriate
start-up script to the terminal.