Have you ever found your Ubuntu freezes? You move your mouse, press keyboard buttons but nothing happens? Well, the last thing we do to solve this problem is pressing the restart button, isn't it? As we all know, doing "hard reset" frequently will cause damages on hardware especially hard disk, correct me if I', wrong. So, is there any "proper" way to restart freezing Ubuntu? Yes, there is. We can use "Magic SysRq Key" to perform clean restart on freezing system. The Sysrq key is located near the Scroll Lock key on the keyboard and it's generally the same as Print Screen key.

To use this magic, you should check the value of "/proc/sys/kernel/sysrq" file by typing the following command:
  • cat /proc/sys/kernel/sysrq
If it prints "1" on the screen, you're ready to go. If not, please set it to "1" by typing the following command:
  • sudo echo "1" > /proc/sys/kernel/sysrq
Let's do the magic!
When your Ubuntu freezes, simply press and hold Alt + SysRq, while holding the Alt and SysRq keys down, type the following keys in order, pausing for several seconds in between each key:
  • reisub
What the magic does is:
r – Puts the keyboard into raw mode, taking control of it away from the X server.
e – Sends the terminate signal to all processes, asking them to end gracefully.
i – Sends the kill signal to all processes, forcing them to end immediately.
s – Flushes data from your cache to disk.
u – Remounts all file systems read-only.
b – Reboots your computer.

For further information about what commands are available, please click here.

via: HowToGeek