I have PATH=foo
set in /etc/profile
According to /etc/password
the root
and myaccount
users have /bin/bash
as the login shell.
When I log in as myaccount
, the PATH
has been set correctly from /etc/profile
. If I then sudo su
, PATH
does not include the value set in /etc/profile
.
If I sudo su -
instead then /etc/profile
is sourced. I know it is good practice to do this anyway but I don't see why it's necessary in order to source /etc/profile
.
Why does sudo su
clobber PATH
, disregarding /etc/profile
and how to I make it not?
Best Answer
sudo su
is an abomination that should be cursed unto the ends of the earth.Having got that out of the way, you'll be asking what you should do instead.
Only login shells source
/etc/profile
.