Linux - How to set the $PATH environment variable?


The PATH environment variable is a list of which directories Linux will search for for executable files.

As in DOS, the shell uses the PATH variable to locate a command. PATH contains a list of directories separated by colons: When you enter a command, the shell search it in each of the directories specified in the PATH value trying to find it.

If it can't find it, you'll see a “Command not found” message.


to Manage it?

To manipulate and to change it, refer to this article: Bash - (Environment) Variable. Below is simple snippet.

See it

[root@ebs121 lib]# echo $PATH

See if a command is in your path

To see if a command is in your path, you can use the which command:

$ which mycommand

Change it for the session scope

To change your PATH variable to include a directory in a session scope:

[root@ebs121 lib]# export PATH=$PATH:$HOME/bin
[root@ebs121 lib]# echo $PATH

You can remark the root bin at the end. It was added.

Of you can add it permanently by adding this line in a shell startup script


  • To set it globally for all users
RUN echo "export PATH=$PATH:/whatever" >> /etc/profile

Documentation / Reference

Discover More
Bash Liste Des Attaques Ovh
Bash - Cd (Change Directory) builtin command

in bash. Cd is a builtin command that changes the current directory where: the options -L forces symbolic links to be followed. -P says to use the physical directory structure instead of...
Windows Search Path
Os - (Search) Path Environment Variable

The PATH environment variable allows to not type the entire path of a executable It contains a list of directory path where the operating system will search for executable files. For Linux: Unix...
Bash Liste Des Attaques Ovh
Shell - (Startup|Login) script (.bash_profile, .profile, .login)

The shell login scripts are the script that launch automatically after a login shell and permit to store permanently the values of environment variables. bashrc You can found them in two directory:...

Share this page:
Follow us:
Task Runner