7

In my gnome GUI desktop of Ubuntu 12.04, Ctrl+Alt+Delete will log out instead of rebooting.

But I was told that

Switching to a text-based virtual console and pressing Ctrl+Alt+Delete will reboot the machine. It will shut down cleanly and reboot, which is much better than Alt+SysRq+REISUB.

So I wonder if the above two different meanings of Ctrl+Alt+Delete are right?

What commands Ctrl+Alt+Delete is binded to in these two cases?

6

Ctrl+Alt+Delete is actually a "magic" keystroke for the IBM PC-compatible hardware architecture that would call a BIOS reset.

Since this kind of thing is dangerous for a system like Linux the decision was made to hook those keystrokes and do something else instead. This is controlled by init and you can see what it does by looking in /etc/inittab.

On my Debian Squeeze system:

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

Windows NT later followed suit and turned Ctrl+Alt+Delete into the secure key entry mode*.

In the case of X, it is similarly hooking the keystrokes but it simply kills the display server (which will automatically respawn if you're using a display manager).

Some systems (perhaps all, I haven't tried in a while) you can still press Ctrl+Alt+Delete before the OS loads to trigger a BIOS reset.


*I'm not sure what they actually call it.

  • Thanks! What is /etc/inittab used for? – Tim Jul 8 '12 at 12:07
  • @Tim: /etc/inittab is more or less the config file for init. – bahamat Jul 8 '12 at 18:01
  • On my Ubuntu 12.04, there is no /etc/inittab. What might possibly be the alternative? – Tim Jul 8 '12 at 21:08
  • Mm, that's right. Ubuntu uses upstart rather than init. The equivalent on Ubuntu is the etc/init directory. (Note not /etc/init.d). – bahamat Jul 8 '12 at 22:29
  • 1
    @Tim /etc/init/control-alt-delete.conf As for upstart, upstart is still called init, but it's not the traditional init. See the Wikipedia article and the project page. – Eliah Kagan Jul 9 '12 at 1:43
2

The Linux kernel can either hard reboot or send SIGINT the init process upon Ctrl + Alt + Del

The Linux kernel itself allows two possible behaviors from Ctrl-Alt-Del:

  • reboot immediately
  • send SIGINT to the init process

Which behavior is used can be selected with either:

  • reboot system call, see man 2 reboot
  • /proc/sys/kernel/ctrl-alt-del

Therefore, if the SIGINT behaviour is enabled, then the outcome of Ctrl + Alt + Del depends entirely on the SIGINT handler that your init has.

For example, BusyBox' 1.28.3 init execs an arbitrary command given in /etc/inittab as:

::ctrlaltdel:/sbin/reboot

And here is a minimal interesting C example for uclibc:

#define _XOPEN_SOURCE 700
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/reboot.h>
#include <unistd.h>

void signal_handler(int sig) {
    write(STDOUT_FILENO, "cad\n", 4);
    signal(sig, signal_handler);
}

int main(void) {
    int i = 0;
    /* Disable the forced reboot, enable sending SIGINT to init. */
    reboot(RB_DISABLE_CAD);
    signal(SIGINT, signal_handler);
    while (1) {
        sleep(1);
        printf("%d\n", i);
        i++;
    }
    return EXIT_SUCCESS;
}

Here is an easy setup to try this out.

1

Contemporary Linux distros use systemd instead of SysV init. Behaviour of ctrl-alt-delete combo is handled by ctrl-alt-del.target, which is by default linked to reboot.target, but could be set to any other one.

List of targets available:

systemctl list-unit-files -t target

Switching target

Pressing the combo 7+ times within 2 seconds (like press and hold) would force immediate reboot by default (or the action specified by CtrlAltDelBurstAction).

There is also useful kbrequest.target, but this is not enabled by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.