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?

link|improve this question

44% accept rate
Which pair of commands are you asking about? The ones in the question body? Or the ones in the question title? – JdeBP Jan 25 at 8:15
The ones in the question body. You don't seem to be able to change titles. – Steve Bennett Jan 30 at 5:20
feedback

2 Answers

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.

link|improve this answer
feedback

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

link|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 at 3:35
feedback

Your Answer

 
or
required, but never shown

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