Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to edit /etc/sudoers so that I can execute a bash script with a root password.

so far every edit I've tried to sudoers is not working.

I've tried adding each of these lines:

%admin    ALL= NOPASSWD: /sbin/ifconfig

%admin    ALL=(ALL) NOPASSWD: /sbin/ifconfig

%users    ALL=(ALL) NOPASSWD: /sbin/ifconfig

"myusername"  ALL=(ALL) NOPASSWD: /sbin/ifconfig

Each time I am able to save and quit out of visudo without any warning about syntax errors. But then when I try to execute the ifconfig command from my admin account, it still says 'permission denied'

ifconfig en0 down
ifconfig: down: permission denied 

Can someone please tell me what is going wrong? thanx

share|improve this question

You have to prefix your command submission with 'sudo'. In your case, the command would be:

 sudo ifconfig en0 down

Also, with your config you are allowing ANY ifconfig command line parameters to be used. The correct and much more restrictive sudoers entry is:

 %admin     ALL=(root) NOPASSWD: /sbin/ifconfig en0 down

Please do read the man pages on sudo and look at the various good sources of sudo information out there via google.

share|improve this answer

Your Answer


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.