Add a user to sudoers file, for just one service

Solution 1:

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.