Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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'd like to be able to restart apache under OS X Lion without entering a password. I tried placing this in /etc/sudoers:

<User> ALL= NOPASSWD: /usr/sbin/apachectl

But when I execute apachectl graceful I get an error message:

This operation requires root.

What do I have to do, in order to get this working?

share|improve this question
up vote 4 down vote accepted

You still need to sudo, otherwise you are executing the command as your user by default. The difference is that it doesn't require you to enter the password.

sudo apachectl graceful

Remember that, for changes in visudo to be applied, you need to quit the editor. It's not enough to save, since the changes are initially applied to a temporary file only.

You can always define an alias or function in your shell, like the following:

alias apachectl='sudo apachectl'

Store it in your personal shell configuration file (e.g. ~/.bash_profile) to persist.

share|improve this answer
Thanks, that's it! – Till Jan 23 '12 at 13:12

You must log in to answer this question.

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