I've used my raspberry pi for about 2 years now and in the beginning I removed the X server as I thought I'd never use it. (I followed the tips here to remove How to uninstall X Server and Desktop Manager when running as headless server?).

Now I want to be able to run X server and have graphics.

I've been entertaining the idea of wiping the SD card and just doing a new installation with X already working but I've configured the Raspbian I have now quite extensively and I don't want to do it again.

My preferred method would be to just install X and get it working again into the Raspbian I already have there. Is it possible? How would I go about doing that?

up vote 20 down vote accepted

Linux uses a heterogeneous GUI stack, meaning it's arranged in layers but there's different layers you can arrange.

The bottom of the stack is relatively homogeneous, meaning it's almost always the same. This is the Xorg server joan has indicated.

However, while X all by itself does provide you with a graphical desktop, it doesn't look like much -- plain black screen with a cursor. This makes just launching applications difficult, since there are no menus or taskbars either. You can configure a terminal to launch at start up and go from there, but realistically, additional software is needed.

This is where the next two layers, the window manager (WM) and desktop environment (DE) come in. The latter requires the former but not vice versa. There are stand-alone WM's that have most of the features associated with a graphical desktop, but linux distros usually use a more minimal WM with a heftier DE on top.

The default DE on Raspbian was (keep reading) lxde. If you want that back, I imagine apt install lxde should do it. There may be more pieces needed in the end -- you can see a list of possibilities with apt-cache search lxde. The other common linux DE's are also available, but most of them consume more resources which is why lxde was chosen as the default on the pi.

Note that this does not include a graphical login, which is the task of a display manager (DM). The default on raspbian is lightdm, which you can install with apt-get install lightdm.

To sum up the two parts you'd need to get the original GUI system back would be:

  • apt install lxde lxde-core lxterminal lxappearance
  • apt install lightdm

These should drag in X and other dependencies if they are not there already. If you wish to start X from the command line using startx or xinit, you'll need:

  • apt install xinit

The new default DE is the Pi Foundation's tweaked branch of LXDE, PIXEL. Apparently you can install that with:

apt install raspberrypi-ui-mods

This may or may not include a display manager for GUI logins.

  • Thanks. This took about 300 mbs of space on hdd which is what I was expecting. The install I did before that installed X11 didn't allow me to run startx, it just said that startx wasn't a recognized command. This might fix it I hope. – Whettingstone Jan 14 '15 at 13:23
  • 2
    Looking at apt-file search startx (finds packages containing file), startx is in the xinit package (which you would need to start X usefully...). Probably that got pulled in with the other stuff, but if not, there you go. – goldilocks Jan 14 '15 at 13:31
  • 1
    startx was missing so I had to get xinit as well. After that I can seemingly start X. For obvious reasons I can't see anything since SSH is my only option right now but I'll see when I get home. – Whettingstone Jan 14 '15 at 14:40
  • Following this then runnung startx or xinit results in a white screen in the top left with the command line, and not starting the GUI. but running service start lightdm results in the login screen, and after logging in shows the white screen in the top left again. Rebooting went to the login screen on reboot, but after logging in the box in the top left with the command line is black. – Laurence Cope Oct 15 '17 at 9:51
  • I had to also run the command "sudo apt-get install lxde-core lxterminal lxappearance" from therryvanneerven.nl/… – Laurence Cope Oct 15 '17 at 10:12


sudo apt-get install xutils

That should drag in all the packages you need.

Then perhaps use

sudo raspi-config

and select the option to boot to desktop.

  • That only seems to get util packages for X11. Can't see anything but that references. Also, it takes up about 4.5 mb of space which seems little for X11 and window managers. – Whettingstone Jan 14 '15 at 12:23
  • I think if it doesn't drag in X it must already be installed. Not going to swear on my life though. That's what a package manager should do. – joan Jan 14 '15 at 12:25
  • 1
    @Whettingstone try apt-get xserver-xorg. Does that make a difference? – joan Jan 14 '15 at 12:29
  • Joan Yes, it goes from 21 packages and 4.5 mb to 34 packages and 22.5 mb. It still seems very little to me, at least size wise. I would have expected a few hundreds of mbs. – Whettingstone Jan 14 '15 at 12:33
  • 1
    Give it a go. You can pack an awful lot of software object code into a megabyte. – joan Jan 14 '15 at 12:35

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.