I entered my username in the sudoers file, but when using sudo in scritps, it still asks for the password.

This is my sudoers file:

~: ls -al /etc/sudoers
-r--r-----  1 root  wheel  1297 Aug 14 11:44 /etc/sudoers  


%admin  ALL=(ALL) ALL
petruza ALL=(ALL) ALL

(http://pastebin.com/raw.php?i=F38RxeYP) (I also tried with %petruza but didn't work either)

I have a script to start XAMPP, but it asks for the password anyway:

sudo /Applications/XAMPP/xamppfiles/xampp start

1 Answer 1


Please realize that disabling the password prompt for sudo is a huge security concern.

However, it is possible. Instead of what you already have, add this to your /etc/sudoers file:


Here is some more reading on this topic.

  • Thanks, I can see this is a security threat, but there's actually no sensible information of which security I should care about.
    – Petruza
    Aug 15, 2014 at 14:44
  • You should care because, without a password prompt for sudo, a utility can run as a privileged user without you allowing it to or even without you knowing. I think a better option is to use sudo -v, which will cache your credentials and extend the sudo timeout by 5 minutes. This way, you will be prompted less often but not sacrifice a great deal of security.
    – aglasser
    Aug 15, 2014 at 15:29
  • I’ve just found that such a user record must be in sudoers after the root and %admin records. It took me a lot of time… :-/
    – Melebius
    Mar 26, 2020 at 8:36

You must log in to answer this question.

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