Server Fault is a question and answer site for system and network administrators. 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

I know "why" questions are dangerous :) I have sudo access on RHEL, and noticed this:

su -u fred su -

(I don't know fred's password).

sudo -u fred bash
[fred] $

Is there a way to not need fred's password to do the su? Is there a reason to want that?

share|improve this question
Which pair of commands are you asking about? The ones in the question body? Or the ones in the question title? – JdeBP Jan 25 '12 at 8:15
The ones in the question body. You don't seem to be able to change titles. – Steve Bennett Jan 30 '12 at 5:20
up vote 4 down vote accepted

The difference is that sudo uses privileges attached to the account you're running as, while su is more similar to logging in at a normal prompt as the user you're changing to.

Try su root as a regular user that doesn't have permissions in the sudoers file - you can use the root credentials to change to that user, regardless of your current user's rights.

Conversely, sudo and the permissions assigned in your /etc/sudoers file allow your current user to work as root without needing to know any password but your own. For instance, add sudo to the front of your su -u fred command - fred's password is no longer needed, since the su is then running with root privleges.

share|improve this answer

sudo temporarily caches your passwords ... is this the case here?

share|improve this answer
That's true, but not quite relevant - I know my password, I don't know fred's password. (Entering my password in the first example didn't work) – Steve Bennett Jan 25 '12 at 3:35

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.