0

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

su - fred
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?

John Leuenhagen
  • 119
  • 1
  • 7
Steve Bennett
  • 5,750
  • 12
  • 47
  • 59

2 Answers2

4

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.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
1

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

Jamie
  • 1,284
  • 7
  • 22
  • 40
  • 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 03:35