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.

  • 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, 2014 at 15:56
  • @fixer1234 As explained in John1024's answer, when you use sudo, the system asks for your password to verify your identity, then checks /etc/sudoers to see if you're allowed to run sudo. When you use su, the system requires you to input the password of the user you're switching to. (I know this is now a very old question, but I wanted to add a clarification for the benefit of future viewers.)
    – anonymoose
    Oct 7, 2018 at 19:33
  • @anonymoose, this question was about the OP's personal machine. Typically, when you install Linux on your own machine, you would know if you gave root a different password from your regular user. The question indicates that the OP was surprised to find out that root had a different password.
    – fixer1234
    Oct 7, 2018 at 21:47
  • 1
    @fixer1234 The OP might not have set a root password to begin with. Ubuntu's installer doesn't ask for a root password, and I'm sure that some other distros don't.
    – anonymoose
    Oct 7, 2018 at 22:02

4 Answers 4


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.

  • For home user, would you recommend setting root password in addition to having user with privileges (As in sudo)?
    – Royi
    Dec 22, 2019 at 17:52

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.


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;


For the benefit of some newcomers into this search, there is a simple method to go into root until you exit:

     sudo -iE

Will keep you interactive and keep your environment but now, as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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