Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

On my personal machine, I often type sudo in front of certain commands in order to accomplish administrative tasks. I had hoped to avoid doing this throughout the day, by typing su root and providing the same password I usually do for sudo. However, the two passwords are not the same(I don't know how to log in to su root). Is running a command with sudo different than logging in with su root and running the same command?

I think sudo and su root are the same, because when I type sudo whoami, I get root, as opposed to just whoami where I get my user-name.

share|improve this question
I came across this older thread because it was linked as related to a question I asked. The answers are very informative but leaves a question. On a personal machine (one user), how do you get a different password for root depending on whether you use sudo or su root? Isn't there a single root password, defined when Linux is installed? – fixer1234 Sep 27 '14 at 15:56
up vote 12 down vote accepted

Contrary to what their most common use would lead you to think, su and sudo are not just meant for logging in (or performing actions) as root.

su allows you to switch your identity with that of someone else. For this reason, when you type su, the system needs to verify that you have the credentials for the target user you're trying to change into.

sudo is a bit different. Using sudo allows you to run certain (or all, depending on the configuration) commands as someone else. Your own identity is used to determine what types of commands sudo will run for you under someone else's identity: if you're a trusted user (in the sense that the sysadmin trusts you), you'll be allowed more free rein than, say, an intern. This is why sudo needs to verify your own identity rather than that of the target user.

In other words, trying to su to someone you're not is like attempting to charge your purchases to a stolen credit card while using sudo is like selling your friend's car by legal proxy.

As for what you were trying to do, just sudo su root, or even more simply sudo su and type your regular user password. This would roughly amount to replacing your friend's credit card credentials with your own using the legal proxy they gave you :). It of course assumes the sudo configuration allows you to run su with escalated privileges.

Also, systems that come pre-configured with sudo access typically have the root account disabled (no root password), you can enable that using the passwd command after becoming root via sudo su.

share|improve this answer

It is configurable* but, by default, "sudo" asks you for your password. It is just trying to make sure that it is you, not someone using your keyboard while you were getting coffee.

By contrast, "su root" asks you for the root password.

*If targetpw in /etc/sudoers is false (default), "sudo" asks you for your password. If it is true, then "sudo" asks you for the password of root or, if you specified some other user with the "-u" option, the password of that user.

share|improve this answer

sudo is used to temporarily escalate user permissions to root level, whereas su root is used to create a new shell with root as a user;

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.