$PATH variable is one of the default environment variable in linux (ubuntu). It is used by the shell to look for executable files or commands. Although there are two types of environment variables - global and local, I'll discuss here only this specific
So, let us start by first outputting the content of
$ echo $PATH
And you'll get the result something like this which is a list of directories separated by colon:
Now here comes the important part to make your terminal programs executable without writing full path.
1. Exporting PATH variable to
One of the fastest way to permanently add directory to
$PATH environment variable is by using the following command:
# first append the new directory to path $ PATH = /usr/local/sbin:/usr/local/bin:/pathToMyDirectory $ source /etc/environment && export PATH
Another way is use the
.profile file by adding the
export command and then run the
# add this command to `~/.profile` file $ export PATH=$PATH:/myNewDir # then run the source command $ source ~/.profile
$PATH refers to content already set by system, so that we don't have to write previous directories path.