What does the SysRq key do?

28

2

On my keyboard, the key the functions as the Print Screen key when the F-lock is on has "SysRq" below it (presumably to be used when F-lock is off). What is it and what does it do?

RCIX

Posted 2009-07-16T02:44:19.920

Reputation: 5 415

4Any chance of choosing a correct answer? The question is almost 4 1/2 years old and answer pending for over 2 years. Thanks – Dominic Zukiewicz – 2014-10-09T07:55:01.890

Post-bounty note: The bounty was given to a 5-year old answer that was relatively underappreciated until recently. Now that a newer answer has been posted, that may be another good choice for accepting an answer. – None – 2019-12-26T10:37:28.020

2

There is a Wikipedia page for the System Request key.

– nik – 2009-07-16T02:46:52.973

Answers

18

SysRq was introduced on IBM PC keyboards as a way to have a cross-platform way to initiate a low-level event. When typing the keys, they get put into a buffer and flushed periodically. If your machine locks up, the keyboard does not work.

The SysRq key was basically to force a command to be sent to the computer, bypassing the buffer, to trigger a low level call; usually a RESET event.

However, each OS ignores this key now, and uses a preferred combination keystroke to initiate some sort of 'Task Manager' like interface enabling the OS to remain running, rather than a reset the computer.

Its much more common to run applications from the host OS, rather than from the BIOS. It wasn't like that in the 1980's :-)

Dominic Zukiewicz

Posted 2009-07-16T02:44:19.920

Reputation: 389

5

The SysRq key was invented in the early days of personal computers, when low-level Terminate and Stay Resident (TSR) programs could directly access and modify the keyboard buffer. This key bypassed the buffer and gave direct access to the MSDOS operating system.

Today this key is ignored by the BIOS and by Windows. It has been relegated to the Prt Scn key and is activated by Alt+Prt Scn. Some manufactures, for example Lenovo, no longer mark it on the keyboard, although it can still be accessed as above.

Some older debuggers used this key as the break-execution key, but this no longer exists.

Under Linux the key is still present, requiring that the CONFIG_MAGIC_SYSRQ kernel option was specified when the kernel was built. This can be checked by entering the command:

$ cat /proc/sys/kernel/sysrq
176

The command will most often return the value of 176, where each bit stands for one function:

0 - disable sysrq completely
1 - enable all functions of sysrq
2 - enable control of console logging level
4 - enable control of keyboard (SAK, unraw)
8 - enable debugging dumps of processes etc.
16 - enable sync command
32 - enable remount read-only
64 - enable signaling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks

A value of 0 disables all SysRq functions and a value of 1 enables all of them. The running value can be changed for example by the command:

echo "1" > /proc/sys/kernel/sysrq

Of all command key sequences, REISUB is the most famous, when holding the Alt+Prt Scn keys and pressing the following keys in sequence:

  • r : switches the keyboard from raw to XLATE mode
  • e : sends a SIGTERM signal to all processes, to close gracefully if possible
  • i : sends a SIGKILL signal to terminate processes which didn't respond
  • s : sync all mounted filesystems and flush all cached disk changes
  • u : remount all filesystems in read-only
  • b : system reboot.

References:

harrymc

Posted 2009-07-16T02:44:19.920

Reputation: 306 093

3

It is a programmable key which can be made to do a variety of things, depends.

I remember it having some uses on old ibm terminals, and some DOS programs used it for a form of soft resetting.

Rook

Posted 2009-07-16T02:44:19.920

Reputation: 21 622

2

On linux it still serves a very useful function:

https://en.wikipedia.org/wiki/Magic_SysRq_key

pgoetz

Posted 2009-07-16T02:44:19.920

Reputation: 141