Centos – How to ensure only the root user have the right to halt/reboot the system

centospermissionsrebootshutdown

CentOS Linux by default allows all users to have permission to "halt" & "reboot" the system by using the commands halt and reboot.

How can I configure my system so that only the root user has the right to halt/reboot the system?

Best Answer

CentOS/RHEL/Fedora

You can disable access to these commands by removing their entries in the /etc/security/console.apps/*:

$ $ ls /etc/security/console.apps/
authconfig      gparted          poweroff                      system-config-date      system-config-network-cmd  zenmap-root
authconfig-gtk  halt             reboot                        system-config-keyboard  system-config-selinux
authconfig-tui  kismet_capture   setup                         system-config-language  system-config-users
chkrootkit      liveusb-creator  system-config-authentication  system-config-lvm       wifi-radar
config-util     lshw-gui         system-config-boot            system-config-network   wireshark

$ rm -f /etc/security/console.apps/reboot

Above was found here: 27.2. Disabling Console Program Access - CentOS Deployment Guide

Hack method

I think you can achieve this by doing the following. In the directory /lib/upstart, are the following commands:

$ pwd
/lib/upstart

$ ls -la
total 176
drwxr-xr-x.  2 root root  4096 Sep  9  2011 .
dr-xr-xr-x. 16 root root 12288 May  4 21:27 ..
lrwxrwxrwx   1 root root     6 May 26  2011 halt -> reboot
lrwxrwxrwx   1 root root     6 May 26  2011 poweroff -> reboot
-rwxr-xr-x   1 root root 17112 May 11  2011 reboot
-rwxr-xr-x   1 root root 14472 May 11  2011 runlevel
-rwxr-xr-x   1 root root 65976 May 11  2011 shutdown
-rwxr-xr-x   1 root root 56304 May 11  2011 telinit

chmod 700 the reboot executable:

$ chmod 700 /lib/upstart/reboot
Related Question