The Definitive Guide to Getting Your Linux Desktop Back

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,MetacityCompiz 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 tuxfiles.org.

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 thisnavigation 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:

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

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

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:

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

or

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:

Next install Aptitude:

Then install missing package dependencies and do a full upgrade with

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

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

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

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:

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

Next, reconfigure the display manager with

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

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

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

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:

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.

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

Table 1: Common Window & Display Manager Combinations
Example DistroDesktop EnvironmentWindow ManagerDisplay Manager
UbuntuGNOMEmetacitygdm
KubuntuKDEkde-workspacekdm
KubuntuGNOME & KDEcompizkdm or gdm
UbuntuUnityunitygdm
LubuntuLXDElxdeldm
XubuntuXFCExfce4lxdm

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

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:

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

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

Secondly, purge packages with the command

Thirdly, reinstall the purged package with

Finally, restart your computer.

For example, to purge and reinstall 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
  4. Paying attention to the capital X, recreate a default xorg.conf file with
  5. The new xorg.conf file will be in your home directory. Move it to /etc/X11/ with
  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:

Ubuntu

Kubuntu

Lubuntu

Xubuntu

Edubuntu

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:

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

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

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/

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

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.

More Info.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值