PATH
What is PATH
When you wish to install programs into other locations on your host, but be able to execute them easily without specifying their exact location. This can be easily done by adding a directory to your $PATH
.
View PATH
echo $PATH
Install packages and add to path
- temporarily set path
export PATH=<your-dir>:$PATH
- permenantly set path: add
export PATH=<your-dir>:$PATH
in.bashrc
. Then restart the terminal.
which
vs whereis
which: returns the pathnames of the file which would be executed in the current enviroment
whereis: searches for binary/source and manual page files.
For example,
whereis php => php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
# the php is executable, and some other stuff (e.g., man pages)
which php => /usr/bin/php
# returns only the php executable.