When Linux Hangs or Completely Freezes

04/06/2010 at 14:55 7 comments

When Windows hangs itself we all know what to do right? Were just reaching for the combination [Ctrl]+[Alt]+[Del] (Control Alt Delete). But if you try this in Linux nothing happens (in some distributions, like Ubuntu, you actually get the menu for shutting down your system, but this don’t work when your system hags or freezes).

So what to do?

There is 3 keyboard combinations every Linux user should remember (or write down). But before we begin I want you to understand some of the signs I use: If a symbol is surrounded by [ ] means that it is a button or key on your keyboard. + means that you have to hold the keys down at once. And > means that you have to click the buttons one by one, remember that you have to press each key for 2-3 seconds. Now that you have learned this we can move on to the commands:

Fist you have the combination [Ctrl]+[Alt]+[BackSpace] (backspace is the [←] over [Enter]) that restarts X or GDM (you will be logged out), and you can kind of call it Linux’s Control Alt Delete equivalent. This command gives your programs time to make emergency backups of unsaved files (for example if you writing on a document in Open Office) and it  prevents that you get a file system error during the crash.If you use Ubuntu or a distribution based on Ubuntu you will have to use [Alt]+[PrtSc]+[K] (PrtSc = Print Screen) instead, but you should note that some Ubuntu based distros (like Linux Mint) still use the universal [Ctrl]+[Alt]+[BackSpace]. (Note 14.11.2013: For newer versions of Ubuntu, and some of it’s derivatives, even this combination does not seemto work any more, to get it working again check out the update in the end of the post)

But what to do if this combination doesn’t work? Then you have to use something called Magic SysRq Keys. In short they are keys which allows you to perform various commands regardless of the system’s state, like in this case get the system to recover from a freeze. Note that these keys wont work if your system is in kernel panic. Like I said there are tree combinations that you will have to remember and since we have already learned one, there are two to go:

This command will get your freezed system to restart safely:
Hold [Alt]+[PrtSc] then type [R]>[S]>[E]>[I]>[U]>[B] (press each key for 2-3 seconds). In short the keys mean: 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 (restart).

This command will get your freezed system to shut down in a safe way:
Again hold [Alt]+[PrtSc] then type [R]>[S]>[E]>[I]>[U]>[O] (press each key for 2-3 seconds). These keys mean: unRaw, tErminate, kIll, Sync, Unmount , shutdOwn (does it really need an explanation?).

To learn more about Magic SysRq Keys visit: Wikipedia: Magic SysRq Key.

 


 

Update:

As Andy E points out in his comment; [Alt]+[PrtSc]+[K] does not seem to work in newer versions of Ubuntu and some of it’s derivatives.

To get it working again first type this into the terminal (if you prefer using a dedicated text manager and not the terminal, change nano into your preferred text editor, like for example gedit):
sudo nano /etc/sysctl.d/10-magic-sysrq.conf

You will now see this line of code in the end of the file:
kernel.sysrq = 176

Change this into:
kernel.sysrq = 180

Then save and reboot, and [Alt]+[PrtSc]+[K] will “magically” work again!

Advertisements

Entry filed under: Linux Mint, Other, Tutorials, Ubuntu. Tags: , .

How to get hardware information in Linux? How to re-enable Ctrl+Alt+BackSpace in Ubuntu

7 Comments Add your own

  • 1. A.Y. Siu  |  04/06/2010 at 19:10

    I thought Control-Alt-Backspace had been disabled in Ubuntu by default (you can manually re-enable it).

    Reply
    • 2. Chi  |  04/06/2010 at 20:53

      That’s right. But Alt-Printscreen+K does the same trick :)

      I’m thinking about making a new guide later on the different ways you can re-enable or switch the keys. But I decided not to include it in this guide as I thought it would be a little overwhelming for new Ubuntu users.

      Reply
  • […] In my last post I wrote about what to do when when Linux hangs or completely freezes. In the same post I mentioned that the key command [Ctrl]+[Alt]+[BackSpace] was switched to […]

    Reply
  • 4. 2010 in review « My L1NUX!  |  02/01/2011 at 19:00

    […] When Linux Hangs or Completely Freezes June 20103 comments 3 […]

    Reply
  • 5. Donmalardan Kurtulmak | ÖMER YILDIZ  |  29/09/2012 at 19:01

    […] Linux Donmaları Etiketler: bilgisayarın donmasının nedenleri, donma problemi, linux ctrl alt del benzeri, linux ctrl alt del eşdeğeri, linux donma problemi, linux donma problemlerini çözmek, Ubuntu'da donma problemini çözmek, ubuntuda donma problemi No Comments. « Neden Senden Daha İyi Bir Yaz… Cevabı iptal etmek için tıklayın. […]

    Reply
  • 6. Andy E  |  13/11/2013 at 23:26

    Old post, but since it got some pretty high google ranking, someone else may stumble on this post many moons after…

    So after reading all this, you might think that in some Ubuntu “remixes” this is simply not working or not implemented?

    WRONG!

    Took me a whole late Sunday morning to figure out, but I hope it will help someone else, too…
    I have Lubuntu Saucy (v13.10) and it was just DISABLED there!
    Either the one who made the basic configuration had a bad day so he could no longer understand bit masks, or it was disabled on purpose!
    However, since disabling the Magic SysRq keys will also leave YOU, the user, too little room to maneuver, you are highly recommended to turn this on!

    The bad setting was in /etc/sysctl.d/10-magic-sysrq.conf:
    kernel.sysrq = 176

    OMG! They’ve turned on everything important *BUT* the keyboard keys!
    So we need to OR bit 2 to it (LSB be 0), which will be a OIOO in binary. So the better value is:

    kernel.sysrq = 180

    Automagically, the Alt-PrtSc-K combination will work again!!

    Reply
    • 7. Chi  |  14/11/2013 at 07:13

      Thank you for your comment!
      I will add this to the post later when I have time.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Licensed Under:

Creative Commons LicenseExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Tux and GNU are published under the GNU General Public License.

Subscribe

Categories


%d bloggers like this: