Home / Sistemi operativi & mobile / Linux / Magic SysRq key in Linux
Mattepuffo

Magic SysRq key in Linux

Magic SysRq key in Linux

Qualche giorno fa ho scoperto le magic SysRq key, combinazioni di tasti in Linux, che operano a basso livello.

Sono combinazioni che vengono recepite direttamente dal Kernel, e sono delle vere e propire System Request (da cui SysReq).

Molto spesso sono usate per uscire dai freeze / blocchi di sistema, che non sono in grado di recepire i normali input da tastiera e mouse.

Possono, quindi, essere comodi in molte situazioni.

In sostanza, consistono in una combinazione così fatta: ALT + SYSRQ + KEY.

Inoltre, partono sempre dal layout QWERTY.

Questa la tabella con le combinazioni (fonte Wikipedia):

ActionQWERTYDvorakAZERTYColemak
Set the console log level, which controls the types of kernel messages that are output to the console 0 through 9 0 through 9 0 through 9
(without using shift)
0 through 9
Immediately reboot the system, without unmounting or syncing filesystems b x b b
Perform a system crash. A crashdump will be taken if it is configured. c j c c
Display all currently held Locks (CONFIG_LOCKDEP kernel option is required) d e d s
Send the SIGTERM signal to all processes except init (PID 1) e . e f
Call oom_kill, which kills a process to alleviate an OOM condition f u f t
When using Kernel Mode Setting, provides emergency support for switching back to the kernel's framebuffer console[3] If the in-kernel debugger 'kdb' is present, enter the debugger. g i g d
Output a terse help document to the console
Any key which is not bound to a command should also perform this action
h d h h
Send the SIGKILL signal to all processes except init i c i u
Forcibly "Just thaw it" – filesystems frozen by the FIFREEZE ioctl. j h j n
Kill all processes on the current virtual console (can kill X and svgalib programs, see below)
This was originally designed to imitate a secure attention key
k t k e
Shows a stack backtrace for all active CPUs. l n l i
Output current memory information to the console m m , m
Reset the nice level of all high-priority and real-time tasks n b n k
Shut off the system o r o y
Output the current registers and flags to the console p l p ;
Display all active high-resolution timers and clock sources. q ' a q
Switch the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode r p r p
Sync all mounted filesystems s o s r
Output a list of current tasks and their information to the console t y t g
Remount all mounted filesystems in read-only mode u g u l
Forcefully restores framebuffer console, except for ARM processors, where this key causes ETM buffer dump v k v v
Display list of blocked (D state) tasks w , z w
Used by xmon interface on PPC/PowerPC platforms. x q x x
Show global CPU registers (SPARC-64 specific) y f y j
Dump the ftrace buffer z ; w z

Facendo un esempio, vediamo come riavviare il pc:

  • premete ALT + SYSREQ (il tasto del Print Screen)
  • mentre tenete premuto, scrivete REISUB

Il computer dovrebbe riavviarsi.

REISUB sta per:

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),
reBoot.

Quasi divertente.

Ultima cosa, ovviamente ci sono delle situazione in cui comunque non possono servire:

  • kernel panic
  • segmantation fault
  • errori hardware o software, anche senza kernel panic
  • in caso di combinazione con il comandi "c", in quanto provoca un kernel panic

Enjoy!