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
add comment

1 Answer 1

up vote 6 down vote accepted

You should consider using sudo with the NOPASSWD config.

See man 5 sudoers

Ex:

Host_Alias     LOCAL=192.168.0.1
user_foobar    LOCAL=NOPASSWD: /etc/init.d/apache2
share|improve this answer
1  
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 –  sputnick Mar 19 '12 at 13:25
    
Works as a charm, thanks! –  user Mar 29 '12 at 22:55
    
U're welcome ;) –  sputnick Mar 30 '12 at 0:28
add comment

Your Answer

 
discard

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.