Sunday, 7 January 2018

script to grant permission for particular user to start | stop | restart the services

Please find below the script to grant permission for particular user to start | stop | restart the services.
Path where to be to add the following files - cd /etc/sudoers and create a new file /etc/sudoers.d/file_name then add the following script.
Defaults: !requiretty, secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Cmnd_Alias USERNAME_CMD = /etc/init.d/mysql start, /etc/init.d/mysql stop, /etc/init.d/mysql restart, /etc/init.d/mysql status
(Here you can add the service which ever need )
Defaults!USERNAME_CMD !requiretty
username ALL=(username) NOPASSWD: USERNAME_CMD username ALL=(root) NOPASSWD: USERNAME_CMD root ALL=(username) NOPASSWD: USERNAME_CMD

and on the /etc/sudoers file add the following line to grant privilege for the user.
username ALL=(username) NOPASSWD: USERNAME_CMD
--
Here on the user name add the user which ever created and granting permission to them.

No comments:

Step-by-step OpenLDAP Installation and Configuration on server

This tutorial describes how to install and configure an OpenLDAP server and also an OpenLDAP client. Step by Step Installation and Conf...