Celeb Glow
news | April 02, 2026

How can I reset $PATH to its default value in Ubuntu?

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?

3

4 Answers

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:

PATH+=:$mynewdir
7

You can find it on /etc/environment:

$ /usr/bin/cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

So, just source it:

$ source /etc/environment
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
2

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:

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

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

The default path is

/home/_username_/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games 

Hope this helps you

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy