The Definitive Guide to Getting Your Linux Desktop Back

Despite every ounce of intuition in your body screaming “No, no, no, no, don’t do it!”, you did it anyway. You just had to click that button. The one that should have been big and red and marked SELF DESTRUCT. And now your computer’s buggered. Isn’t it lovely to have intuition give you it’s best gut wrenching “I told you so!” gloat.

Welcome to the definitive guide to getting your Linux desktop back.

Broken Desktop
What to do when Linux won’t let you log in..?

Whether you have a black screen, a flashing screen, just can’t get past the login screen or you’re stuck in the command-line, you are about to learn a few tricks that will help you get your Linux desktop back to full working order. You will even learn how to open multiple virtual desktops.

Written for Ubuntu, these Linux desktop recovery tricks are laid out in an easy to follow guide that presents recovery solutions in least destructive to this-could-break-everything-or-make-everything-better order.

Whether you’re suffering from an I-know-what-I’ve-done-how-do-I-fix-it problem or a my-Linux-desktop-is-broken-and-I-haven’t-a-clue-what’s-wrong-with-it-but-I-blame-the-kids kinda problem, there is a solution here for you.

A little knowledge goes a long way

Linux is primarily a non graphical operating system.The graphical environment you know and love is an optional component formed by a window system, a window manager and a desktop manager.

When a Linux graphical desktop environment breaks, it is usually caused by a bad setting in any of the following layers of the graphical environment:

  • the window system
  • the window manager
  • the desktop manager
  • the display manager

As well as bad configuration files, I have known for an update or the removal of a software package to also uninstall one or more of those layers or to remove software dependencies required by those layers.

My preferred Linux distro is Kubuntu which is built around Ubuntu. Ubuntu uses the X Window System as the basis of its graphical desktop environment. The X Window System, also called X, makes it possible for graphical programs to communicate with the hardware Linux runs on.

Sitting on top of X is a window manager. There are many different window managers. To name a few of them, we have Kwin, Metacity, Compiz and Emerald. The window manager decorates windows, provides menus and makes interaction with windows possible. Different Window Managers make the various flavors of Ubuntu look and feel different.

The desktop manager usually provides icons, windows, toolbars, folders, wallpapers and desktop widgets.

The login screen that usually greets you when your operating system loads is called the display manager or greeter. The display manager starts the X Server before the login screen shows and initializes the desktop session which loads when you login to your computer. If you were to stop the display manger from the command-line it would also stop your desktop session. Display managers are optional.

A good explanation of the roles played by the window system, window manager and desktop manager is given at

We have Linux display errors Q&A forum here.

Getting the Desktop Back

I have not yet lost documents and files while using any of these methods to restore a Linux desktop from its broken state. However, it is always a good idea to be cautious. You should be able to use a Live Disc to gain access to files stored on the hard drive of a broken operating system. A guide to accessing files with a Live Disc is here.

I recommend you move through these desktop recovery solutions in order from one to eight. If you know what you did to cause your desktop to break then you might be able to guess the solution that will work best for you: what the hell, go with your hunch, I would.

The Preliminaries

First, print this guide or load it in your mobile browser so you have complete access to it.

If you have the command-line browser Lynx installed or if you can install Lynx and you have an Internet connection from your desktopless computer then you can open a second terminal environment with Ctrl+Alt+F2 or F3 (see this guide) and open this desktop recovery guide  in Lynx with the command:


Second, if you need to know the basic steps of how to find your way around the Linux command line then need to look at this navigation guide.

Third, access the Linux shell using Ctrl+Alt+F1. Follow this command line access guide if you cannot access the shell environment.

Fourth, stop the Linux display manager if it is running. Use these instructions to stop and start the Linux display manager. For example, sudo stop lightdm or sudo stop kdm.

Fifth, when the Xorg script begins loading the display it writes a log file to /var/log/Xorg.#.log (where # represents the display number. This is typically 0). Check the log file for error and warning messages with the following command:

egrep '\(EE\)|\(WW\)' /var/log/Xorg.1* | less

Most warnings can be ignored but they do hint at possible solutions. Here’s an example of an ignorable warning (explanation here):

fglrx: No matching Device section for instance (BusID PCI:0@0:17:0) found

A common and easily fixed error relates to missing font directories. It can usually be ignored but if you wish to fix it you can install additional X Server fonts with

sudo apt-get install xfonts-*

An FAQ of X Server error messages is at the Xorg Wiki.

Sixth, the config files .xinitrc, .xserverrc and .xsession are sometimes placed into a user’s home directory. They can be useful when deliberately placed there by a user to override global settings of the X Window Server but when these files get corrupted they can prevent X from initializing properly. Run the next command to rename these files to prevent them from being used:

sudo cp ~/.xinitrc ~/.xinitrc.bckxyz; sudo cp ~/.xserverrc ~/.xserverrc.bckxyz; sudo cp ~/.xsession ~/.xsession.bckxyz

Do not recreate these files just yet. Instructions for (re)creating xinitrc, xserverrc and xsession scripts are here for when you need them.

Seventh, these preliminary steps might have fixed your computer so restart your computer with

sudo reboot


sudo shutdown -r now

Just a tip: if your computer is being stubborn about being switched off, hold the power button in for 30 seconds.

If your desktop still refuses to load, try the following solutions.

The definitive guide to getting the Linux desktop back

Starting a desktop session as a new user is an excellent way to determine whether a desktop loading error is due to a misconfiguration. If you can log into a desktop environment as a different user then the issue relates to something specific in the desktop configuration of the user whose desktop will not load.

Testing whether you can log in as a different user may help you decide which of the following solutions will work best. If you can successfully log in to a desktop environment as a different user you might find some of these solutions easier to employ.

Solution One: clean var/tmp/

Drop to a shell at the login prompt or use a LiveDisc to get access to the root file system. Browse to /var/tmp/ and check for big files. Delete those big files.

The directory at /var/tmp/ sometimes gets overfilled with huge error logs. I recently found I could not log into Kubuntu because of several huge 16GB dmesg monster zip files. Those zip files would have gotten bigger except they had filled up my OS drive so could grow no more.

Check your OS partition is not full. If it is, remove a few files.

Solution Two: update everything

A botched software update might have caused you to lose your desktop. A bug fix might have been released so update your software package list then upgrade your system. Drop to shell then type:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Next install Aptitude:

sudo apt-get build-dep aptitude
sudo apt-get install aptitude

Then install missing package dependencies and do a full upgrade with

sudo aptitude build-dep
sudo aptitude full-upgrade

Restart your computer by typing sudo reboot to check whether the problem has gone away.

Solution Three: reconfigure the window system

A messed up xorg configuration can prevent the X Window System loading properly so reconfigure it with

sudo apt-get build-dep xorg
sudo dpkg-reconfigure xserver-xorg

Restart your computer by typing sudo reboot.

Solution Four: reconfigure the window manager

Different desktop managers tend to use different window managers. Table 1, below, shows commonly used combinations of desktop manager, window manager and display manager software. Refer to table 1 to learn which display manager your system uses then stop it before reconfiguring your window manager with

sudo stop [display manager]
sudo dpkg-reconfigure [window manager]

For example, if you use Kubuntu, your OS will use the KDE desktop environment and the “kde-workspace” window manager (also known as Kwin). You would reconfigure it with

sudo stop kdm
sudo dpkg-reconfigure kde-workspace

Restart your display manager as shown in Table 1 of Starting (and Stopping) a New Desktop. For example, “sudo start [display manager].

Press Ctrl+Alt+F7 to try to access the graphical environment. If the terminal display at Ctrl+Alt+F7 stays blank, try F8 through F12 instead of F7.

Solution Five: reconfigure the display manager

Reconfigure the display manager or, if you have more than one display manager installed, check which one is set as the default manager then either reconfigure it or set a new default display manager.

First discover the default display manager:

cat /etc/X11/default-display-manager

Which will show something like this


The string after the third forward slash is the name of the default display manager. In this case, the display manager is “kdm”.

Stop the display manager with

sudo stop [display manager]

Next, reconfigure the display manager with

sudo dpkg-reconfigure [display manager]

A list of installed display managers is shown during reconfiguration. Make a note of them because you might need to re-install them all.

Choose a display manager to use at login then restart the display manager with

sudo start [display manager]

Re-access your GUI with Ctrl+Alt+F7.

Using kdm as an example, I would reconfigure my display manager with

sudo stop kdm
sudo dpkg-reconfigure kdm
sudo start kdm

If your desktop still fails to load after a reboot and more than one display manager is installed on your system, try another display manager. Set the OS to use the original display manager if no other display manager option works.

Solution Six: reinstall the window system, window manager and display manager

Where reconfiguration fails, re-installation might succeed.

The Window System is easiest to reinstall:

sudo apt-get build-dep xorg xfonts-utils
sudo aptitude reinstall xorg xfonts-*

The Window Manager is easy to reinstall if you know which window manager your system uses. Refer to table 1 to discover which window manager you might be using.

sudo apt-get build-dep [window manager]
sudo aptitude reinstall [window manager]

Replace [window manager] with one of the window managers shown in table 1.

Table 1: Common Window & Display Manager Combinations
Example Distro Desktop Environment Window Manager Display Manager
Ubuntu GNOME metacity gdm
Kubuntu KDE kde-workspace kdm
Kubuntu GNOME & KDE compiz kdm or gdm
Ubuntu Unity unity gdm
Lubuntu LXDE lxde ldm
Xubuntu XFCE xfce4 lxdm

For example, to reinstall the GNOME window manager, Metacity, use,

sudo apt-get build-dep metacity
sudo aptitude reinstall metacity

Most display managers can be used in combination with any window manager. For example, you can use GDM with KDE or KDM with GNOME. Refer to table 2 to find out which display manager your computer most likely uses then re-install it with:

sudo apt-get build-dep [display manager]
sudo aptitude reinstall [display manager]

For example, if you use KDE then your display manager will likely be KDM so install it with

sudo apt-get build-dep kdm
sudo aptitude reinstall kdm

A more brutal option is to purge the installed window manager and display manager packages from your computer. Purging removes all configuration files so any settings used for the desktop environment would be lost if you purged the system. If the other solutions fail to work then purging might be your only option. Try all other options first and come back to this section if they fail to bring your desktop back to life.

Only purge packages if you have an Internet connection or another means of downloading and re-installing purged packages.

Firstly, make sure any packages to be installed are downloaded afresh by clearing the cache of downloaded packages with

sudo apt-get cache-clean

Secondly, purge packages with the command

sudo apt-get purge [package-name]

Thirdly, reinstall the purged package with

sudo aptitude install [package name]

Finally, restart your computer.

For example, to purge and reinstall Unity:

sudo apt-get purge unity
sudo apt-get build-dep unity
sudo aptitude install unity

Solution Seven: switch to a basic graphics driver

Many graphics problems, blank screens and desktop loading issues are caused by misconfigured, corrupt or buggy graphics drivers. Propriety graphics drivers such as those used by ATI and NVIDIA graphics cards can be especially troublesome.

The easiest way to fix a bad VGA driver is to disable the driver and to use a generic driver such as MESA or VESA. This can be done by recreating the xorg.conf file:

  1. Drop to a shell
  2. Stop your display manager as shown in table 1 of this guide e.g “sudo stop kdm” or “sudo stop gdm”
  3. Delete your xorg.conf file
    sudo rm /etc/X11/xorg.conf
  4. Paying attention to the capital X, recreate a default xorg.conf file with
    sudo Xorg -configure
  5. The new xorg.conf file will be in your home directory. Move it to /etc/X11/ with
    sudo mv ~/ /etc/X11/xorg.conf
  6. Restart your display manager with “sudo start kdm” or “sudo start gdm” etc…
  7. Access the graphical environment with Ctrl+Alt+F7

xorg.conf stores configuration settings for your display driver. Running the Xorg -configure command causes Xorg to create an xorg.conf file that specifies the use of a generic graphics driver.

Once a generic driver is in use you should be able to load your desktop and install the propriety driver again. Hope that doing so fixes the original issue; if it does not you will need to reset to the generic MESA or VESA driver. If creating a new xorg.conf file does not fix your desktop then you will at least know that your desktop loading error is not necessarily related to your graphics driver.

Solution Eight: reinstall your desktop manager or install a new one

This could take some time because your computer might need to download a lot of software packages.

To reinstall your desktop manager, choose the appropriate installation command for your distro from this list:


sudo apt-get build-dep ubuntu-desktop
sudo aptitude reinstall ubuntu-desktop


sudo apt-get build-dep kubuntu-desktop
sudo aptitude reinstall kubuntu-desktop


sudo apt-get build-dep lubuntu-desktop
sudo aptitude reinstall lubuntu-desktop


sudo apt-get build-dep xubuntu-desktop
sudo aptitude reinstall xubuntu-desktop


sudo apt-get build-dep edubuntu-desktop
sudo aptitude reinstall edubuntu-desktop

The good news here is that you can install multiple desktop environments into Linux and Linux will love you for it.

Installing an alternative desktop environment will provide you with a desktop to use until your regular one is fixed. To install a new desktop environment, use the above commands but replace sudo aptitude reinstall with apt-get install.

For example, if you use Ubuntu you can install Kubuntu along side Ubuntu with:

sudo apt-get build-dep kubuntu-desktop
sudo apt-get install kubuntu-desktop

An alternative way to install a new desktop environment is to use Tasksel. Install Tasksel with “sudo apt-get install tasksel” then run it from the command line with “sudo tasksel”. Once Tasksel is loaded, use the up and down arrow keys to scroll through the software packages, use the space bar to select packages and use the enter key to commit changes.

Solution Nine: reconfigure everything

If you are adamant that you want your desktop fixed because you can’t live life without it then a completely nuclear approach is to reconfigure everything. In this case, “everything” does mean every single bit of software installed on your computer via its package manager.

Reconfiguration is achieved with

sudo dpkg-reconfigure -a --priority=critical

The option –priority=critical instructs DPKG to show questions that absolutely must be answered by a human to enable a package to be configured. Keep watching the shell because you will need to answer occasional questions that must be answered before DPKG can continue processing software.

A common error chucked out by dpkg while everything is being reconfigured is

dpkg-maintscript-helper: error: couldn't identify the package

The solution is to run the following sed command to comment out any lines beginning “dpkg-maintscript-helper”. These lines are found in all cron files stored in /var/lib/dpkg/info/

sudo sed -ir 's/^\(dpkg-maintscript-helper\)/#\1/' /var/lib/dpkg/info/cron.*

After DPKG has reconfigured everything, uncomment those lines with the sed command

sudo sed -ir 's/^#dpkg-maintscript-helper/dpkg-maintscript-helper/' /var/lib/dpkg/info/cron.*

If reconfiguring everything does not enable you to gain access to a desktop and none of the other solutions presented in this guide to fixing desktop loading errors revives your desktop then I suggest you use a Live Disc to access your hard drive then backup your home directory and any files you want to keep then reinstall your OS. Alternatively, keep searching for solutions and post them here so we can all benefit from them.

Visit our Linux display errors Q&A forum for more help.

Sharing is caring!

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x