Skip to main content

Sudoers Configuration (stop and start services)

So you want to allow other users to stop and start some of the services. From the linux point of view you can do this by using sudo.

Change ".bash profile" file contents of the user so that "service" and "chkconfig" commands will be in the PATH environment variable. "/sbin" folder must be included.

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
# User specific environment and startup programs
export PATH

Change the "/etc/sudoers" file using "visudo" command like:

Host_Alias       OPNETS = <ip address of the server>
User_Alias       OPERATORS = <username>, root
Runas_Alias     OP = <username>, root
Cmnd_Alias      SERVICES = /sbin/service, /sbin/chkconfig

Defaults        logfile=/var/log/sudo.log
Defaults       lecture_file=/etc/mylecturefile


"logfile" holds logs that contains which commands executed with the user at which time from which terminal console and from which ip address etc. "NOPASSWD" is required for using sudo without password.

After these changes the operator user can be list services and can change status of the services.

# sudo chkconfig --list
# sudo service sendmail stop


Popular posts from this blog