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

This question already has an answer here:

I have tried this on Fedora and on Ubuntu.

su: Authentication failure

kshitiz@kshitiz:~$sudo su


I am entering the same password in both the cases.

share|improve this question

marked as duplicate by Gilles, Renan, vonbrand, n0pe, jasonwryan Mar 13 '13 at 22:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 7 down vote accepted

su requires the password of the account whose privileges you are trying to assume (apparently root in this case).

sudo requires the password of the current user - that is, the password for user kshitiz.

By running sudo su, you are effectively becoming root, then running su to get a root shell - that is, your privileges are already elevated to root before the call to su is executed, which is why you don't get prompted for the root password again.

share|improve this answer

su uses the root password, while sudo uses the current user password. At least in Ubuntu the root password is scrambled during installation.

share|improve this answer
Isn't that a security loophole? Since any user in sudoers list can elevate to root what is the purpose of having a su account with scrambled password? Why doesn't setup just put the same password for su and kshitiz? – Kshitiz Sharma Mar 13 '13 at 10:42
@KshitizSharma : The "su" password in this case is the root password. If you are asking, "what's the purpose of the root account?", methinks the caveat against using root has gone a bit far, lol -- but that would make a good separate question. The reason you must be root to use su with no arguments is because it stands for "switch user" (not "super user") but, if you don't specify anything, the default is root. You can, however, specify anyone, eg. "su kshitiz" -- in which case you would need kshitiz's password, not root's. Make sense? – goldilocks Mar 13 '13 at 11:52
@KshitizSharma, yes, it is a hole. sudo is to give selected users permissions to run some programs as root (or other users). This way those users can run any program as root. It is a bit safer than letting Joe Random switch to root to do something (and stay there!), but not much better. As configuration for personal machines it is fine, elsewhere a much more careful configuration is required. – vonbrand Mar 13 '13 at 14:01

In fact, you can specify in the /etc/sudoers file (use visudo) which password the user who issues sudo has to enter. If these lines

# Defaults      targetpw
# ALL   ALL = (ALL) ALL  

were uncommented, you would have to enter the root-password to run passwords with root-permissions via sudo.

share|improve this answer

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