82

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?

4

12 Answers 12

68

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
2
  • 11
    sudo apt-get autoremove --purge
    – hostmaster
    Commented Oct 11, 2015 at 10:53
  • Two liner magic!
    – GTodorov
    Commented Jul 23, 2017 at 4:46
34

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

3
  • 4
    +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
    Commented Mar 6, 2013 at 12:18
  • 2
    This really is the best answer for most situations where SD card space is scarce.
    – kenny
    Commented Nov 23, 2013 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
    Commented Nov 26, 2013 at 12:32
17

$ 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.

4
  • 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. Commented Mar 28, 2014 at 22:25
  • 1
    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
    Commented Apr 14, 2014 at 9:33
  • 1
    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! Commented Apr 14, 2014 at 15:18
  • 2
    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
    Commented Feb 16, 2017 at 15:58
13

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.

2
  • 1
    Would you mind adding the exact aptitude command that you would use to remove the X packages?
    – fouric
    Commented Mar 5, 2013 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
    Commented Mar 5, 2013 at 19:34
10

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
2
  • Package 'task-desktop' is not installed, so not removed... Commented Oct 30, 2015 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
    Commented Aug 23, 2017 at 4:18
7

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

5

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!

1
  • openjdk-11-jre-headless in Raspbian Buster
    – fer
    Commented Dec 18, 2019 at 11:15
4

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

3
$ 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.

4
  • It is the exact same answer I gave.
    – vcuongvu
    Commented Feb 3, 2016 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. Commented Feb 3, 2016 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
    Commented Feb 3, 2016 at 12:52
  • 1
    This answer is actually better and safer because the asterisk-containing argument is properly quoted.
    – joonas.fi
    Commented Feb 16, 2017 at 16:06
1

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

2
  • this does not actually answer the question, because there's no "gnome" on Raspberry Pi.
    – lenik
    Commented Dec 26, 2013 at 0:09
  • @lenik That's not true. Gnome is available, try apt-cache search gnome
    – j b
    Commented May 25, 2020 at 11:35
0

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

0

apt-get remove -y --purge x11-common apt-get autoremove -y --purge apt-get install -y deborphan deborphan | xargs dpkg -P # do this a bunch of times

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jul 2, 2022 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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