Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

su -u fred su -
Password:

(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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.