I would like to know how to completely remove X.org and all GUI-related components from Raspbian or soft-float Debian. The most obvious solution would be sudo apt-get purge xorg, but I am afraid that that will leave some GUI packages lying around.

How can I accomplish this?

  • 6
    Sorry to be condescending BUT: people who need help doing this almost always also need help recognizing why it is mostly a pointless exercise. Unless you have some specific reason (which usually has a more specific solution) other than, "I'm not gonna use it" just leave it, it does not matter. There are tons of things installed you'll never use or know about. They're irrelevant. – goldilocks Mar 5 '13 at 1:41
  • 28
    @goldilocks, it is not entirely a "pointless exercise". Modern GUIs take up large amounts of space, even "lighter" ones like LXDE, and sometimes that extra 100-800 MB of space makes a big difference. – fouric Mar 5 '13 at 7:02
  • 8
    @goldilocks I am late but I want to put down your misinformation. Disk may be cheap, but anything you have installed represents an attack vector. The first thing any competent admin does is remove everything that is not absolutely essential to the function of the device. X presents a pretty large attack surface and since it usually runs SUID root it scores highly in any risk assessment. – Adam Hawes Aug 15 '13 at 10:41
  • 8
    @goldilocks I could go on and on, but you are just wrong. If something is installed it is runnable. Just because it isn't started at boot does not mean an attacker cannot leverage it to get root once they have an unprivileged shell. And, if you don't know any sysadmins who wouldn't remove (or not install) X (and everything else they aren't using) then I suggest you don't know any competent sysadmins. My point was you're pissing on about how disk is cheap, but the OP didn't specify any reasoning for why, so your telling him to not do something he perceived a need for is just wrong. – Adam Hawes Aug 17 '13 at 7:18
  • 6
    I'm a little late to this party, but I just want to add that I am looking to install a headless server instance of a pi just for running transmission. I don't need a GUI for it, I can just SSH or console in if I need anything. I don't even have a display for it. Anyway, the main point is that I used the command `sudo apt-get --purge remove x11-* and it's freeing up 1.5gb of space. When you're talking about an average of 4gb of space per SD card, 1.5 is quite the large amount, especially when it's not going to be used. – Kirkland May 6 '15 at 1:47

11 Answers 11

I was able to remove the desktop environment include with Raspbian by first removing x11-common and then removing my 'stale' packages.

sudo apt-get remove --purge x11-common
sudo apt-get autoremove
  • 5
    sudo apt-get autoremove --purge – hostmaster Oct 11 '15 at 10:53
  • That saved me! Thanks mate! – geeth Mar 20 '17 at 2:10
  • Two liner magic! – GTodorov Jul 23 '17 at 4:46

You can do it on your own, or use what others have already done for you:

  • 3
    +1 While the autoremove option is quick and dirty and does work, I find that a clean install without the GUI works better and the footprint is smaller. – Guy Coder Mar 6 '13 at 12:18
  • 2
    This really is the best answer for most situations where SD card space is scarce. – kenny Nov 23 '13 at 3:57
  • 2
    @kenny: For even less SD card space you might want to take a look at Tiny Core Linux for Pi. – avra Nov 26 '13 at 12:32

The way I've done it is to remove all the packages under the Installed Packages --> x11 category in aptitude, then run sudo apt-get autoremove, which uninstalls any leftover packages that aren't needed anymore.

  • 1
    Would you mind adding the exact aptitude command that you would use to remove the X packages? – fouric Mar 5 '13 at 6:39
  • i just ran the aptitude TUI (text user interface), so sudo aptitude, then, using the arrow keys, scrolled to the x11 section and removed each package with the - key – nc4pk Mar 5 '13 at 19:34

$ sudo apt-get --purge remove "x11-*"

This will remove all the packages that are under x11 which is the library with all the graphical packages. the option --purge allow you to delete all the config file related.

$ sudo apt-get --purge autoremove
autoremove removes all the unused packages. There are a lot of unused packages after the first command.

  • This is a very low quality answer. You simply provided two commands and no explanation. Please, in the future, explain your answers so that users who are new can understand what you mean. You should explain what these commands are for. – RPi Awesomeness Mar 28 '14 at 22:25
  • Weeeell, sorry. So : apt-get --purge remove x11-* will remove all package that are under x11, which is the library with all the graphical package. Then, apt-get --purge autoremove will remove all package that are not used anymore. – vcuongvu Apr 14 '14 at 9:33
  • Thank you. This is exactly how an answer should be, provide the commands as well as an explanation. That's all I was trying to get you to do. Thanks! – RPi Awesomeness Apr 14 '14 at 15:18
  • 1
    It is dangerous to use wildcard without quotes. If there are any files or directories beginning with "x11-" in your current directory, they're going to get passed to apt-get, because your shell tries to look for matching files by your wildcard. Quoting it passes the asterisk directly to apt-get: $ sudo apt-get --purge remove "x11-*" – joonas.fi Feb 16 '17 at 15:58

The GUI packages are referenced by the meta-package task-desktop. So it is enough to remove that meta-package:

sudo apt-get remove task-desktop

I found out the name of the package by running Debian-specific tasksel:

tasksel --list-tasks
tasksel --task-packages desktop
  • Package 'task-desktop' is not installed, so not removed... – brianlmerritt Oct 30 '15 at 10:31
  • tasksel remove desktop seems to be the way to do it but it doesn't do anything. A curses screen pops up and then goes away. – squarism Aug 23 '17 at 4:18

There is now also an X-less image by the foundation named Raspbian Jessie Lite: https://www.raspberrypi.org/downloads/raspbian/

And if you want an installer which installs only a minimal system, there's also the Raspbian UnAttended Netinstaller

Build a custom image? - I use https://github.com/jamesbennet/pistrap. A fairly minimal install is ~300mb.

Jessie Raspbian took a different but similar path as other answers here.

# First the jre needs X (boo!) so switch that out to a headless version
sudo apt-get install -y openjdk-7-jre-headless

# Next x11 won't go because libice6 is installed
# but this seems to trigger the same result
sudo apt-get remove -y libice6

# Finally clean up
sudo apt-get autoremove -y --purge

While I'm at it, cleaning up for headless mode:

# you can also create this blank file after you
# burn your image to the SD card
touch /boot/ssh

sudo raspi-config
   3. Boot Options
      - B1 Desktop / CLI
        - B1 Text console, requiring user to login
        - Press Enter
      - Tab over to Finish
      - Yes to Reboot

# switch users, get rid of default password in a way
sudo useradd -G sudo -m your_new_username
sudo passwd your_new_username
sudo userdel -r pi

Headless server!

$ apt-get --purge remove 'x11-*'
$ apt-get --purge autoremove

The first command removes many X11 packages, including the X11 core libraries. Since all other X11 packages (transitively) depend on the X11 core libraries, they are also removed.

The second command removes all now unneeded packages, i.e. packages that were only installed as a dependency of later removed packages.

The --purge options instructs apt-get to also remove the related configuration files.

On non-minimal install this frees up about 1.5 GiB space.

  • It is the exact same answer I gave. – vcuongvu Feb 3 '16 at 9:52
  • @vcuongvu, no, it is not. My explanation is different, i.e. better and more extensive. I also give an estimate on how much space will be freed. I addressed this because some readers of the question apparently have doubts if the removal is actually worth it. Btw, I upvoted your answer because it contains the right commands. – maxschlepzig Feb 3 '16 at 10:07
  • My bad then, I'm unable to remove my downvote unless you edit a little bit your answer. However, I think it would be less redundant to comment under my answer in that case. – vcuongvu Feb 3 '16 at 12:52
  • 1
    This answer is actually better and safer because the asterisk-containing argument is properly quoted. – joonas.fi Feb 16 '17 at 16:06

to remove gnome

# tasksel remove gnome-desktop

Tasksel is a tool that installs multiple related packages as a co-ordinated “task” onto your system.

# apt-get install aptitude tasksel

Install gnome on debian

# tasksel install gnome-desktop --new-install

http://namhuy.net/1085/install-gui-on-debian-7-wheezy.html

  • this does not actually answer the question, because there's no "gnome" on Raspberry Pi. – lenik Dec 26 '13 at 0:09

I had a similar problem on my RPi. Using aptitude purge instead of apt-get purge did the trick.

Your Answer

 
discard

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.