How can I reset $PATH to its default value in Ubuntu?
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
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
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: https://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:
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games