All operating systems freeze sometimes, and Ubuntu is no exception. What should I do to regain control when...

  • just one program stops responding?
  • nothing at all responds to mouse clicks or key presses?
  • the mouse stops moving entirely?

In what order should I try various solutions before deciding to pull the power plug?

link|improve this question

80% accept rate
4  
hit it with a hammer – Paul Apr 24 '11 at 10:31
4  
throw it in the microwave for 30-60 seconds, on high. – TheX Jun 5 '11 at 20:50
feedback

14 Answers

up vote 27 down vote accepted

When a single program stops working:

In GNOME, when a program in a window stops responding, you can usually stop it by clicking the X-shaped close button at the top right of the window, or at the top left on newer Ubuntu versions with Unity. That will generally result in a dialog box saying that the program is not responding (but you already knew that) and presenting you with the option to kill the program or to continue to wait for it to respond.

Sometimes this does not work as expected. If you can't close a window by normal means, you can open a terminal (or use Alt + F2) and run xkill. Your mouse cursor will then turn into an X. Hover over the offending window and left-click to kill that process. Right clicking will cancel and return your mouse to normal.

When commands run from an xterm or console stop responding, they can sometimes be halted with Ctrl + C. Ctrl + Z will sometimes work when that fails. If neither of these works, open another terminal and run ps ax |grep foo where foo is the name of the unresponsive program. This should return a line of output that looks something like this:

$ ps ax |grep firefox
2222 ?        S      0:00 /bin/sh /usr/lib/firefox-3.6.9/firefox
2227 ?        S      0:00 /bin/sh /usr/lib/firefox-3.6.9/run-mozilla.sh /usr/lib/firefox/3.6.9/firefox-bin
2231 ?        Sl   514:36 /usr/lib/firefox-3.6.9/firefox-bin
24970 ?        Sl   173:30 /usr/lib/firefox-3.6.9/plugin-container /home/andyman/.mozilla/plugins/libflashplayer.so 2231 plugin true
30290 pts/2    S+     0:00 grep --color=auto firefox

The first field of each line of output is a number which represents the Process ID of the program matched by grep (you can safely ignore the last one, which represents grep itself). To halt the offending process, do: kill -9 bar where bar is the Process ID of the program. You might have to use your judgment as to which of the matches needs to be killed, or you could use top instead.

If you are running GNOME, of course, you don't have to fool with this crazy command-line stuff to get the job done- just go to SystemAdministrationSystem Monitor. Navigate to the Processes tab. Choose the process you want to halt (Hm, could it be the one using 90% CPU?) and right-click it. Since the process is already stopped, (that's the problem, right?) choose End Process or Kill Process from the resulting menu.

I'm not sure what the difference is between the two. In my experience they both get the job done. Perhaps someone can chime in with that information?

When the mouse stops working:

If the keyboard still works, hit Alt + F2 and run gnome-terminal. From there you can troubleshoot things. I'm not going to get into mouse troubleshooting here, as I haven't researched it. If you just want to try restarting the GUI, run sudo service gdm restart. This should bring down the GUI, which will then attempt to respawn, bringing you back to the login screen.

When everything, keys and mouse and all, stop working:

First try the Magic SysReq method outlined in Phoenix' answer. If that doesn't work, hit the Reset button on the computer case. If even that doesn't work, you'll just have to power-cycle the machine. May you never reach this point.

link|improve this answer
I've recently discovered that, rather than the "ps $options | grep $process_name" referenced above, one can just enter "pgrep $process_name" to achieve approximately the same result (for certain values of $options). – koanhead Jun 4 '11 at 13:45
feedback

If it locks up completely, you can REISUB it, which is a safer alternative to just cold rebooting the computer.

REISUB by:

While holding Alt and the SysReq(Print Screen) keys, type R E I S U B.

R:  Switch to XLATE mode
E:  Send Terminate signal to all processes except for init
I:  Send Kill signal to all processes except for init
S:  Sync all mounted filesystems
U:  Remount filesystems as read-only
B:  Reboot

REISUB is BUSIER backwards, as in "The System is busier than it should be", if you need to remember it.

More info on all the Alt SysReq functions here: http://en.wikipedia.org/wiki/Magic_SysRq_key

link|improve this answer
interesting ... it will be so much better if it was not so hard to do this ... REISUB ... REISUB ... REISUB ... ok ... :) – Jiew Meng Apr 24 '11 at 7:42
8  
In the event you're forced to do this, do it slowly. Let a few seconds pass in between each keypress so that the commands you're invoking have a chance to finish before you go to the next one. – Amazed Apr 24 '11 at 8:22
4  
In case you like mnemonics: Raising Elephants Is So Utterly Boring, or Reboot Event If System Utterly Broken. I've also seen it as RSEIUB (Raising Skinny Elephants is Utterly Boring). – Siegfried Gevatter Apr 26 '11 at 14:19
feedback

You can make the shortcut Ctrl+Alt+Delete open the System Monitor, with which you can kill any unresponsive applications.

  1. Open up System ➜ Preferences ➜ Keyboard Shortcuts and click Add.
    In the Command field, enter gnome-system-monitor. Name the shortcut whatever you want.

    enter image description here

  2. Click Apply and then click where it says Disabled. Now hit the keys Ctrl+Alt+Delete

    enter image description here

  3. Close Keyboard Shortcuts and try out the shortcut:

    enter image description here

link|improve this answer
feedback

When everything stops working, first try Ctrl + Alt + F1 to go to a terminal, where you can likely kill X or other problem processes.

If even that doesn't work, try using holding down Alt + SysReq while pressing (slowly, with a few seconds between each) R E I S U B.

This puts the keyboard in raw mode, ends tasks in various states, syncs the disks, etc, and finally reboots the machine. You will get much better results doing this than just pulling the plug. Of course, if this fails, you're pretty much left with pulling the plug.

link|improve this answer
4  
A way to remember "REISUB" is "Reboot Even If System Utterly Broken". – Matthew Crumley Sep 20 '10 at 3:15
2  
or "Raising Elephants Is So Utterly Boring" :P – Axel Sep 20 '10 at 12:09
1  
I remember it using "BUSIER" Backwards – Nerdfest Sep 20 '10 at 16:33
feedback

What I do is opening a terminal with eg. Ctrl + Alt + F2

Login and use the terminal to kill the process that is lagging

ps -e | grep <procesname>

This shows the processID of the process with that name

(sudo) kill <processID>

This shuts down the process safely, in case that doesn't work use

(sudo) kill -9 <processID>

Use the man pages for more information about these commands.

You can get back to the graphical user interface with Ctrl + Alt + F7

link|improve this answer
8  
ps and grep PROCESS can be replaced by a pgrep PROCESS call, and your whole thing can simply be replaced by pkill PROCESS or a killall PROCESS. – queueoverflow Apr 24 '11 at 22:01
thanks, I didn't know that. Seems to be UNIX commands too, nice – Chielus Apr 25 '11 at 8:32
feedback

Also, sometimes it's simply the X-Server which hangs - a case I've most often found when you're using Compiz.

If this is the case you can kill X, which will restart and drop you back at the log-in screen.

The default sequence is Ctrl + Alt + Backspace

Although this is turned off by default (presumably new-users were accidentally hitting it) and can be turned back on like this:

  1. SystemKeyboard (i.e. the Keyboard Preferences Dialogue)
  2. Layouts tab
  3. Click the Options button
  4. At the Key Sequence to kill the X server point check Control + Alt + Backspace.
link|improve this answer
feedback

My first favourite when total freeze occured - Alt + SysRq + K.

That combo kills X, and returns me to GDM login screen. If that doesn't work, try Alt + SysRq + R E I S U B.

link|improve this answer
feedback

If you're getting a lot of freezes, there might be something wrong with your hardware. I used to get hard lockups every 48 hours due to some less than optimal RAM. Memtest86+ showed the fault after 40 minutes of testing. Swapped the RAM out for some more (under warranty) and I'm now at 32 days, 1 hour of uptime.

Ubuntu doesn't tend to leak its guts all over your memory like Windows can over time. Even if one application or a poor X video driver does, you can restart gdm very simply and just keep going and going and going. I've actually been through three beta versions of the nvidia driver in this one boot :)

Anyway... While knowing how to restart softly is a very handy thing, finding, reporting and fixing the system should be your next priority. If it's an always-on system, you should easily be able to make it between kernel updates* without needing a restart.

*You should restart when you get kernel updates as they'll be security fixes that won't be applied until you reboot into the newer kernel.

link|improve this answer
feedback

DoR and Phoenix has answered this well. To make this page more complete I would add:

If it is only X that is "broken", than you can use kernel to kill it:

Sys Rq + Alt + K

(or for laptops:

Fn + Sys Rq + Ctrl + Alt + K)

link|improve this answer
FWIW it depends on the laptop -- on my ThinkPad Alt+SysRq doesn't require Fn nor Ctrl. – Marius Gedminas May 10 '11 at 12:46
Thank you for adding it. – desgua May 10 '11 at 16:32
feedback

If you ever use the magic SysRq key as suggested in the first answer, just try getting the keyboard to work first with Alt + SysRq + R; then try Ctrl + Alt + F1 again.

It may work and you may save yourself a reboot. Only if it doesn't work you should try the whole REISUB sequence.

link|improve this answer
feedback

I thinks there is no such thing as a perfect distro, even in Windows they have this screen of death.

  • Open another terminal Ctrl + Alt + F2.

  • Login with your username and password.

  • Issue this command:

    sudo /etc/init.d/gdm restart
    

    This restarts or logs you out of your current session but it will not reboot.

Then Ctrl + Alt + F7 go get back to your graphical interface.

link|improve this answer
feedback

The simplest solution is to add the "Force Quit" applet to your Gnome top panel and when a program doesn't respond, click on the force quit and then on the application.

I am surprised with so many answers, this isn't mentioned. Of course, you can always do a ps -A and pipe that to grep for your program name. And kill -9 that. I prefer simplicity.

link|improve this answer
feedback

You can always do Alt + F2 and write killall <program> or xkill and click on the window you want smashed!

link|improve this answer
feedback

if possible, try to open an ssh shell from another computer. this is an option If you knew in advance that the computer might hang soon, open the connection first before you perform that task.

I do this sometimes when I know vmware runs crazy and the GUI of ubuntu (the vmware host) becomes unresponsive. I can do a suspend from the ssh shell, it might take a while until it gets thru, and after a while the computer is idle again.

link|improve this answer
A better idea would going to an other TTY (non-GUI) by pressing Ctrl + Alt + F[1-6] where F[1-6] is F1, F2, ..., F6. This is especially helpful if your network connection is heavily used. (to switch back, use Ctrl + Alt + F7. Replace F7 by F8 if it didn't work. – Lekensteyn Apr 30 '11 at 8:14
Sure, however I always tend to forget these key combinations. And when I know I have to carry out some tasks/experiments where the computer might hang, it's always handy to have access to a second computer available right next to the hanging one. – knb May 1 '11 at 13:03
For some experiments, a virtual machine in VirtualBox is recommended. In that way, you can easily revert the machines state. – Lekensteyn May 1 '11 at 13:24
feedback

Your Answer

 
or
required, but never shown

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