What is the meaning of 0 in /proc/sys/kernel/ctrl-alt-del file in Linux ?

Do you know what is the meaning of value stored in /proc/sys/kernel/ctrl-alt-del file ?

Let us have a look at it.

I. Meaning of default values

[root@ngelinux kernel]# cd /proc/sys/kernel
[root@ngelinux kernel]# cat ctrl-alt-del 
0

Here 0 value means ctrl-alt-del is trapped and sent to the init program to handle the request as mentioned in the configuration file(which is usually graceful restart).

When this value is greater that zero, the linux kernel performs an immediate reboot, without even syncing its dirty buffers.

 

II. Changing ctrl-alt-del behavior

RHEL or CentOS 7: On Grub 2

[root@ngelinux kernel]# cat /etc/inittab  
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
[root@ngelinux kernel]# 


[root@ngelinux kernel]# cat /usr/lib/systemd/system/ctrl-alt-del.target
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Reboot
Documentation=man:systemd.special(7)
DefaultDependencies=no
Requires=systemd-reboot.service
After=systemd-reboot.service
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=reboot-force

[Install]
Alias=ctrl-alt-del.target
[root@ngelinux kernel]# 

As we can see above, “JobTimeoutAction” decides what to do when pressing ctrl-alt-delete.

 

On RHEL 6

# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf

[root@nglinux ~]# 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"

In above file, we can see the command shutdown is called.

Note:– When a program like dosemu has keyboard in raw mode, ctrl-alt-del is intercepted by program even before it reaches the kernel layer, and the program used to decide what to do with it.

Leave a Reply

avatar
  Subscribe  
Notify of