Does Linux have a CTRL+ALT+DEL equivalent?
9 Answers
Under GNU/Linux [at least those based on the SystemV init style], the behavior of ctrl+alt+del relies on the configuration file /etc/inittab where you should be able to read a line like:
<id>::ctrlaltdel:/sbin/shutdown -t3 -r now
(example from an ArchLinux distribution) which means that the system will be shutdown when it receives the key combination. But you may want to do something else, like*:
<id>::ctrlaltdel:/usb/bin/sudo make me a sandwich
(which is much more useful :)
- 392
Well you can create shortcut for Alt+Ctrl+Del in Linux, but there is some other more interesting combinations that you might like to know.
Holding down Alt and SysRq (which is the Print Screen key) and typing REISUB with a few(I usually count to 5) seconds between each key will get you safely restarted. REISUO will do a shutdown rather than a restart. As pointed out by a comment, this is not a single command, but a combination of many commands, each doing a specific thing. So I recommend to take a look at REISUB - the gentle Linux restart for more details.
And you might already know this but press Alt + Ctrl + any of the keys from F1 to F6 to get a console at any time, which you can use to login in text mode and use command line. This was very helpful when I messed my desktop environment.
- 497
The Linux kernel can either hard reboot or send SIGINT the init process upon Ctrl + Alt + Del
Therefore, if the SIGINT behaviour is enabled, then you can make Ctrl + Alt + Del do whatever your init wants it to do.
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:
rebootsystem call, seeman 2 reboot/proc/sys/kernel/ctrl-alt-del
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.
On Ubuntu 20.10 for example, which uses systemd as the init, everything is wired up so that Ctrl + Alt + Del by default offers to log you out on the GUI. How can I give a grace period to CTRL-ALT-DEL in systemd suggests that this is controlled by /lib/systemd/system/ctrl-alt-del.target, but on my system that is just a symlink to reboot.target, which seems to actually reboot, not just logout. Maybe someone more patient than me can figure out exactly what is going on.
- 12,482
Yes, however the action it takes depends on desktop manager configurations. In KDE it shows a dialog for which you can choose if restart or halt the system.
- 169
REISUB would be the closest equivalent. Magic SysRq keys are the only way of emulating traditional Windows / DOS hard-resets in Linux / UNIX.
For a Program Manager-like interface, use top and hit 'k' for 'k'ill.
Ctrl+Alt+Backspace is disabled by default in X Servers > 1.6 (although some distros re-enable it in the config files that they ship). Although it doesn't do what Windows Ctrl+Alt+Del does in general killing X and fixing misbehaving programs is preferred over restarting the machine.
- 189
Yes, they are the same keys as on Ubuntu but they may vary according to your distribution.
- 57,881
- 1,051
In gnome, there's a feature called "Keyboard Shortcuts" that lets you customize keyboard shortcuts.
The process manager for Gnome is called gnome-system-monitor, so if you go to: - System; - Preferences; - Keyboard Shortcuts and add gnome-system-monitor as CTRL+ALT+DEL it should work for you :)