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?

  • 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 '12 at 23:41
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.

  • 1
    Where "a period of time" is 5 minutes IIRC. – Jason Salaz Jun 7 '12 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 '12 at 1:57
  • @JasonSalaz: Yes, by default. See the entry timestamp_timeout in the sudoers manual page. – Harald Hanche-Olsen Jun 7 '12 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 '12 at 12:30
  • Indeed, it's system-wide. – Daniel Jun 7 '12 at 15:30
3

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

  • This does not answer the OPs question. – Jason Salaz Jun 7 '12 at 18:37
  • @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 '12 at 20:31

You must log in to answer this question.

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