[Linux] Magic Keys
When the system freezes
Sometimes the system freezes and will not respond at all to any solicitation (keyboard / mouse)
, and the only solution that comes to mind (for most Windows user's)
is to press the Reset
But as we shall see, there is a series of combination of keys that allow (most of the time) to adopt our system with minimal risk and to limit, restrict the loss of data. This is called the "Magic Keys"
In short Magic keys are a combination of keys that allows you to execute low levels commands despite the actual state of your system,(directly processed by the Kernel).
Of course to implement these magic combinations, then the option is compiled into the kernel
. So check this condition.
But that's not all. If in a distribution like Mandriva the option is enabled by default, this is not the case for all others. We must therefore check that the option is enabled. To do this, type in a terminal:
- which will have for value: "1".
- Otherwise (the return value of "0"), do the following to activate it (as root):
echo "1" > /proc/sys/kernel/sysrq
- You can also use the sysctl command instead of echo
sysctl -w kernel.sysrq="1"
- There is however a drawback.
- The change made with echo or sysctl will be lost when you restart the system.
- For the configuration to be permanent you must edit the file / etc / sysctl.conf or by using a text editor and adding the line kernel.sysrq = 1 or using the command
echo 'kernel.sysrq=1' >> /etc/sysctl.conf
Points to consider
When the system freezes (we assume we are in an X session
), and before implementing the use of magic keys, if your keyboard is still active, first try:
- Kill the X server using the key combination "CTRL + ALT + BACKSPACE"
- Switch to another console "CTRL + ALT + Fn (n = 1-6)
- Try to kill the X server (as root):
- kill -15 $ (pidof X)
- kill -9 $ (pidof X)
If there is a local network, try connecting with "ssh
" from another machine and resume the hand on your workstation.
If all these attempts have failed, then it is time to use the "Magic Keys
The Magic Keys
The Magic Keys (SysReq or keys) require the use of a combination of three keys at once.
- The "alt" (to the left of the spacebar, not to be confused with the "ALT Gr"), the *"SysRq (System Request), this key is nothing but the key known and designated by *"Print Screen System" (top right of the keys F1 through F12), and finally a third button from the following letters:
- R: Raw activates the keyboard mode "raw" (raw). Try to access to your keyboard.
- E: term SIGTERM. Sends a termination signal to all processes except init.
- I : kill SIGKILL. Sends a signal to end all processes except init.
- S: Sync synchronization disk. Try to write all unsaved data.
- U: umount all file systems in read-only mode. Prevents a file system check on reboot
- B: reboot Reboot the system. Cleaner than pressing "reset".
- O: Out off the system.
- L: kill SIGKILL. Sends an end signal to all processes, including init.
- K: Key Sends a signal to end all processes on the current virtual console.
- P: Print Displays the contents of the registers and flags (flags) in the console.
- M: Memory Displays memory contents in the console.
- T: Task List contents of the tasks running and information about them.
- 0-9: Number Sets the level of the console log.
- H: Help Displays a help on the codes keys.
Making use of Magic keys
It should be understood that the use of the Magic Keys
is a sequence
, these keys should be used in a specific order:
Note that :
- Set the keyboard in "raw"
- Sync disks
- Sends a stop signal to the process
- Mounting filesystems read-only
- Sends a termination signal to process
- Reboot the system
This is a mnemonic phrase to remember the order of the sequence (in English): "Raising Elephants Is So Utterly Boring"
For unlimited offline reading, you can download this article for free in PDF format:
In the same category