3

Why does sudo ask for a password when one can sudo su without a password and perform the same commands? Is there a way to make sudo not ask for a password when you're logged in as the an admin anyway?

1
  • You can remove the password by modifying your sudoers file. I don't remember the details, but man sudoers and man visudo will help.
    – ughoavgfhw
    Jun 6, 2012 at 23:41

3 Answers 3

6

sudo su asks for a password on my system. Did you run another sudo command before the sudo su? Once you've run sudo and entered your password, it doesn't require a password again for a period of time.

7
  • 1
    Where "a period of time" is 5 minutes IIRC. Jun 7, 2012 at 1:30
  • @JasonSalaz That sounds about right. I didn't want to look it up, and the exact time didn't seem all that relevant.
    – Cajunluke
    Jun 7, 2012 at 1:57
  • @JasonSalaz: Yes, by default. See the entry timestamp_timeout in the sudoers manual page. Jun 7, 2012 at 11:38
  • I tried opening a new terminal window before I posted the question but it appears sudoing the password goes across windows
    – Akshat
    Jun 7, 2012 at 12:30
  • Indeed, it's system-wide.
    – Daniel
    Jun 7, 2012 at 15:30
4

You can just modify following lines in /etc/sudoers :

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo  ALL=(ALL:ALL) ALL

to

# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD: ALL

# Allow members of group sudo to execute any command
%sudo  ALL=(ALL:ALL) NOPASSWD: ALL
0

sudo will always want a password once, but just set a crazy long timeout -- and note that it is specified in minutes:

Defaults env_reset,timestamp_timeout=60

2
  • This does not answer the OPs question. Jun 7, 2012 at 18:37
  • 1
    @JasonSalaz In my opinoon the hint for setting a timeout is not a full answer, but helpful for the second question "Is there a way to make sudo not ask for a password...?"
    – Pro Backup
    Jul 3, 2012 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .