Linux - Sudo or sudoers permission for start stop service, Visudo permission for accessing command service

Sudo or sudoers permission for start stop service

How do I give new admin only permission to start and restart Apache web server?

How do I setup sudo for the same via sudoers file?

In redhat Linux or RHEL, the sudo command allows a user to execute the specified command as a superuser or as a specified user. The real and effective uid and gid are set to match those of the target user as specified in the passwd file and the group vector is initialized based on the group file.

The visudo commad is used to edit the file /etc/sudoers
 # visudo


 mathieu ALL=(ALL)  NOPASSWD: /etc/init.d/httpd, /sbin/service httpd start, 
 /sbin/service httpd stop, /sbin/service httpd restart, /sbin/service httpd status


The above gives the user mathieu root access to the command /etc/init.d/httpd, /sbin/service httpd.. Thsi allows the user to start, stop, restart or check the status of the service httpd or apache.

For example if you want to execute a script as a oracle user, then you can use the below.
 oraadmin       ALL=(oracle)    NOPASSWD: /opt/oracle/bin/emctl

The topic on Linux - Sudo or sudoers permission for start stop service is posted by - Math

Hope you have enjoyed, Linux - Sudo or sudoers permission for start stop serviceThanks for your time

Tech Bluff