[sf-lug] /proc/sysrq-trigger ...

Rick Moen rick at linuxmafia.com
Sun Jan 1 17:22:54 PST 2017


Quoting Michael Paoli (Michael.Paoli at cal.berkeley.edu):

> Good to know!  :-)
> https://en.wikipedia.org/wiki/Magic_SysRq_key
> 
> Of course physical and console keyboard access needs be suitably secured,
> but that's part of the physical security anyway.

Not that use of /proc/sysrq-trigger is _always_ allowed (by any
root-privileged logged in user).  The values set in
/proc/sys/kernel/sysrq determine what local keyboard users are permitted
to do without needing to login.

To exercise the latter functions, ah, that's where the 'magic key'
aspect comes in, and you merely press ALT _and_ the SysRq key if any
(it's sometimes labelled Print Screen), _and_ the desired command key
such as 'b' for boot.

As https://kernel.org/doc/html/latest/admin-guide/sysrq.html points out,
some keyboards are funky about pressing many keys at once, so success
might require playing around, e.g., keep ALT held down and then press
first SysRq, release it, press the command key, release.  And on some
keyboards, there's other local variations like needing to use Fn, too.

The 'e' and 'i' commands (send SIGTERM or SIGKILL, respectively, to all
processes other than init) can be a lifesaver if you have a system going
into runaway load and are having a difficult time getting control -- but
are at the physical console.  You can then just restart normal services,
and you're back.  I just noticed the 'f' command, which calls out the
OOM killer; might be handy, too.

And I hadn't noticed the 'w' = 'Dumps tasks that are in uninterruptable
(blocked) state' command, but will try to remember it next time my
system is wedged waiting on a blocked thread in kernelspace.




More information about the sf-lug mailing list