It is my understanding that they do the same: they ask for my password (if I am allowed in /etc/sudoers), and give me a login shell as root.
Is there any difference between them?
sudo su -
sudo -i
Also, what's the difference between
sudo su
sudo -s
I think that they both ask for my password, and give me a shell with my old environment variables.
Best Answer
There is little difference in the command pairs you are wondering about.
The first pair attempts to simulate a fresh login as the new user-- there could be some difference in the environmental variables supplied, as
sudo su -
is going to try and preserve existing environmental variables, whilesudo -i
will set very specific environmental variables and strip all others (check your man pages for specifics).For the second pair, the difference in behavior is this:
sudo su
will always start the shell listed in the user's/etc/passwd
, whereassudo -s
will check theSHELL
environmental variable first, and only execute the shell in/etc/passwd
ifSHELL
is unset.