I have a Non Root User abc
and want to give the user sudo
rights only to restart
, start
or stop
- mysqld service
. i.e sudo service mysqld restart
. How can I do it so?
I would like to do the same to usergroup too!!
You need to add the following lines in /etc/sudoers
dba01 ALL=/sbin/service mysqld start dba01 ALL=/sbin/service mysqld stop dba01 ALL=/sbin/service mysqld restart
this config will allow dba01 user to execute all three commands.
Now here is the output
[dba01@APP01 root]$ sudo /sbin/service mysqld restart [sudo] password for dba01: Shutting down mysqld: [ OK ] Starting mysqld: [ OK ]
If you try to run any other service
[dba01@APP01 root]$ sudo /sbin/service ip6tables restart Sorry, user dba01 is not allowed to execute '/sbin/service ip6tables restart' as root on APP01.
/sbin/service mysqld
will grant permission to run it with any arguments.
granting permissions to allow the group to run sudo service
, would give them permission to restart any service. I would simply grant them access to the init script.
You can do this by adding the following line to the sudoers file
%groupName ALL=(ALL) NOPASSWD: /etc/init.d/mysql
Then the group members should be able to run
sudo /etc/init.d/mysql restart
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql restart
sudo visudo
to go to sudoers file....then i added a line User_Alias GROUPONE = abc1,abc2,abc3,...
Oct 15, 2015 at 14:32
%GROUPONE ALL=(ALL) NOPASSWD: /etc/init.d/mysql
Oct 15, 2015 at 14:33