Question

I want to give permission to a normal user to start/stop a particular service only. Then how can i tweak the sudoers file to achieve this?

Was it helpful?

Solution

Add this entry in the sudoers file

username ALL=(ALL) NOPASSWD: /etc/init.d/Servicename *

If you are using php_exec,

apache ALL=(ALL) NOPASSWD: /etc/init.d/servicename *

Apache is the user who runs the webserver. It is www-data in some OS.

Also dont forgot to comment out

#Defaults    requiretty 

in sudoers file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top