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 (almost) definitive guide to getting your desktop back
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’re about to learn a few tricks that will help you get your desktop back to full working order. You will even learn how to open multiple virtual desktops.
Written for Ubuntu, these 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 desktop’s 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.
The guide is split into five sections:
Display Errors, Symptoms & Solutions
Beginner’s Info explains how to access the Linux shell from different stages of the boot-up process, how to access the shell from within a desktop environment and how to get out of the Linux shell once you’ve accessed it. This section should be quickly scanned so you know the type of information it offers so you can refer back to it while following the solutions in the other sections of this guide.
Getting the Desktop Back demonstrates eight stab-in-the-dark ways to solve unknown desktop loading errors. These solutions fix most broken desktops. They are easily remembered so you will find yourself using them whenever your desktop breaks.
Multiple Displays shows you how to use one computer to run more than one desktop session on one machine simultaneously. This is useful when you need to locate and edit files but feel uncomfortable using the command-line to do so or when you want to browse the Net for solutions without using another computer. You only need one monitor, one keyboard and one mouse to do this.
Display Errors, Symptoms & Solutions is a list of desktop loading errors, symptoms and (surprise, surprise) their solutions. Where the first three sections teach the methods for diagnosing and fixing general display faults, this section gives solutions to specific errors that cause the computer to scream inadequacy rousing errors at you. If you have a specific error message then jump to this section before trying fixes shown in the other sections.
Resource Links lists the sites referenced in this article and the sites I discovered while fact-checking this guide.
“Obvious solutions are usually the most obviously missed!” – Lee Hodson, 2011.
I worked in hardware and software diagnostics long enough to know that many computer problems are fixed by shutting down the computer, unplugging it from the mains then checking the cables are properly connected and checking a fuse hasn’t blown before plugging in and powering everything on again before checking the monitor is switched on.
Just a tip: if you’re computer is being stubborn about being switched off, hold the power button in for 30 seconds.
When I worked as a techie, one of my colleagues took a call from someone with a fuzzy display and no matter how many times the computer and its software were fiddled with, the display remained fuzzy. The blindingly obvious solution was to wipe the screen with a cloth. That’s just one of many examples I could give you of the blindingly obvious being obviously missed.
Assuming you’ve tried the above solutions first and they haven’t helped, please read on and let’s get your desktop back.
Beginners Info
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.
Like most Linux distros, Ubuntu uses the X Window System as the basis of its desktop environment. The X Window System, also called X, makes it possible for graphical programs to communicate with the hardware Linux runs on. On top of X is a window manager such as Kwin, Metacity, Compiz or Emerald that 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. The display manager starts the X Server before the login screen shows and initializes a desktop session when you log into 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.
Getting Into the Linux Shell
The place where commands are typed instead of clicked
You will see it called a shell, a terminal, a console, the command-line, a tty and many other things. But really, it’s just a black screen with a text prompt that lets you run non graphical programs (scripts) by typing their name at the prompt and pressing enter.
When you can’t access your desktop, and a quick reboot doesn’t help, you will need to use the Linux shell. Getting into the shell is easy and whenever I say “drop to a shell” I mean you should do one of the things suggested in this section.
Option One: Ctrl+Alt+Function Key
The typical way to drop to a shell is to press Ctrl+Alt+F1 or any Ctrl+Alt+Any function key from F1 through F6. This should make your screen go black for a second or two before it displays a textual login prompt. Use your regular desktop login username and password to log into the shell.
Access the boot menu (or grub menu) by continuously tapping the Shift key when the computer begins to boot up. Keep tapping it until the boot menu shows. In the menu, select the Recovery Console option then select Drop to Root Shell Prompt with Networking.
If tapping the Shift key doesn’t bring up the boot menu, tap Escape instead.
You might need to restart a few times before tapping Shift (or Esc) takes you to the boot menu.
Be careful while using a root shell because you will have super user rights. Running your OS with root privileges (admin rights) will leave your OS undefended against malicious software such as viruses.
Option Three: Log into a Console at the Login Prompt
Most display managers (login screens) have a drop-down menu that lets you choose the environment you want to log into. When using the GNOME Desktop Manager (GDM), the drop-down menu is in the menu bar at the bottom of the screen. When using the KDE Desktop Manager (KDM), the drop-down menu is usually beneath the login form. Most desktop managers place their drop-down menus in either of those two places. XDM (The X Desktop Manager) is one of the exceptions that doesn’t provide an option for choosing the desktop environment to be logged into.
The option for logging into the Linux shell is often labeled “Failsafe” or “Console”. Choose it, then log in as per normal and a terminal window will open up. Use this terminal as you would the Linux shell.
Option Four: Ctrl+Alt+Backspace
Pressing Ctrl+Alt+Backspace should kill the window manager for the active display.
This key combination is disabled in modern versions of Ubuntu but when you have command-line access, you can re-enable it with
setxkbmap -option terminate:ctrl_alt_bksp
A more permanent solution is to append that line to a file called xinitrc with the command
sudo sh -c "echo -e '\nsetxkbmap -option terminate:ctrl_alt_bksp\n' >> /etc/X11/xinit/xinitrc"
A third option for enabling Ctrl+Alt+Backspace requires access to the desktop:
“On KDE, this system-wide setting has no effect. To restore, go to Kickoff > Computer > System Settings which will open up the System Settings window. Click on ‘Input Devices’. In this new window click the Keyboard tab and then click on the advanced tab. In this new window, click the box for ‘Configure keyboard options.’ Expand the entry for ‘Key sequence to kill the X server’ and ensure Control + Alt + Backspace is checked. Click Apply and close the System Settings window. You now have your CTRL-ALT-Backspace back in KDE.” – source.
Getting Out of the Linux Shell
Unhiding an Already Running Desktop
Dropping to a shell from a desktop environment will not kill the desktop manager or window manager. It only hides it. You can get back into a “hidden” desktop by pressing Ctrl+Alt+F7.
Ubuntu gives you six possible command-line terminals to choose from by pressing any function key from F1 to F6 in combination with Ctrl+Alt. You can log into each of these terminals either as yourself or another user and run up to 6 virtual displays. Any activated display can be viewed by pressing Ctrl+Alt in combination with any function key from F7 to F12. Terminal F1 is typically used with display F7, F2 is typically used with F8, and so on to terminal F6 being used with display F12.
Displays are numbered 0 to 5. For example, Ctrl+Alt+F7 corresponds with display 0 and Ctrl+Alt+F12 corresponds with display number 5. More about this is shown in the section on Multiple Displays.
Starting (and Stopping) a New Desktop: The Failsafe Environment
The X Windows System, X, provides an option for running a basic configuration of an available desktop environment as provided by your desktop manager.
The default environment lacks a user’s usual desktop settings. It is loaded by the following command-line instruction:
startx
The default desktop environment loaded by startx can be overridden on a per user basis by stating the desktop manager to load in the .xsession and .xinitrc scripts in a user’s home directory. You don’t need to know much about .xsession and .xinitrc just yet. The section on Multiple Displays discusses them in more detail.
You can start your regular desktop environment by initializing your display manager (login manager). The commands for starting and stopping different display managers are in Table 1.
Only one desktop session can run on a display at any one time so make sure your regular desktop session is stopped before you try to start another. For instance, if you used KDE with the K Display Manager (KDM) and needed to restart your desktop session, you would first stop your display manager with “sudo stop kdm” then restart it with “start kdm”.
Some older versions of Ubuntu use a longer command-line instruction to start and stop display managers. The old command took the form:
/etc/init.d/[display manager] start/stop
For example, to start kdm you would type
/etc/init.d/kdm start
and to stop it
/etc/init.d/kdm stop
Starting a default desktop environment with startx can help you to establish whether your desktop loading error is caused by a misconfiguration of the window manager, desktop manager or a script that starts when your regular desktop loads i.e if startx loads a desktop then there is probably a misconfiguration that causes the system to hang.
If you are unable to start a desktop session without being a root user (e.g you need to type “sudo startx” or “sudo start kdm”) then you will need to create an .xsession script as shown in Display Errors, Symptoms & Solutions: Error 4. It is a bad idea to start a desktop session as root.
If you can’t access the shell
Some solutions shown below here are as simple as editing configuration files so if you can’t access the shell use a Linux Live disc to gain access to your operating system’s configuration files and make edits with the Live Disc’s file browser and text editor.
Once a Live Disc has loaded a desktop, open a terminal and mount all storage devices with the instruction
sudo mount -a
Depending on the display manager used by the live disc, open a file as root with one of the following commands:
KDE
sudo dolphin
GNOME
sudo nautilus
LXDE
sudo thunar
If you do need to reinstall everything, you can use a Live Disc to enable you to browse and backup your home directory and any files or documents you want to preserve.
Listing files is done with the “ls” command. File names that start with a dot are hidden. Type “ls -a” to view all files and directories including hidden ones. Type “ls” to see files and directories that are not hidden only.
Changing directory is done with the “cd” command. Type cd followed by the directory you wish to go to. For example, typing “cd /home/dion” would take me to my home directory.
A shorthand way of accessing the home directory is “cd ~/” and a shorter way is “cd ~”. The tilde symbol, ~, represents the home directory. So typing “cd ~” would take me to /home/dion/.
Going up a directory is as easy as typing “cd ..”.
Editing files is easily done with the command-line text editor Nano. Type “nano” to start Nano. You can tell Nano to open a specific file with the command “nano /directory/file-name”. Some files need to be opened by a user with admin rights before they may be edited. Typing “sudo nano” will allow those files to be edited.
Nano has a menu at the bottom of its display. Menu items are accessed by pressing Ctrl plus the specified key for the menu item. For example, Ctrl+X closes Nano.
Nano offers to save file edits on exit.
Locating a file or directory is as easy as typing “locate file-name”.
If a listing is too long to display on one page, you can “pipe” it through the “less” command to spread it over several pages. The pipe is the vertical line character on your keyboard that looks like “|”. For example “ls | less” or “locate home | less”.
Stopping a running program is done by pressing Ctrl+C.
Quiting a running program is done with Shift+Q.
Rebooting the system is done with the command “sudo reboot”.
Shutting the system down is done with “sudo shutdown -P now”
Getting the Desktop Back
When your desktop breaks, it’s usually caused by a bad setting in any of the window system, the window manager, the desktop manager or the display manager. It’s not unknown for an update or the removal of a software package to uninstall one or more of those layers or their dependencies.
This part of the desktop recovery guide will help you fix those layers of graphical user interface (GUI).
The Preliminaries
Firstly, print out this guide then get access to a shell using the instructions shown above here. Ctrl+Alt+F1 usually works.
Secondly, ensure your display manager is not running. Use the instructions given above here to stop it. For example, “sudo stop gdm” or “sudo stop kdm”.
Thirdly, when Xorg begins loading the display it writes a log file to /var/log/Xorg.#.log (where “#” represents the display number, 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 – external site):
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 here (external site).
Fourthly, 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 if they are corrupt they can prevent X from initializing properly. Run the next command to rename them and therefore prevent them from being used:
sudo cp ~/.xinitrc ~/.xinitrc.bckxyz; sudo cp ~/.xserverrc ~/.xserverrc.bckxyz; sudo cp ~/.xsession ~/.xsession.bckxyz
Instructions for recreating those 3 files are given here.
By renaming them instead of deleting them you are able to examine them later on.
Solution One: 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:
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 Two: Reconfigure the Window System
A screwed up 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 Three: Reconfigure the Window Manager
Different desktop managers tend to use different window managers. Table 2, below, shows common desktop manager, window manager and display manager combinations. Refer to table 2 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 re-access the graphical environment. If the screen at Ctrl+Alt+F7 stays blank, try F8 instead of F7. Move to the next solution if that doesn’t work.
Solution Four: 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
/usr/bin/kdm
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 option works.
Solution Five: 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 2 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 2.
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 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 but, 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 Six: Switch to a Basic Graphics Driver
Many graphics problems, blank screens and desktop loading issues are caused by misconfigured, corrupt or buggy graphics drivers, especially propriety ones such as those used by ATI and NVIDIA graphics cards. The easiest solution is to disable your VGA’s specific driver and to use a generic driver such as MESA or VESA by recreating the corg.conf file:
- Drop to a shell
- Stop your display manager as shown in table 1 e.g “sudo stop kdm” or “sudo stop gdm”
- Delete your xorg.conf file
sudo rm /etc/X11/xorg.conf
- Recreate a default xorg.conf file with
sudo Xorg -configure
- The new xorg.conf file will be in your home directory. Move it to /etc/X11/ with
sudo mv ~/xorg.conf.new /etc/X11/xorg.conf
- Restart your display manager with “sudo start kdm” or “sudo start gdm” etc…
- 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 and hope that doing so fixes the original issue. 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 solely related to your graphics driver, if at all related to it.
Solution Seven: 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
sudo apt-get build-dep ubuntu-desktop sudo aptitude reinstall ubuntu-desktop
Kubuntu
sudo apt-get build-dep kubuntu-desktop sudo aptitude reinstall kubuntu-desktop
Lubuntu
sudo apt-get build-dep lubuntu-desktop sudo aptitude reinstall lubuntu-desktop
Xubuntu
sudo apt-get build-dep xubuntu-desktop sudo aptitude reinstall xubuntu-desktop
Edubuntu
sudo apt-get build-dep edubuntu-desktop sudo aptitude reinstall edubuntu-desktop
Installing an alternative desktop environment will provide you with a desktop to use until your regular one is fixed. To install a new one use the above commands but replace “sudo aptitude reinstall” with “apt-get install”.
For example, to install Kubuntu:
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 with “sudo tasksel”. Once Tasksel is loaded, use the up and down arrows to scroll through the software packages, space to select a package and enter to commit changes.
Solution Eight: Reconfigure Everything
If you’re adamant that you want your desktop fixed because you can’t live life without it then a bombastic approach is to reconfigure everything. In this case, “everything” does mean every single bit of software installed on your computer via your 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 still need to answer occasional questions that must be answered before DPKG can continue processing software.
A very common error chucked out by dpkg while reconfiguring everything 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” that 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 wouldn’t like to lose before you reinstall your OS. Alternatively, keep searching for solutions and post them here so we can all have the benefit of them.
Multiple Displays
Linux is full of surprises. Having multiple virtual desktops is good but being able to run multiple virtual displays with each display using its own desktop manager is so much better.
Function keys F1 through F6 give access to the Linux shell. A new desktop session can be initialized and viewed on a virtual display by anyone logged into a shell session.
Virtual displays are mapped to function keys F7 through F12 and can be viewed by pressing Ctrl+Alt+F7 through F12 once initialized from a shell.
In other words, one physical computer, keyboard, mouse and display can be used to run multiple desktop sessions by one or more users with each desktop display visible on a virtual display accessed by pressing Ctrl+Alt+ the function key from F7 to F12 that is mapped to that display.
Generally, you have access to 6 command-line shells from which 6 desktop sessions and 6 displays can be initialized. Displays are numbered 0 to 5 and correspond to keys F7 through F12.
The default display, the one you see when you log into your computer, is called display 0. It corresponds to function key F7 so is accessed by pressing Ctrl+Alt+F7.
Command-line shells do not automatically correspond to a particular display and desktop session. With the exception of display 0, whenever you wish to start a new desktop session you must specify the display to open it on. If you were logged into the shell at Ctrl+Alt+F2, you could open a desktop session accessed through Ctrl+Alt+F8 or Ctrl+Alt+F9 or Ctrl+Alt+ any key from F7 to F12 that does not already have a display mapped to it.
There are several ways to initialize a desktop session. The easiest way is to type “startx” while logged into a command-line shell. Doing so will spawn a desktop session on display 0 at Ctrl+Alt+F7.
The startx command opens a desktop session using the default desktop manager such as KDE or GNOME. So if you usually log into GNOME then startx will spawn a GNOME session.
To start a desktop session alongside another session, drop to a shell by pressing, for example, Ctrl+Alt+F2 then tell X to start a desktop session by typing
startx -- :1
The part after the two dashes is an instruction to the xserver. In this case, the colon (:) and the number tell xserver the display number to open. “startx – - :1″ opens a desktop session on display 1. Display 1 is mapped to F8 so is accessed by pressing
Ctrl+Alt+F8
Type “man startx” and “man xserver” in a terminal prompt or on the command-line to learn more about the options you can use to configure a new session when initializing one.
You can start a desktop session with a specific display manager by specifying the path to the binary file of the display manager you wish to use.
For example, to start a KDE session on virtual display 1 you would type
startx /usr/bin/kdm -- :1
Other display manager binary files are stored in the directory /usr/bin/ also, so, for example, to start a gdm session on display 2 you would type
startx /usr/bin/gdm -- :2
Remember that display 0 is mapped to F7, display 1 is mapped to F8 and display 2 is mapped to F9 so press Ctrl+Alt+F8 to view display 1 or Ctrl+Alt+F9 to view display 2.
Though not recommended in the xorg man page, an alternative to using startx is to use “Xorg :[Display Number]“. For example:
Xorg :1
Pay attention to the capitalization of the X. It is deliberate and needed.
Adding a New User
Opening multiple desktop sessions for use by the same user will cause each desktop to use the same configuration files. Although different applications can be opened in different sessions and the same applications can be opened in different sessions concurrently, changes made to the settings within each application will impact across each session unless each concurrent desktop session is opened by a different user. In other words, if you wish to use different configurations for each desktop and each application then you will need to login as a different user for each simultaneous session.
New users can be added with the adduser command which takes the form
sudo adduser username
Adduser will prompt for a password during the new user account’s set up. Type “man adduser” in the command-line to learn more about the adduser script.
Starting a desktop session as a new user is an excellent way to determine whether a desktop loading error is due to misconfigured application or buggy software: if a desktop loads for a new user then the issue relates to a something specific in the desktop setup of the user whose desktop will not load.
Starting a Display from a Remote Location
I’ve never tested this but I know it’s possible. You can log into a Linux computer from another Linux computer connected to the same network. You only need the IP address of the computer you wish to log into and, if it’s a secure (SSH) connection, a username and password. You might find this useful if your computer boots up but fails to respond to its input devices.
To remote access a computer without SSH (a non secure connection):
X :1 -query IP-Address
To remote access a computer with SSH (a secure connection):
ssh -X IP-Address
You can discover who is logged into a computer by typing “w” in the command-line.
You can use the ifconfig command to discover your network’s internal IP address. All devices attached to your network will have an IP address that is based on your network’s IP address. For example, if ifconfig shows your “inet address” to be 192.168.1.2 then your router will be at 192.168.1.1 and other machines will be at IP addresses ranging from 192.168.1.3 to 192.168.1.255.
I will write more about this at a later date.
Display Errors, Symptoms & Solutions
X: user not authorized to run the X server, aborting
Solution
Reconfigure x11-common with
sudo dpkg-reconfigure x11-common
Now select “Anybody” from the presented options.
X: client 1 rejected from local host
Solution
Enable access for localhost
xhost +localhost
Doing the above is a security risk. It all local programs to access the X server so remember to use “xhost -localhost” when you close your session.
An even more insecure solution, though more likely work, is to enable anyone to start a desktop session with
xhost +
Remember to secure access to your computer by resetting xhost to permit access from registered users only by typing
xhost -
Failure to reset xhost will leave your computer open to hackers.
Not all programs open in the actively viewed desktop (they open in another desktop) or they refuse to open at all
Solution
This is another xhost issue. Either use “xhost +localhost” or “xhost +” to permit applications to run on the actively viewed desktop.
Unable to startx or xorg or init or any other desktop session start up script without being a super user i.e you have to type “sudo startx” to begin a new session.
Solution
Create a file called .xsession in the home folder of the user who wants to open a new desktop session then place the following text into it. Read it for more information:
#!/bin/sh # Each line here tells Xorg to load a specific desktop environment when a desktop session is created. # Remove the hash sign (#) to uncomment the instruction you want Xorg to execute. # Prepend a hash sign to any line to comment it out. # Only one line should be uncommented. # Only uncomment an instruction if you have the required environment installed # KDE is uncommented by default # exec afterstep # AfterStep # exec blackbox # Blackbox # exec enlightenment # Enlightenment # exec fluxbox # Fluxbox # exec startfluxbox # Fluxbox # exec fvwm # FVWM # exec fvwm2 # FVWM2 # exec gnome-session # GNOME # exec icewm # IceWM # exec ion # # exec mwm # Motif # exec openbox # Openbox # exec openbox-session # Openbox # exec pekwm # exec qvwm # qvwm # exec /usr/bin/ratpoison exec startkde # KDE # exec startlxde # exec startxfce4 # XFce 4 # exec wmaker # WindowMaker # exec xfce # XFce 3 # exec xterm # ...or another installed Window Manager
You can create the .xsession file in the home directory of the user logged into the terminal from the command-line by executing the command
sudo touch ~/.xsession
The important part of the file is the exec command so you only need to a relevant exec line into it. This can be done from the command line with, for example,
sudo sh -c "echo -e '#!/bin/sh\nexec startkde\n' >> ~/.xsession"
Replace “startkde” with whatever session type you want to start.
You can edit the .xsession script from the command-line with Nano:
sudo nano ~/.xsession
The above instructions apply to the files .xinitrc and .xserverrc also.
The window manager loads to a blank screen
X starts with a blank screen
The screen’s black when the desktop starts
No desktop shows
Solution
Check for a file called .xsession in your home folder. If it doesn’t exist create it using the instructions given for Error: 4.
The desktop manager (window manager) fails to load
There’s no login screen when the computer boots
Solution
Reconfigure the desktop manager as shown in Option Three of Getting the Desktop Back. If that fails check for a file called .xinitrc in the home folder of the user who’s trying to log in. Delete it if it exists then recreate it.
To check whether it exists, type
locate ~/.xinitrc
If it does exist, delete it with
sudo rm ~/.xinitrc
.xinitrc tells X which desktop manager should be launched when a desktop session is started. If the file already exists then it might be corrupt and should be deleted or recreated.
If the file didn’t exist or if deleting it didn’t solve the login issue, create it with
sudo touch ~/.xinitrc
Open it in Nano by typing
sudo nano ~/.xinitrc
Then fill it with the same content you would put into your .xsession file as shown in the solution for Error: 4.
xinit connection to x server lost
Cannot start X without being root
Cannot start desktop without using sudo
Solution
Unless you place a copy of .xinitrc and .xsession in your home directory (or the home directory of whoever is trying to start a desktop session from the command-line), Xorg reads the global xinit and xsession files located in /etc/X11/xinit/. That means it is reading scripts that are owned by root and which belong to the root group. Xorg needs root privileges to run those files. So, the solution is to create the files .xinitrc and .xsession in the home directory i.e /home/[user name]/.xinitrc and /home/[user name]/.xsession.
Occasionally, the problem is caused by having either one or both of those files in the home directory. If the files already exist in your home directory, confirm they are properly formatted or delete one, reboot and retry, then the other before rebooting and retrying.
The files .xinitrc and .xsession can both contain the same data. Create/Recreate both files using the instructions for creating .xsession as shown in the solution to Error: 4.
Cannot open theme file /usr/share/kde4/apps/kdm/themes/oxygen-air
Cannot open some other important theme file
Solution
List the folders contained in the directory where the missing theme folder is, for example:
ls /usr/share/kde4/apps/kdm/themes/
Open the file kdmrc
nano /etc/kde4/kdm/kdmrc
Change the line
Theme=/usr/share/kde4/apps/kdm/themes/oxygen-air
Then replace “oxygen-air” with the name of one of directories listed under /usr/share/kde4/apps/kdm/themes/.
Save the file and reboot.
Resource Links
Linux start-up process, Wikipedia
Explanation of the component layers of the Linux GUI, tuxfiles.org
Explanation of Xorg, wiki.archlinux.org
Explanation of the Window Manager, wiki.archlinux.org
Explanation of the Window Manager, Wikipedia
Explanation of the Display Manager, wiki.archlinux.org
Explanation of xinitrc, wiki.archlinux.org
Comparison of window Managers, Wikipedia
List of Window Managers, xwinman.org
X.org Warning Messages FAQ, wiki.x.org
X.org Error Messages, wiki.x.org
Fix for the “not authorized to the X server” error, karuppuswamy.com
Please tell me of you find any inaccuracies or omissions soothers can benefit from your knowledge.
Want to republish this content? Read the copyright notice first.. Like this, support this.









very good!
very helpful, thanks!!!
This is awesome. Thank you. My Linux Mint 14 laptop ran out of battery and after a recharge, I couldn’t get my GUI back after boot. I tried repeated shift on boot, no go. Tried ESC on boot and it brought back the GUI.
Wow, excellent article. Helped me fixing my broken Ubuntu and improved my knowledge of Linux desktop environments…