Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to add a user to the sudoers file so that it can only start, stop and restart a particular service.

I am using Debian and can access the sudoers file using sudo visudo, I am stumped now though on how to set up this one user to be limited to one service.

share|improve this question
    
This should probably be moved to unix & linux stackexchange site. I flagged it to get moved. –  slm Apr 5 '13 at 12:46
add comment

1 Answer 1

up vote 4 down vote accepted
root@megatron# visudo

Append following line (where megatron is your hostname)

jakenoble megatron=/etc/init.d/httpd start, /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd restart

Save and close the file. You have to type following command:

jakenoble@megatron$ sudo /etc/init.d/httpd restart

You must list the full command you want someone to run for visudo to allow it.

For example, given the line in /etc/sudoers

 %users  localhost=/sbin/shutdown -r now

Users can only RESTART (-r) the machine, they cannot HALT (-h) it.

share|improve this answer
    
That makes sense, I will try it –  Jake N Apr 5 '13 at 14:17
    
Good summary, lots of questions recently that involve visudo. –  nerdwaller Apr 5 '13 at 15:00
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.