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

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

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. Understanding /etc/group file
  2. iSCSI connection command examples (Cheat Sheet)
  3. CentOS / RHEL : How to assemble a software RAID in Rescue mode
  4. How to prevent non-root user from creating crontab entry
  5. Understanding /etc/xinetd.d directory under Linux
  6. How to modify snmp service to listen to an alternative port in CentOS/RHEL
  7. How to Setup VNC Server for New User in CentOS/RHEL 5
  8. How to monitor /etc/shadow and /etc/passwd file for changes with Auditd?
  9. What are the mount options to improve ext4 filesystem performance in Linux
  10. CentOS / RHEL 6 : How to Disable / Enable direct root login via telnet

You May Also Like

Primary Sidebar

Recent Posts

  • “su: Authentication failure” – in Docker
  • How to Pause and Resume Docker Containers
  • How to find docker storage device and its size (device mapper storage driver)
  • Understanding “docker stats” Command Output
  • ‘docker images’ command error – “Permission Denied”
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary