[conspire] sudo -i vs sudo su - ? [Was:] Help with GRUB

Steve M Bibayoff bibayoff at gmail.com
Thu Nov 5 00:10:55 PST 2009


Hello,

On Wed, Nov 4, 2009 at 4:05 PM, Rick Moen <rick at linuxmafia.com> wrote:
> Quoting Steve M Bibayoff (bibayoff at gmail.com):
>
>> > On reflection, "sudo su -" is probably the method one should favour.
>>
>> Reason?
>
> It ensures that the root shell has user root's environment, and thus
> doesn't pick up any silly wack-assed stuff from the non-root user, such
> as unsafe additions to $PATH.
>
> If you're saying that "sudo -i" also does that, fine.  That was not
> entirely clear from the manpage snippet I quoted -- whereas it's very
> clear that "sudo su -" does it.

wasn't clear to me either. Just thought someone might have some insight.

a little experiment clears it up for me:

$ sudo -i
# env > dash_i
# exit
logout
$ sudo su -
# env > su_dash
# diff dash_i su_dash
5,8c5,6
< SUDO_USER=steve
< SUDO_UID=1000
< USERNAME=root
< PATH=/usr/lib/kde4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
---
> MAIL=/var/mail/root
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
12d9
< SUDO_COMMAND=/bin/bash
16,17d12
< SUDO_GID=1000
< DISPLAY=:0.0
19,20d13
< XAUTHORITY=/home/steve/.Xauthority
< COLORTERM=gnome-terminal

So it does seem like sudo -i carries alot(some?) crude from user.

Steve




More information about the conspire mailing list