Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For one specific user I want to be able to restart Apache. This user does have sudo privileges and I could run sudo /etc/init.d/apache2 reload, but I want to include this restart script in a git post-receive hook. So this would prompt for the password and fail. So the question is: what is the proper way to allow this user to restart apache, without requiring sudo? I want to restrict option to only restarting Apache, and only this particular user.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You should consider using sudo with the NOPASSWD config.

See man 5 sudoers


Host_Alias     LOCAL=
user_foobar    LOCAL=NOPASSWD: /etc/init.d/apache2
share|improve this answer
You should consider NOPASSWD extremely carefully, though. –  Shadur Mar 19 '12 at 8:53
Sure, don't use that for all commands. Never something like LOCAL=NOPASSWD: /bin/bash –  stArdustͲ Mar 19 '12 at 13:25
Works as a charm, thanks! –  user Mar 29 '12 at 22:55
U're welcome ;) –  stArdustͲ Mar 30 '12 at 0:28

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.