Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I accidentally unset all the directories of $PATH while trying to add a new one in ~/.bashrc. I opened a new terminal window as I was editing and now $PATH is empty. I'm worried if I boot from another drive to find the $PATH I won't be able to boot into this drive again.

Basically, what is the default result of echo $PATH?

share|improve this question
Comment out or fix that export line and you should e good to go. –  bodhi.zazen Mar 16 '12 at 5:28
~/.bashrc is the wrong place to set environment variables though. You should do that in ~/.profile instead. –  geirha Mar 16 '12 at 6:38
Yes I figured it out. PATH is still fine in the other terminal window that was open before the new one, so just fixing the export line by adding :$PATH at the end restored the PATH. And yes in ~/.profile there is code to "set PATH so it includes user's private bin if it exists" i.e. $HOME/bin –  Cee Mar 16 '12 at 8:24

3 Answers 3

up vote 1 down vote accepted

Adding :$PATH to the end of the export line fixed the problem e.g. export PATH=<directory to be added>:$PATH

I add this line to the ~/.bash_rc file instead of the ~/.profile file so I can see the effect immediately in a new terminal and for other reasons based on the information here: http://superuser.com/questions/176404/linux-bash-not-loading-profile-in-new-session

For me, the default output of echo $PATH before adding the new directory is:


share|improve this answer

The answer to your question is:

PATH=$(getconf PATH)

and works on any POSIX compliant system. The selected answer is the correct way to augment the path without obliterating prior existing content. If you use bash, you might consider:


share|improve this answer

The default path is


Hope this helps you

share|improve this answer
That differs from my default PATH. See below. –  Cee Mar 16 '12 at 16:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.