I'm having a little issue with my PATH
when I use sudo
:
My PATH
from user shell :
/usr/local/bin:/usr/bin:/bin:/opt/bin
My PATH
from root shell, via su
or root login on TTY :
/usr/sbin:/usr/bin:/sbin:/bin
My PATH
from root shell, via sudo -s
:
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin
As you can see, when using sudo
, the order of /bin
, /usr/bin
and /usr/local/bin
is reversed.
It's quite annoying, mainly when I use Vim. I'm used to having vi
a symlink to vim
. The configuration of symlinks on my Gentoo system is :
/bin/vi -> busybox
/usr/bin/vi -> vim
So in most cases, simply typing vi
brings up Vim, but if I use sudo vi
, I end up with the Busibox vi, due to change in PATH
order !
I couldn't find out how sudo
builds this new path, is there a way to change it ?