Linux – How to check which SysRq functions are enabled

bashbitmapslinuxlinux-kernelsysrq

The file /proc/sys/kernel/sysrq contains a single number, such as:

  • 1 (enable all SysRq commands),
  • 0 (disable all),
  • or a base-10 positive integer which functions as a binary bitmask, enabling a subset of functions.

Could someone please tell me which SysRq functions are allowed/disallowed when the bitmask is set to 438?


$ cat /proc/sys/kernel/sysrq
438

Best Answer

These are the available SysRq functions:

0 - disable every SysRq function.
1 - enable every SysRq function.
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 signalling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks

438 = 2 + 4 + 16 + 32 + 128 + 256, so only the functions associated with those numbers are allowed. Read all about it in the documentation.

If you convert 438 to base 2 (110110110) it is even easier to see.

1     1     0    1    1    0   1   1   0
^256  ^128  ^64  ^32  ^16  ^8  ^4  ^2  ^1

Depending on your distribution, you may be able to tell if the kernel was compiled with CONFIG_MAGIC_SYSRQ using this command:

$ grep SYSRQ /boot/config-$(uname -r)

This works for me on Ubuntu.