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?

fouric
  • 1,809
  • 4
  • 18
  • 26
  • I answered this in another similar question: http://raspberrypi.stackexchange.com/questions/4745/how-to-uninstall-x-server-and-desktop-manager-when-running-as-headless-server

    Answer: http://raspberrypi.stackexchange.com/a/5127/6199

    – Maxx Daymon Apr 09 '13 at 12:14
  • 3
    An additional reason to remove the gui is so that updates run faster, because fewer packages require update. – Michael Aug 15 '15 at 00:11
  • Well, now there is Jessie Lite! – Patrick Cook Feb 22 '16 at 07:07
  • +1 to @Michael. The main reason to remove the GUI is it takes 98% less resources to keep your system up to date. – SzG Dec 11 '17 at 20:41

12 Answers12

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
Keith Smiley
  • 783
  • 5
  • 6
34

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

avra
  • 1,273
  • 8
  • 9
  • 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 Mar 06 '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 03: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
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.

vcuongvu
  • 290
  • 2
  • 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. – RPiAwesomeness Mar 28 '14 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 Apr 14 '14 at 09: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! – RPiAwesomeness Apr 14 '14 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 Feb 16 '17 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.

nc4pk
  • 1,378
  • 1
  • 13
  • 25
  • 1
    Would you mind adding the exact aptitude command that you would use to remove the X packages? – fouric Mar 05 '13 at 06: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 05 '13 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
geekQ
  • 233
  • 2
  • 6
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

Diederik de Haas
  • 809
  • 8
  • 12
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!

squarism
  • 151
  • 1
  • 4
4

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

James Bennet
  • 291
  • 1
  • 2
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.

maxschlepzig
  • 147
  • 3
  • It is the exact same answer I gave. – vcuongvu Feb 03 '16 at 09: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 03 '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 03 '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
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

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

FraPel
  • 1
  • 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 Jul 02 '22 at 17:10
0

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

Netzdoktor
  • 101
  • 2