8

This question already has an answer here:

The magic SysRq key does not work on my Ubuntu 16.04 desktop. I imagine it's now disabled by default. My attempts to enable it did not work, and the only thing Google finds is a 2007 forum post from when it was apparently enabled by default.

Can I enable it? If so, how?

[Added the following after the first answer:]

According to https://en.wikipedia.org/wiki/Magic_SysRq_key "In Ubuntu the combination of Alt+SysReq acts as "print screen" command." This is in fact the behaviour I observe on a non-hung system, even after doing sudo sysctl -w kernel.sysrq=1 I get some kind of screen capture on my desktop. Not what I want.

It's not practical to write to /proc/sysrq-trigger from a system that's basically hung, trying to get information to debug the problem.

marked as duplicate by wjandrea, user68186, Byte Commander, Ravexina, user364819 May 4 '17 at 20:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Looks like a dup to me too, or more correctly it looks like the answers also answer my question, which is not really the same - I'm not just interested in one specific non-working sysrq option. I'll try the suggestions there, and see whether they still work; it's possible that additional changes to Ubuntu have made them out of date. (The question dates to 2013.) – Arlie Stephens May 5 '17 at 3:48
12

To enable sysrq magic keys temporarily:

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

or # sysctl -w kernel.sysrq=1

This enables sysrq magic keys for the current user session. You can disable it again by exchanging 1 with 0 in the above commands. Or go back to the standard value of 176.

To enable these changes at boot time one has to create config file in the sysctl.d directory (e.g. /etc/sysctl.d/90-sysrq.conf) with this line:

kernel.sysrq=1

So setting /proc/sys/kernel/sysrq to 1 enables the sysrq magic keys, setting it to 0 disables it.

  • I tried that. Unfortunately this is ubuntu. Quoting wikipedia " In Ubuntu the combination of Alt+SysRequest acts as "print screen" command." And that's what I got – Arlie Stephens May 4 '17 at 14:56
  • Well, sorry about that. I'm using KDE Neon, which is based on Ubuntu 16.04, and it worked for me. – jarleih May 4 '17 at 18:58
  • 1
    Unity strikes again :-( – Arlie Stephens May 5 '17 at 3:42
  • 1
    @ArlieStephens no you can, just edit /etc/sysctl.d/10-magic-sysrq.conf to change at the value you wish. Read more carefully wikipedia ;-) – tmow May 4 '18 at 8:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.