• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to disable Ctrl+Alt+Del causing system reboot in CentOS/RHEL 6

by admin

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
Note : This method doesnt work on a terminal server which have many users logged in the server at the same time though vnc. You may have to modify the script accordingly.
How to Disable “alt+ctrl+Del” Key Combination causing reboot in CentOS/RHEL 4,5
How to disable “Alt+Ctrl+Del” causing system reboot in CentOS/RHEL 7

Filed Under: CentOS/RHEL 6, Linux, OEL 6

Some more articles you might also be interested in …

  1. Linux OS Service ‘NetFS’
  2. loadkeys Command Examples in Linux
  3. How To Configure Separate Override.conf For Multiple MySQL Instances Using Systemd
  4. flameshot: command not found
  5. pkginfo: command not found
  6. How to gzip all or specific files in Linux
  7. conky: command not found
  8. gdebi: command not found
  9. vdir: command not found
  10. RDEPENDS V/s DEPENDS in Yocto

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright