PATH Variable
$PATH
- Normally to run an application, you need to fully specify the directory path to the application
- For example,
/home/user1/Downloads/installer.deb
- For example,
$PATH
is the variable which defines the directories in which the OS looks for applications to run- This way, you can just run applications by their name, such as
nuclei
instead of/home/max/go/bin/nuclei
- This way, you can just run applications by their name, such as
- Which directories are in PATH?
- Just run
echo $PATH
and you'll see all the directories configured - To find out where an application is being run from, you can use
which [command]
- e.g.,
which cut
reveals that it's being run from/usr/bin/cut
- e.g.,
- Just run
- How do you add directories to PATH?
- Open the config file for your shell of choice
- For example,
nano ~/.zshrc
ornano ~/.bashrc
- For example,
- At the very end of the file, add
export PATH="$PATH:path/to/directory/here"
, replacingpath/to/directory/here
with the target directory- For example to add the Go bin to the PATH variable, I entered
export PATH="$PATH:home/max/go/bin"
- For example to add the Go bin to the PATH variable, I entered
- Exit Nano and save the file, then Reload your terminal with the new config using
source ~/.zshrc
orsource ~/.bashrc
- Open the config file for your shell of choice
Metadata
Sources
An Introduction to Linux Directories and the PATH Variable
Getting Started with ProjectDiscovery in Linux and Windows