Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm using my Raspberry Pi as a headless server which I can ssh into. I don't need the X Server, LXDE etc.

I'm running Raspbian "wheezy". I've already disabled "Start desktop on boot" using raspi-config as described here. But I keep getting lots of package updates for all the desktop stuff that I don't use (I run apticron to notify me of pending updates via email), so I'd like to completely apt-get remove all the unnecessary packages to avoid these unnecessary updates.

Which package(s) should I remove?

So far, I've come up with the following:

sudo apt-get remove desktop-base lightdm lxappearance lxde-common lxde-icon-theme lxinput lxpanel lxpolkit lxrandr lxsession-edit lxshortcut lxtask lxterminal obconf openbox raspberrypi-artwork xarchiver xinit xserver-xorg xserver-xorg-video-fbdev

I made the above list by looking in aptitude for all packages in the Installed Packages -> x11 -> main section that were not "automatic installs".

For some reason when I run this, apt-get tells me that:

The following extra packages will be installed:
  libutempter0 xbitmaps xterm

which seems a little odd for a remove operation.

Is there an easier way? Is there a "super" package which owns all of this graphical stuff and can be removed, taking all it's dependencies with it? From my understanding, it doesn't look like this is possible, because these things have not been automatically installed, meaning I need to track them all down and remove them all explicitly.

share|improve this question

6 Answers 6

up vote 31 down vote accepted

If a package foo depends on another package libfoo and you remove the libfoo package, the dependent (foo) is also removed. Because Foo has a depends line specifying libfoo, it would be broken to leave foo if libfoo were removed. The reverse is not true: removing foo does not delete libfoo automatically. Another package xfoo may also depend upon libfoo, so apt won't just remove it (although apt will track if it was installed only as a side-effect of installing foo and offer to auto-remove it if you ask it to, so long as no others still depend on it)

Meta packages depend on a set of other packages in much the same way that foo depended on libfoo, so when you remove a meta-package, little else is typically removed. For example, there may be two meta-packages that depend on xterm (lxsession and xfsession perhaps), but uninstalling one or both won't uninstall xterm because xterm isn't broken without lxsession or xfsession. Meta-packages are generally at the top of the dependency tree, not at the bottom, and few things tend to depend directly on meta-packages. Meta-packages primarily provide a convenient way to install a sensible set of packages at once, but they aren't uninstall tools.

So, if you want to scorch everything that depends upon X11, you will need to target the base set of libx11 libraries that all x11 apps must ultimately depend upon:

apt-get remove --dry-run --auto-remove --purge libx11-.*

This will (simulate) remove everything that ultimately depends on libx11-.*, and will also remove any packages that were installed as a dependency of an X11 program even if they didn't directly depend on X11 itself (CUPS and Ghostscript are typically installed as a side-effect of installing a desktop environment). Remove "--auto-remove" if you want to do this step later or not do it at all, or just add back the packages manually after cleaning the GUI off.

I prefer to clean and purge the side-effects, and add them back as needed. Also, I went ahead and tested this on my own pi, and it rebooted to a very spartan but functional server. :)


The above strategy solves the stated problem, but there is still the curiosity of why a remove operation results in packages being installed.

At the heart of every package manager is a satisfiability solver of some kind. When you tell a package manager to install some packages, remove some packages, or upgrade some packages, what you are really asking it to do is to solve for the next desired state of software installation given an available set of packages. This solution may include installing additional packages (dependencies), removing existing packages (conflicts, breaks), downgrading/upgrading specific packages (compatibility level), or a combination thereof. So, while it is a bit counterintuitive that the solver determines that some packages need to be installed in order for other packages to be removed, it makes perfect sense. This is the nasty dependency management problem that package managers solve.

A concrete example: Given a set of Java applications already installed, they all depend upon a java compatible runtime which currently happens to be openjdk-7-jre. You then ask the package manager to solve for installation of a new Java tool that declares a conflict with openjdk-7-jre but works with oracle-7-jre (both packages generically provide a java-7-runtime). The solver will propose a removal of openjdk-7-jre and an install of oracle-java-7-jre as the solution to your desired state of having the new package installed while not breaking existing packages.

In this specific case, xterm is a package that provides a virtual dependency called x-terminal-emulator (xterm, lxterminal, and aterm all provide an x-terminal-emulator), so it is likely that in removing lxterminal (as a part of removing lxde), the solver found an existing installed package (transcode as a possible example) that required some kind of x-terminal-emulator, so the solver chose to install xterm (which requires libutempter0 and xbitmaps, explaining the other packages to install) to satisfy the otherwise broken dependency. Without seeing the package database, I would hypothesize that this is the most likely scenario.

To discover the packages that are currently depending upon xterm (or an alternate), use the apt-cache rdepends command (using the --installed switch to limit to installed packages only):

$ apt-cache --installed rdepends xterm
xterm
Reverse Depends:
    |xorg
     clusterssh
    |xinit
    |tk8.5
    |tk8.4
    |transcode

Dependencies that start with the alternation character '|' mean that the package depends on xterm or something it provides (that something is x-terminal-emulator in this case). The clusterssh package depends on xterm explicitly, and does not allow for an alternative. This is the short list of the packages that are causing xterm to be required.

share|improve this answer
1  
Brilliant worked for me thanks. It did also remove munin for some reason, but I could put that back easily enough afterwards. –  Day Mar 11 '13 at 12:53
2  
Scorch it! I had to quote 'libx11-.*' to prevent the shell from globbing. –  Cuadue Aug 18 '13 at 20:16
1  
@Maxx, great answer, but in all your scenarios, you didn't describe how it is that when he ran the apt-get remove that it wanted to install xterm and two others. I too have experienced this and couldn't work it out. –  Madivad Aug 25 '13 at 11:17
1  
Thanks for the comments! I updated the answer to address the question from @Madivad –  Maxx Daymon Aug 30 '13 at 7:28

Have a look here but scroll down to the part about tasksel.

Running tasksel --list-tasks on the pi via wifi ssh gives me (after about 30 seconds):

u desktop   Debian desktop environment
u web-server    Web server
u print-server  Print server
u database-server   SQL database
u dns-server    DNS Server
u file-server   File server
u mail-server   Mail server
u ssh-server    SSH server
u laptop    Laptop

So, tasksel remove desktop should do what you want [see comments]. The man page is a little brief and mysterious, perhaps because tasksel is mostly intended for debian maintainers. If this works let us know ;)

share|improve this answer
    
Thanks, I'd never heard of tasksel, although I do have a fair amount of Ubuntu experience. Unfortunately I tried this, it took a while to run the remove desktop command but all those "graphical" packages are still there according to aptitude. –  Day Jan 29 '13 at 20:39
    
I hadn't either, but I was a little perturbed when I noticed just apt removing some basic X component did not pull the whole dependency stack, which I thought it would. I found a better page for tasksel, and actually fired up the ncurses app (tasksel with no options). Pretty sure now the 'u' means the metapackages are't installed, and if you install 'desktop', you will get a get more than just the lxde version wiki.debian.org/tasksel So no dice. I notice the "xorg" metapackage from apt-cache search metapackage is not actually installed either. Blame the raspbians I guess. –  goldilocks Jan 29 '13 at 20:54
2  
I'll leave this answer up to save someone a dead end, or in case anyone can shed better light. –  goldilocks Jan 29 '13 at 20:56

Based on the tasksel information, it is possible to find out, that there is a meta-package task-desktop, which references all the other GUI related packages. So just

sudo apt-get remove task-desktop

This will remove plenty of other packages (GUI/Desktop related).

Background: name of the package task-desktop can be found by running following tasksel commands:

tasksel --list-tasks
tasksel --task-packages desktop
share|improve this answer

Alternatively, you can try this Raspbian minimal image: http://www.linuxsystems.it/raspbian-wheezy-armhf-raspberry-pi-minimal-image/

share|improve this answer
1  
Doesn't answer the question at all. The question was how to uninstall X, not how to install a new OS without X. This would have best been left as a comment, try asking your own question or providing a useful answer to get the rep needed to leave a comment. Nice link none the less. –  Impulss Nov 20 '13 at 2:49

Another option is to use aptitude which you should always prefer, if you're going to do more than just install or remove a few packages.

Start aptitude as root by typing sudo aptitude. In the standard Packages view of aptitude the last list entry is Tasks in which you can select the various options listed by tasksel. Navigate through the items with j, k and enter. Mark an item to be purged by entering _ (underscore) on the highlighted item. This only prepares actions. To execute the actions press g.

Read about aptitude in the debian manual.

share|improve this answer

1/. To remove all desktops I just did (go make a pot of coffee. Take a walk this will take a while)...
apt-get remove --dry-run --auto-remove --purge libx11-.*

2/. Then I installed deborphan to get rid of orphaned files...
sudo apt-get install deborphan

If you want to see what has been orphaned do this...
deborphan -sz

3/. Then I removed all orphaned files...
sudo apt-get remove --purge $(deborphan)

Finally do this to remove the unnecessary packages that are not orphaned...
sudo apt-get autoremove

Final result: Headless and clean as a whistle

share|improve this answer
1  
apt-get remove --dry-run does absolutely nothing, but prints messages on the screen. –  lenik Jun 16 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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