Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer
    
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 Lawson Jun 7 '12 at 15:30
show 2 more comments

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
share|improve this answer
add comment

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

share|improve this answer
    
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
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.