Rescuing A Hung GNU/Linux System

My GNU/Linux box just hanged. It is actually my own fault as I tried to empty the swap partition (with sudo swapoff -a; sudo swapon -a) without realizing that I don't have enough RAM space! Anyway, if you have a hung X session, what can you do?

Note: I assume that you are using QWERTY keyboard. If not, convert the key sequence as described here [wikipedia.org].

  • Kill the X session. Do this with Ctrl-Alt-Backspace. This should bring you back to the X login window. You can't do this in Ubuntu anymore. If so, kill the processes in the current virtual console as described below.
  • Kill all processes on the current virtual console. Do this with Alt-SysRq-K if you fail to kill the X session as described above. This should bring you back to the X login window.
  • Reboot the system safely. Do this if you fail to reboot the system in the normal ways. To reboot a GNU/Linux system safely, use the following key combinations in sequence:
    1. Alt-SysRq-R. Take the control of the keyboard.
    2. Alt-SysRq-E. Send SIGTERM to all processes.
    3. Alt-SysRq-I. Send SIGKILL to all processes.
    4. Alt-SysRq-S. Sync all mounted filesystems.
    5. Alt-SysRq-U. Remount all filesystems in read-only mode.
    6. Alt-SysRq-B. Reboot!
  • You can memorize this magic sequence with "Reboot Even If System Utterly Broken", or simply "BUSIER" backwards.

  • Press the 'magical' reset button! Frankly speaking, you almost never need to do this with Linux. (Although you may do this very often in some other operating systems.)