Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the technical differences between the two? The only thing I noticed is that

sudo su

requires you to enter your own password (assuming you're not root)


su root

requires you to enter root's password. However both seem to log you into the root user account.

share|improve this question
Looks like a duplicate of… – Sergey Dec 8 '11 at 13:22
sudo su root -- the best of both worlds! – William Jackson Dec 8 '11 at 14:27
up vote 3 down vote accepted

The second command cannot be executed in a default Ubuntu installation, where the root account is not enabled.

But supposing you have unlocked the root account giving him a password, the two commands could only differ in the environment and shell variable set, I think. Compare the output of env in the two situations, and maybe also the output of set to see the differences.

share|improve this answer

There's a subtle difference between the two. su root (which can be shortened to just su) runs the su command as the user who invoked it. sudo runs the specified command (su) as root. Running su as root is essentially a no-op, though it probably starts a new shell. Running sudo -i is a cleaner (in my opinion) way of running sudo su.

Also, as pointed out previously, there is no root password on a default Ubuntu installation, so invoking su by itself will fail.

share|improve this answer
Just a clarfication. It's not really a no-op. It does go through the whole su process. There is a difference between sudo su and sudo bash. – user606723 Dec 8 '11 at 15:50

Another difference; the sudo command uses YOUR password and you have to be authorized in the /etc/sudoers file. The sudoers file defines what commands you are allowed to execute using sudo. The su command uses the ROOT password. which must be known.

Depending on options you can pick up roots environment or carry yours forward.

I use "sudo bash" to get a root shell. That is almost identical (maybe is, I am not sure) to "sudo -i". The environment is controlled like this "sudo su - other_user" gets the environment for other_user. But "sudo su other_user" carries your environment forward under the UID of other_user. That means your aliases and such will be available.

Also, auditing results are different in the audit logs when using su versus sudo. More tracability with sudo. Lastly, for su you give the root password around and have a maintenance pain. If you authorize people with sudo, you just update the sudoers file to add or remove people and they only have to remember their own password. Sudoers also allows you to decide what others can do.

share|improve this answer

sudo -i is how you do it, at least from 11.00 on, not sure about previously or after 12.04.

arries your environment forward under the UID of other_user. as said previously

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.