What's the difference between the commands "su -s" and "sudo -s"?
In practice, they will both make you the superuser. However, they do slightly different things, in slightly different ways.
First, su -
switches you to a login shell, whereas sudo -s
does not. In practice, this often means that your environment variables will not be switch to root
's for sudo -s
. Note that you can run just su
to not get a login shell, or sudo -i
to get a login shell [not in all versions].
Secondly, su
and su -
switch to a new user by asking you to authenticate as the new user. sudo -s
and sudo -i
(and just regular sudo foo
) let you run a command for which you're pre-authorized [see /etc/sudoers
], possibly by asking you to confirm your current ID.
If you want to be really cute, you can also run sudo su -
, which will request to login as root (su -
) run by the root user (the sudo
part).
If the root user is locked (such as on Ubuntu), you will not be able to login as root using su
. In this case, you'll need to use sudo -s
or sudo -i
su -s
Will switch to a user (in this case root) and launch the shell you specify, or one of few other methods of determining the shell. This is useful if you want to use zsh or another shell as root really quick... and for some reason you're not using sudo.
sudo -s
Just executes a shell using sudo, which would give you a root shell. You can pass a shell to it as well.
su -s is older, much older then the sudo -s command. My guess is that the developer is trying to make it as easy as possible to switch to using sudo.