Last updated on July 28, 2020 by Dan Nanni
/usr/local/bin. How can I add
/usr/local/binto my PATH variable, so that I can run the command without specify the path?
PATH environment variable stores a set of directories to search for an executable command when the command is typed by a user. The value of
PATH variable is formatted as a series of colon-separated absolute paths. Each user has a user-specific
PATH environment variable (initialized with system-wide default
To check the current
PATH environment variable of a user, run the following command as the user:
$ echo $PATH
$ env | grep PATH
If the command that you type is not found in any of these directories, the shell will throw an error message: "command not found"
If you want to add an additional directory (e.g.,
/usr/local/bin) to your
PATH variable, you can follow these instructions.
PATHEnvironment Variable for a Particular User Only
If you want to temporarily add a new directory (e.g.,
/usr/local/bin) to a user's default search path in the current login session, you can simply type the following.
Now check if
PATH has been updated:
$ echo $PATH
PATH will then remain effective in the current login session. The change, however, will be lost in any new terminal session.
bash users) If you want to change
PATH variable permanently, open
~/.bash_profile) with a text editor, and append the following line.
Then activate the change permanently by running:
$ source ~/.bashrc (or source ~/.bash_profile)
PATHEnvironment Variable System-wide
If you want to permanently add
/usr/local/bin to system-wide default
PATH variable, edit
/etc/profile as follows.
$ sudo vi /etc/profile
Once you re-login, the updated
PATH variable will take effect.
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.