How can I know what keys will invoke the magic SysRq key? Provided I am in front of a Linux machine which is not frozen (yet). I need something easier than trying all common combinations of magic SysRq key to discover if it's working.
-
Note that, at least for me, I have to **hold** the `Alt` key, release the `SysRq` (`PrintScreen`) key, and then press the 3rd key while still holding `Alt`, in order for it to work properly... – Andrew Mar 22 '23 at 21:30
1 Answers
The magic SysRq key itself is AltSysRq or AltPrint Screen on PCs, which is in turn combined with a third key (letter), indicating some specific action.
The short version is that, at a console, AltSysRqSpace will display the available shortcuts (thanks to Josip Rodin for pointing that out).
The magic SysRq key, if enabled, is controlled by /proc/sys/kernel/sysrq; you can determine if it's enabled and what functions are allowed by running
cat /proc/sys/kernel/sysrq
If this complains that there's no such file or directory, then magic SysRq isn't enabled at all. Otherwise it will show a number which determines the available functions:
- 0: disable SysRq completely
- 1: enable all functions
- any other value is a bitmask of allowed functions:
- 2: control console logging level
- 4: control keyboard
- 8: process debug dumping
- 16:
sync - 32: read-only remounts
- 64: process signalling
- 128: reboot/power-off
- 256: nicing of all RT tasks
If the system is operational as far as having a working root shell, you can also invoke a magic SysRq function by writing its letter to /proc/sysrq-trigger; e.g.
echo s > /proc/sysrq-trigger
will perform an emergency sync.
This is all detailed in the kernel documentation.
- 411,918
- 54
- 1,065
- 1,164
-
1This is a nice answer; however, what about non-standard keyboards that don't have either a 'SysRq' or 'Print Screen' key? What would happen if I were to unplug a keyboard that does have a SysRq key and plug in one that doesn't? Ref. new question I have asked [here](https://unix.stackexchange.com/q/682965/257802). – Time4Tea Dec 19 '21 at 00:06