Wednesday, December 12, 2012

Ways To Recover From Frozen Or Crashed X Server on Linux

                                                         Fig1: Frozen server on Linux
We often get this kind of a problem, when we work on a server and the server gets freeze. It occurs when either a single computer program or the whole system ceases to respond to inputs. The most commonly seen scenario is a workstation with a graphical user interface,all windows belonging to the frozen program become static and though the mouse cursor still moves on the screen,but neither typing on the keyboard nor clicking the mouse gives any effect in the program's windows. X server crashes can be caused by bugs for example hardware problem or some software bugs. This freezing of a server can cause to lose all unsaved work in the graphical program windows. In that case to recover we always used to reboot the machine. But we had some alternatives ways on Linux to recover from the crash and restart the X server without restarting the computer.
The ways are as follows:

Ctrl + Alt + Backspace:

This combination of keys Ctrl + Alt +Backspace keyboard shortcut restarted the X server on Linux. However this combination is disabled by default in Linux because new users can hit this combination accidentally and can lose their work. To enable it on any distribution that is using GNOME-based desktop, we can use the Keyboard Layout utility.

                                                  Fig2: This is the screen of Dash   

Then, we can get these options under the Keyboard Layout utility.

                             Fig3: This is the screen appears after clicking Keyboard Layout

Click the options and enable the Control +Alt+ Backspace under the Key sequence to kill the X server.

After it's enabled, we can press Ctrl + Alt + Backspace to quickly restart the X server.

Switch Virtual consoles:

 We can use the Ctrl+Alt+F1 keyboard shortcut to switch to a different virtual console from the X server. And by using Ctrl+Alt+F7 can take you back to X server window where we were before. Once we have done with this, we can log into the virtual console and run the command that will restart the X server. The command that we need depends on the display manager that we're using.On Ubuntu, that uses the LightDM display manager, the following command is used:

    sudo  service lightdm restart

Using the Magic SysRq Key:

 The SysRq is generally the same as the Print Screen key. If we want to kill the X server locally, it might be that the system may not respond to the key presses, including the Ctrl+Alt+F1 keyboard shortcut. This can occur when the X server has taken the control over the keyboard. So, to take the control away from the X server, following combination can be used:

After you had done with this, you can try by pressing Ctrl+Alt+F1 to access a virtual console. We can also use Alt+SysRq+k combination, which kills all the programs running on the current virtual console including the X server.
You can also know detail information about the Magic SysRq Key on

SSH into Computer:

If you can’t kill the X server locally, you can kill it over the network. Assuming that you had SSH set up and running on your Linux system, you can log in from another computer and run the command that will restart the X server. Just sign in through SSH to access a remote console and use the command to restart your display manager accordingly. On Ubuntu, it’s the same as above that we had seen

        sudo  service lightdm restart

These are some of the alternatives that can be helpful when we got stuck to the frozen server and can get recover quickly without any rebooting or loosing of work.