After much frustrating head-brick-wall contact, I've discovered this:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/steve/bin
$ sudo bash
# echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
but
$ sudo bash -c 'echo $PATH'
/sbin:/bin:/usr/sbin:/usr/bin
$ sudo bash -Ec 'echo $PATH'
/sbin:/bin:/usr/sbin:/usr/bin
I gather from another post that the sudo
path is read from /etc/sudoers
— but why? Does setting $PATH
in /root/.profile
make any sense, or is that just a recipe for the confusion above (ie, spawning an actual shell causes a different $PATH
from that used in casual sudo
commands...)?
I'm using bash on RHEL 6.4.