sysrq
Reference table of Linux Magic SysRq keys for low-level system control, debugging, recovery, and emergency operations
| Command | Function |
|---|---|
| b | Immediately reboots the system without syncing or unmounting disks. |
| c | Performs a system crash; a crashdump will be taken if configured. |
| d | Shows all locks that are held. |
| e | Sends SIGTERM to all processes except init. |
| f | Invokes the OOM killer to kill a memory-hog process (no panic if nothing can be killed). |
| g | Used by kgdb (kernel debugger). |
| h | Displays help (any undefined key will also show help). |
| i | Sends SIGKILL to all processes except init. |
| j | Forcibly "just thaw it" — unfreezes filesystems frozen by the FIFREEZE ioctl. |
| k | Secure Access Key (SAK): kills all programs on the current virtual console. |
| l | Shows a stack backtrace for all active CPUs. |
| m | Dumps current memory info to the console. |
| n | Used to make RT tasks nice-able. |
| o | Shuts the system off (if configured and supported). |
| p | Dumps current registers and flags to the console. |
| q | Dumps per-CPU lists of armed hrtimers and clockevent device details. |
| r | Turns off keyboard raw mode and sets it to XLATE. |
| s | Attempts to sync all mounted filesystems. |
| t | Dumps a list of current tasks and their information. |
| u | Attempts to remount all mounted filesystems read-only. |
| v | Forcefully restores framebuffer console. |
| v | Dumps ETM buffer (ARM-specific). |
| w | Dumps tasks that are in uninterruptible (blocked) state. |
| x | Used by xmon on PPC/PowerPC; shows PMU registers on sparc64; dumps TLB entries on MIPS. |
| y | Shows global CPU registers (SPARC64-specific). |
| z | Dumps the ftrace buffer. |
| 0–9 | Sets the console log level (e.g. 0 = only emergencies like PANIC/OOPS). |
| R | Replays kernel log messages on consoles. |
How do I enable the magic SysRq key
0- Disable sysrq completely1- Enable all functions of sysrq>1- Bitmask of allowed sysrq functions (see below for detailed function description):
| Value | Description |
|---|---|
| 2 = 0x2 | Enable control of console logging level |
| 4 = 0x4 | Enable control of keyboard (SAK, unraw) |
| 8 = 0x8 | Enable debugging dumps of processes etc |
| 16 = 0x10 | Enable sync command |
| 32 = 0x20 | Enable remount read-only |
| 64 = 0x40 | Enable signalling of processes (term, kill, oom-kill) |
| 128 = 0x80 | Allow reboot/poweroff |
| 256 = 0x100 | Allow nicing of all RT tasks |
Search for CONFIG_MAGIC_SYSRQ i kernel config
$ rg CONFIG_MAGIC_SYSRQ /usr/src/linux/.config
CONFIG_MAGIC_SYSRQ=y
CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
CONFIG_MAGIC_SYSRQ_SERIAL=y
CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""
Search for CONFIG_MAGIC_SYSRQ_DEFAULT_ENABL i kernel config
$ rg "CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE" /usr/src/linux/.config
CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
You can set the value in the file by the following command
The number may be written here either as decimal or as hexadecimal with the 0x prefix. CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE must always be written in hexadecimal
echo "number" >/proc/sys/kernel/sysrq
Will perform a system crash and a crashdump will be taken if configured.
echo c >/proc/sys/kernel/sysrq
How do I use the magic SysRq key
You press the key combo ALT-SysRq-<command key>
Resource(s)