Five tips for troubleshooting Linux desktops

The Linux desktop is generally stable and trouble-free. But when the occasional issue arises, these steps will help you identify and fix the problem.

The Linux desktop is a stable environment for the end user. But even the most stable environment will have trouble now and then. When problems arise, it's always good to know how to troubleshoot the issues. But where do you start? With so many log files and different types of desktops, what are the best ways to fix an ailing Linux desktop?

Of course, since the Linux desktop environment is currently in a state of flux (with GNOME Shell and Ubuntu Unity about to be released), it's difficult to know exactly what each user is troubleshooting. But we can approach this in such a way that you can learn how to troubleshoot one desktop by seeing how to troubleshoot another.

Note: This article is also available as a PDF download.

1: Check the logs

Linux logs a lot of information. This starts with the kernel and goes all the way up to the user-space. So even desktop malfunctions will be recorded. But what log file is the best choice to begin your troubleshooting? If your desktop still runs on, the most logical launch point would be the /var/log/Xorg.0.log file. In this log file, you're going to find issues regarding X Windows, which in most instances is the underlying platform for your distribution's desktop. Even if you can't log into your desktop, you can still go to a virtual terminal (hit Ctrl-Alt-F2 to go to the second virtual terminal) and view the log files. Although this will not give you any specific information about your particular desktop environment, it will help you eliminate X Windows as a problem area.

2: Log in from the command line

One of the best ways to get a good idea, in real-time, of what is causing the problem with your desktop is to log into it from the command line. This means you have to make sure your boot process stops at runlevel 3. When your system is at runlevel 3, you will be prompted for your username and password and will have nothing more than a bash prompt upon successful authentication. From that point, you will need to use an ~/.xinitrc file, add a line like gnome-session or startkde, and issue the command startx to start up. When there are problems with the desktop, you should see error messages appear that might give you clues as to what is wrong.

3: Check to see whether it's a login issue

I have seen a user login go corrupt. This could be the shadow entry for the user or corruption in the user's configuration files. The easiest way to figure this out is to try to log on with another user. If you don't have another user, you can drop to the command line and add one with the following:

sudo useradd -d /home/testuser -m testuser
sudo passwd testuser

If you can log on with the testuser user, you know something has gone awry with your regular user.

4: Diagnose inconsistent startup

Say GNOME will start up for one user, but not another. You can work with this. You'll need to log in with the user that works and then begin the process of troubleshooting with the help of the su command. Once you have logged into the working user, open up a terminal window and change to that user with the command su USERNAME (where USERNAME is the name of the user that can't log in). Now that you have taken on the identity of that user, you can begin to troubleshoot. You can do things like disable Compiz or other effects, open Nautilus, and look for corrupt files. You might also open the gconf-editor and scan it for problems. If you suspect gconf might be the issue, you can install the Gconf Cleaner tool and have it scan for problems. (Make sure you run it as the user that can't log in.)

5: Remove user configurations

As a last ditch effort, you can log into the command line and remove the .gnome2 (for GNOME) or .kde4 (for KDE). This will get rid of all user configurations for either desktop, but it will allow you to log in. If you have special scripts or files located within those directories, you can always back the directories up and then remove them. With backup copies, you can move your scripts and files back in (one at a time) until you know you can log back in successfully.

Best problem-solvers

The Linux desktop is a solid and reliable user interface. Most often, you will never have any problems with it. But in those instances where problems happen (and happen out of nowhere, of course), it's handy to know where to begin troubleshooting.

Do you have a different method of troubleshooting the Linux desktop? How about the Windows desktop? Share your favorite diagnostic tricks with fellow TechRepublic members.