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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYou 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
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
su
. It's important to verify that various changes don't break anything, but this would only break something if a core system script was both running as non-root (unlikely) and called the reboot
binary directly (also unlikely). I haven't tested this specific change but "don't change modes on system files" isn't a valid general principle in my experience.
Jun 24, 2013 at 13:37
setfacl
and chmod
commands (in case someone manually makes permissions more liberal and doesn't reset them) other places use IDS tools like Tripwire to ensure continued compliance.
Jun 24, 2013 at 13:56
These commands already force you to either be root or be logged in to the console. If a normal user runs "halt" or "reboot" from an ssh session, it refuses to halt or reboot the system:
$ halt
halt: must be superuser.
halt
andreboot
.