What does $PATH mean?
Run in a terminal:
echo $PATH
or
printf "%s\n" "$PATH"
what you see is a list of directories, looking like:
/home/jacob/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
If you put an executable in either one of these directories, you do not need to set the path to the executable / script, but you can run it by its name as a command.
Executables in $PATH
should not have a language extension by convention (although they would work)
Editing your $PATH variable
You can (permanently) add a directory to $PATH
by adding the following line to your ~/.profile
file (invisible by default, press Ctrl+H in the file manager to make it visible):
export PATH=$PATH:/path/to/dir
More usefull information on environment variables
(such as $PATH
) can be found here (thanks for the suggestions @Letizia)
$PATH
is a environment variable that is file location-related.
When one types a command to run, the system looks for it in the directories specified by PATH
in the order specified.
You can view the directories specified by typing echo $PATH
in the terminal.
Suppose there is a executable file foobar01.sh
present at /home/user/foo1/foo2/foobar01.sh
which you want to execute on a regular basis. typing the entire "path" would be time consuming. So we add the directory in to $PATH
variable and we can execute foobar.sh
directly without even specifying the path.
You can add it to $PATH
by typing the following command:
export PATH=$PATH:/home/user/foo1/foo2