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

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
  • 7
34

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

avra
  • 1,273
  • 8
  • 9
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
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
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
6

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
  • 161
  • 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
  • 157
  • 3
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
0

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

Netzdoktor
  • 101
  • 2