Panel For Example Panel For Example Panel For Example

Using the Linux SysRq Key for Debugging

Author : Adrian September 03, 2025

The SysRq key is a powerful tool for system recovery and debugging. As long as the kernel is not completely frozen, it will respond to SysRq key combinations, allowing you to collect system information such as memory usage, CPU task handling, and process states.

 

Configuration

To use SysRq, you must enable the CONFIG_MAGIC_SYSRQ option in your kernel configuration. After booting, this will create the /proc/sysrq-trigger node for debugging purposes.

Enable SysRq by adding the following line to /etc/sysctl.confkernel.sysrq=1

Run the following command to apply the changes:

sysctl -p

You can also enable SysRq temporarily by writing a value to echo "number" /proc/sys/kernel/sysrq. Different values enable specific features:

Value Description
0 Disable SysRq completely
1 Enable all SysRq functions
2 Enable control of console logging level
4 Enable keyboard control (SAK, unraw)
8 Enable process debugging dumps
16 Enable the sync command
32 Enable remounting filesystems as read-only
64 Enable sending signals to processes (term, kill, oom-kill)
128 Enable reboot/power off
256 Enable real-time task priority adjustment

 

How to Use SysRq

To use SysRq, echo a command key to the /proc/sysrq-trigger node:

echo <command key> > /proc/sysrq-trigger

The <command key> is case-sensitive.

The available command keys are listed below:

Command Key Function

b

Immediately reboots the system without syncing or unmounting disks.

c

Performs a system crash, triggering a crash dump if configured.

d

Displays all held locks.

e

Sends a SIGTERM signal to all processes except init.

f

Calls the OOM killer to terminate a memory-intensive process. It will not cause a panic if no process is killed.

g

Used by kgdb (kernel debugger).

h

Displays help text. Any key not listed here will also show help.

i

Sends a SIGKILL signal to all processes except init.

j

Forcibly thaws 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 information to the console.

n

Resets the priority of all real-time tasks to normal.

o

Shuts down the system (if configured and supported).

p

Dumps the current registers and flags to the console.

q

Dumps information about all armed high-resolution timers and clock event devices for each CPU.

r

Switches the keyboard from raw mode to XLATE mode.

s

Attempts to sync all mounted filesystems.

t

Dumps a list of current tasks and their information to the console.

u

Attempts to remount all mounted filesystems as read-only.

v

Forcibly restores the framebuffer console.

w

Dumps tasks that are in an uninterruptible (blocked) state.

x

Used for xmon on ppc/powerpc. Shows global PMU registers on sparc64. Dumps all tlb entries on MIPS.

y

Displays global CPU registers (SPARC-64 only).

z

Dumps the ftrace buffer.

0-

9

Sets the console log level, which controls which kernel messages are printed to the console (e.g., '0' will only show emergency messages like PANICs or OOPSes).

 

Summary

SysRq is a well-established feature for safely handling system hangs and performing reboots.