16

I found from googling that each letter stands for these:

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),
reBoot.

So if what B does is reboot, what difference does this make against just holding down the power key.

And what's the significance of other letters (I don't understand the terms).

3
  • 12
    When the power button is held, none of the above happens, and that is the difference. Jun 17, 2017 at 14:36
  • But what do they do? If I go from REISU without pressing the B when it's not frozen, it doesn't seem to do anything.
    – prab4th
    Jun 17, 2017 at 14:37
  • 1
    en.wikipedia.org/wiki/Magic_SysRq_key
    – Rinzwind
    Jun 17, 2017 at 15:18

1 Answer 1

26

I'll try to explain those in an easily understandable way, but it might not necessarily be 100% complete or 100% correct.

  • R - switch the keyboard mode

    This is said to "Switch the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode" (from Wikipedia), but I don't really know if this would normally have any notable effect.

  • E - gracefully terminate all running programs

    This sends the SIGTERM signal to all processes except init and thereby asks them to gracefully terminate, giving them a chance to tidy up and free their resources, save data, etc...

  • I - forcibly kill all running programs

    This is similar to the E, but sends the SIGKILL signal to all processes except init, which kills them immediately and forcibly.

  • S - sync all disks and flush their caches

    All your disks normally have a write cache, a piece of RAM where the system caches data it wants to save on the device, to speed the access up. Syncing tells the system to flush these caches now and perform all remaining writes. That way you do not lose any data that has already been cached but not been written yet, and it protects from leaving the file system in an inconsistent state.

  • U - unmount all disks and remount them read-only

    This is again pretty unspectacular, it simply makes all mounted disks read-only to prevent any further (partial) writes.

  • B - reboot the system

    This reboots the system. However, it does not perform a clean shutdown, but instead a hard reset.

However...

On Ubuntu, these SysRqs are normally masked and partially disabled. Only syncing, remounting read-only and shutting down/rebooting are enabled.

This is controlled by the kernel interface file /proc/sys/kernel/sysrq, which holds the decimal representation of a bitmask of the allowed SysRq actions. The Ubuntu default is 176. See this answer for loads of additional explanations and material.

So actually you could also just Alt + SysRq + { S | U | B }.

3
  • 1
    also, if you change your system setting to shutdown when power button is pressed.a normal press(not hold down) will do a normal shutdown in most cases. pressing ctrl + alt + del will bring up the log off dialog, breaking minor hangups.
    – ravery
    Jun 17, 2017 at 16:01
  • 1
    But why are R E I disabled. If I followed the other answer and reenabled them, can it go wrong?
    – prab4th
    Jun 18, 2017 at 2:46
  • 1
    @prab4th If you check the answer I linked, they describe the reason for the bitmasking below the headline "Why does RESIUB(O) not work?" near the top of the post.
    – Byte Commander
    Jun 18, 2017 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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