What is the difference between the two super user commands, su -s
and sudo -s
?
They both give a shell with access to the superuser account.
linuxsudounix
What is the difference between the two super user commands, su -s
and sudo -s
?
They both give a shell with access to the superuser account.
Best Answer
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, whereassudo -s
does not. In practice, this often means that your environment variables will not be switch toroot
's forsudo -s
. Note that you can run justsu
to not get a login shell, orsudo -i
to get a login shell [not in all versions].Secondly,
su
andsu -
switch to a new user by asking you to authenticate as the new user.sudo -s
andsudo -i
(and just regularsudo 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 (thesudo
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 usesudo -s
orsudo -i