The key combination “Ctrl+Alt+Del”, when pressed on a virtual console (black-screen tty), causes the system to reboot. This is the default behavior and sometimes people don’t like this feature as it may cause accidental reboots of the system. The post provides the procedure on how to disable “alt+ctrl+del” key combination in order to prevent an accidental shutdown.
The shutdown command is controlled by /sbin/init, described in /etc/init/control-alt-delete.conf as:
# cat /etc/init/control-alt-delete.conf # control-alt-delete - emergency keypress handling # # This task is run whenever the Control-Alt-Delete key combination is # pressed. Usually used to shut down the machine. # # Do not edit this file directly. If you want to change the behaviour, # please create a file control-alt-delete.override and put your changes there. start on control-alt-delete exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
As described in the file, *do not* comment out the line “exec /sbin/shutdown…” to prohibit the command, but instead, follow the steps outlined below.
1. generate a new file /etc/init/control-alt-delete.override which has just one line:
# vi /etc/init/control-alt-delete.override exec /bin/true
2. reflect the new configuration of control-alt-delete instance by initctl command:
# initctl reload-configuration control-alt-delete
Then, “alt+ctrl+del” key combination will do nothing now. You do not need to reboot the server, restart any services, either any processes.
Disabling the “Ctrl+Alt+Del” triggered shutdowns and logging the events of the key press instead
Sometime you may want to disable the “Ctrl+Alt+Del” triggered shutdowns and only cause some audit-log entry, instead of a system reboot. Follow the steps otlined below:
1. Use the original .conf file to create the control-alt-delete.override file, e.g.:
# cp -v /etc/init/control-alt-delete.conf /etc/init/control-alt-delete.override
2. Edit the file /etc/init/control-alt-delete.override, replacing the exec /sbin/shutdown line, With a line like the following, which will simply generate a log entry each time Ctrl-Alt-Del is pressed:
# vi /etc/init/control-alt-delete.override exec /usr/bin/logger -p authpriv.notice -t init "Ctrl-Alt-Del was pressed and ignored"
3. Test by switching to a virtual console and pressing Ctrl-Alt-Del.
Allow only root to reboot when “Ctrl+Alt+Del” is pressed from console
You can allow only root to reboot it by following the below procedure.
1. Edit /etc/init/control-alt-delete.conf, remove all lines and put in the following lines:
# vi /etc/init/control-alt-delete.conf start on control-alt-delete exec /sbin/control-alt-delete.sh
2. Now create a /sbin/control-alt-delete.sh with a vi editor with the following content.
# vi /sbin/control-alt-delete.sh #!/bin/bash user=`w | grep tty | grep root | cut -d' ' -f1` if [ -z $user ] then echo "control + alt + delete tried by non-root user at `date` " >> /var/log/cad.log else /sbin/shutdown -r now "Control-Alt-Delete pressed" fi
3. Give 500 permission to /sbin/control-alt-delete.sh
# chmod 500 /sbin/control-alt-delete.sh
How to disable “Alt+Ctrl+Del” causing system reboot in CentOS/RHEL 7