I'd like to be able to restart apache under OS X Lion without entering a password. I tried placing this in
<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?
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.
Remember that, for changes in
visudoto 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:
Store it in your personal shell configuration file (e.g.
~/.bash_profile) to persist.