Linux-Noob Forums
How to grant a user access to a system service - Printable Version

+- Linux-Noob Forums (https://www.linux-noob.com/forums)
+-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html)
+--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html)
+--- Thread: How to grant a user access to a system service (/thread-3282.html)



How to grant a user access to a system service - z0ny - 2004-06-23


Let's assume some friend of yours (or even you?) wants to run a system service (or anything else that requires root privileges) on your box and you allow him to do that. Unfortunately the service requires root privileges and you don't want to give him your root password. The solution is 'sudo'.

 

Step 1: Locate the service

Locate the executable of the service, if you use 'service <name> <on|off|...>' as root a good place to look is within '/etc/init.d/'.

 

Step 2: Allow the use of 'sudo'

You have to add the target user to the sudoers list in order to grant him the priviledge to use 'sudo'. That is done by executing 'visudo' (it is recommended to use that command instead of editing the file directly) as root. As we don't want the user to be prompted for a password we add the following to that file (information about the syntax and stuff can be gathered from 'man sudoers'):

 



Code:
<user>   ALL=NOPASSWD: /etc/init.d/<name>




 

We repeat that for every "root-command" (= command that requires root privileges) the user needs access to. After saving the file the specified user is able to control the program by placing 'sudo' in front of the command, in example 'sudo /etc/init.d/<name>'. Kinda easy, isn't it? :)

 

z0ny