If you’re a Linux user, you know that crashes and freezes are all too common. But what if you don’t have a working X server? In this article, we’ll show you how to recover from crashed or frozen X servers on Linux.

  1. Check the system logs: The first step is to check the system logs. This will tell you what went wrong and how to fix it. To do this, open the terminal and type “logcat”. You’ll see a list of all the messages that were sent and received during the past few minutes.
  2. Check your kernel: If your kernel is not up to date, you can update it by typing “upgrade”. This will install any new patches that have been released for your kernel.
  3. Try restarting your computer: Sometimes when something goes wrong, restarting your computer can help fix it. To do this, type “rmdir /etc/rc” and then “start” in the terminal. You should now be able to access your old files again without any problems!
  4. Try using another operating system: If none of the above work, then you may want to try using another operating system such as Windows or MacOSX.

The X server on Linux provides your graphical desktop. If it crashes, you’ll lose all unsaved work in graphical programs, but you can recover from the crash and restart the X server without restarting your computer.

X server crashes can be caused by bugs with graphics drivers — the proprietary AMD or NVIDIA graphics drivers, for example — hardware problems, or other software bugs.

Image Credit: Francois Schnell on Flickr

Ctrl+Alt+Backspace

The Ctrl+Alt+Backspace keyboard shortcut traditionally restarted the X server on Linux. However, after complaints — particularly from new Linux users that accidentally hit this key combination and lost all their work — this shortcut was disabled by default. To enable it on Ubuntu, Fedora, or any other distribution using a GNOME-based desktop, you can use the Keyboard Layout utility.

Click the Options button and enable the Control + Alt + Backspace check box under Key sequence to kill the X server.

After it’s enabled, you can press Ctrl+Alt+Backspace to immediately restart your X server. However, this shortcut is implemented by the X server and may not work if X hangs in some ways.

Switch Virtual Consoles

You can use the Ctrl+Alt+F1 keyboard shortcut (and other F-key keyboard shortcuts) to switch to a different virtual console from your X server. (Ctrl+Alt+F7 usually takes you back to X — the exact F key depends on your Linux distribution.)

Once you have, you can log into the virtual console and run the appropriate command to restart your X server. The command you’ll need depends on the display manager you’re using. On Ubuntu, which uses the LightDM display manager, you’d use the following command:

RELATED: How to Run GUI Applications in a Docker Container

SSH Into Computer

If you can’t kill the X server locally, you can kill it over the network. Assuming you have an SSH server set up and running on your Linux system, you can log in from another computer and run the appropriate command to restart the X server. Just sign in via SSH to access a remote console and use the appropriate command to restart your display manager — on Ubuntu, it’s the sudo service lightdm restart command above.

Use the Magic SysRq Key

We’ve covered using the magic SysRq key in the past — the SysRq is is generally the same as the Print Screen key. Assuming you want to kill the X server locally — not over the network — your system may not be responding to key presses, including the Ctrl+Alt+F1 keyboard shortcut. This can occur because the X server has taken control of the keyboard. To take control away from the X server, use the following key combination:

After you have, you can try pressing Ctrl+Alt+F1 to access a virtual console. You can also use the Alt+SysRq+k combination, which kills all programs on your current virtual console, including your X server.

If you want to restart your computer, you can also use the magic SysRq key to cleanly restart your system — see our full post on the magic SysRq key for more information.