Ubuntu: Reset $PATH to factory default
I just made a mistake when adding a directory to path, and executed
$ PATH=/path/to/my/directory/
instead of
$ PATH=/path/to/my/directory/:$PATH
Consequently, my $PATH
variable now contains only my own directory, which is of course a problem. I don't know exactly what was in the path before, but if I can reset to factory default I can start from there and add things as I need them.
Is there an easy way to accomplish this?
If you can, just log out and relog in.
Otherwise, you can start with
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
and add missing entries.
From the bash(1) man page:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
So, on your system, it's most likely that you just need to look at what the default PATH value is in /etc/profile, set that, and then build up based on what your own login/profile bash scripts do to PATH.
If you're not using bash(1) but some other shell, then use "man thatShellName" to find out what it's invocation behaviour is, and perform similar steps.
As a quick short-cut, in your current shell, (again, assuming you're using bash(1)), type "bash --login" to get a new, login shell process; then, save the value of path with
echo $PATH > /tmp/myPath.txt
then "exit" out of the login shell and type
export PATH=`cat /tmp/myPath.txt`
(note the use of back-ticks in that last expression).
Or if you're a terminal app that has copy/paste abilities, you can just "bash --login", and copy the PATH value to the clipboard, exit, and then "export PATH" and paste in the PATH value.