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.
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:
So setting /proc/sys/kernel/sysrq to 1 enables the sysrq magic keys, setting it to 0 disables it.