Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to add a directory to the PATH?

How do I add a directory to the $PATH in Ubuntu and make the changes permanent?
by

2 Answers

akshay1995
Edit .bashrc in your home directory and add the following line:

export PATH="/path/to/dir:$PATH"

You will need to source your .bashrc or logout/login (or restart the terminal) for the changes to take effect. To source your .bashrc, simply type

$ source ~/.bashrc
pankajshivnani123
think the canonical way in Ubuntu is:

create a new file under /etc/profile.d/

sudo vi /etc/profile.d/SCRIPT_NAME.sh

add there:

export PATH="YOUR_PATH_WITHOUT_TRAILING_SLASH:$PATH"

and give it execute permission

sudo chmod a+x /etc/profile.d/SCRIPT_NAME.sh

Login / Signup to Answer the Question.