Consider, academically, that I have executed sudo mv /bin /foo
. I didn't stop to ask questions, I took charge of my destiny and did it.
What would I have to do if I wanted to permanently change the system-wide $PATH
to reflect this change? This includes:
- interactive shells
- non-interactive shells
- GUI logins
- system services
- sudo use
The reason I ask this, is the water is very muddy about the correct way to do this. Answers to this question variously suggest:
- editing
~/.bashrc
(won't affect e.g.bash --norc
) - editing
~/.profile
(only affects login shells) - editing
/etc/environment
(doesn't affect sudo; sometimes PATH doesn't seem to be here?)
Are there other core system utilities which are likely to cause problems by trying to use some $PATH
copy defined in yet other ways or places that I haven't covered here? How do you override $PATH
when using sudo?
Where does the One $PATH
To Rule Them All live, and how do I add /foo
to it?
I know this has been asked a bunch of times but there are so many different questions and answers floating around and many of them are out of date or cover only certain cases.
/etc/environment
does changePATH
permanently and systemwide; howeversudo
is configured to use its ownsecure_path
which is unaffected by thePATH
variable.