CentOS Linux shutdown, reboot by non-admin non-root users

“sudo is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user”

And we are going to use the same program to assign a user the right or access permission to shutdown or reboot a CentOS based computer system.

Steps to allow non-root non-admin user to shutdown or reboot a CentOS system:

  1. Login as root in the terminal
  2. Create a new group on Centos named ‘developers’ or you may assign the right to an existing group as well.
  3. Install Sudo by using the command: $ yum install sudo
  4. Now edit the sudo configuration using the command: $ visudo
  5. Look for some thing like ‘# %users localhost=/sbin/shutdown now’
  6. Press ‘i’ or insert keyboard button of your keyboard to start editing the config file
  7. Below the above line add the following lines:
    1. %developers ALL=/sbin/shutdown now
    2. %developers ALL=/sbin/reboot
  8. now save the config file by doing:
    1. press ‘Esc’ keyboard button
    2. then type without quotes: “:wq!”
    3. Hit return key

And you are done!

Now any user of the group ‘developers’ will be able to shutdown the system using the following command
$ sudo shutdown now

To reboot:
$ sudo reboot

Comments are closed.