-
What is $PATH in Linux
The $PATH environmental variable is a colon-delimited list of directories that tells the shell which directories to search for executable files.
1 | ✘ gecheng@A ~ echo $PATH |
Adding a Directory to your $PATH
To make the change permanent, you need to define the $PATH variable in the shell configuration files. In most Linux distributions when you start a new session, environment variables are read from the following files:
- Global shell specific configuration files such as
/etc/environment
and/etc/profile
. Use this file if you want the new directory to be added to all system users $PATH.
- Per-user shell specific configuration files. For example, if you are using Bash, you can set the $PATH variable in the
~/.bashrc
file and if you are using Zsh the file name is~/.zshrc
.
1 | export PATH="$HOME/.local/bin:$PATH" |
Save the file and load the new $PATH into the current shell session using the source command:
1 | source ~/.bashrc |