What do do when Linux gui freezes

Solution 1:

One solution that I use form time to time when things get crazy is to switch to another console, using Ctrl-AltFx (F1-F6). Ctrl-Alt-F7 should take you back to the graphic screen. This should take you to a text login prompt.

If this does not work and you installed OpenSSH (sudo apt-get install openssh), you can ssh to your box remotely and get the same prompt.

You can then login as yourself, su to root, and see which application are currently running. This needs a little experience with some of the commands such as ps, kill, grep and less.

ps - ef | more

The above command will show you all processes currently running, and you have a "More..." prompt to take tie to read the output.

kill -9 ####

The above command will kill the process numbered ####.

ps -ef | grep ora | more

The above command will show you all processes with the letters "ora", such as Oracle programs. Will also let you see "More..." prompts.

You need to be careful when doing this. you may kill the entire system. My way of doing this is to look at the processes at the bottom of the list, which will have the latest processes started. Those are more likely the ones that froze the system, and killing those can more likely unfreeze the X environment without actually restating the whole system. In the process list, you will see two numbers. The first (leftmost) is the process number itself, and the one next to it is the process that launched it.

In the commands of the processes, you may be able to recognize the name of the latest programs you started, and kill those first.

At best, you can find and kill the offending program. At worst, you will freeze the system until you power cycle it. Proceed carefully............................

But you have a chance to copy critical files, perform other operations, etc.

Solution 2:

Like private_meta said, you'll probably want to restart X. This stops all GUI processes running, including all processes started from a gui terminal window.

The Ctrl+Alt+Backspace doesn't work on Ubuntu, they disabled this shortcut. You can enable it (don't remember exactly how, but it should be easy to google) or just use the proper combination, which is SysRq + K. SysRq may be a secondary function of another key on some layouts, so for example on a qwertz keyboard you are actually pressing AltGr + Print + K.

For other uses of the SysRq key combinations, read this Wikipedia article. It gives you more controll over the system than you'll probably need.