Skip to main content How to uninstall desktop environments installed with tasksel? : r/debian

How to uninstall desktop environments installed with tasksel?

I'm playing around with different DEs in a VM. I assumed that unchecking the DE in tasksel would uninstall it completely, but apparently it doesn't.

I try for example to uninstall the task-lxde-desktop package but it still leaves packages like lxde, lxde-session and openbox installed. apt autoremove doesn't remove those.

Is there an easy way to completely uninstall DEs or is this a limitation on how metapackages work in Debian?

See how different U.S. Air Force aircraft work together to accomplish missions, and get a sneak peek at the mobile flight game, Command The Stack.
Thumbnail image: See how different U.S. Air Force aircraft work together to accomplish missions, and get a sneak peek at the mobile flight game, Command The Stack.
Sort by:
Best
Open comment sort options

It's a limitation on how circular "Recommends" dependencies limits the ability of apt to recognise that packages are unused.

Basically, packages aren't uninstalled if other packages depend on them. If you install foo which depends on libfoo, and then install bar which also depends on libfoo, if you later delete foo then you don't want libfoo to be uninstalled because that would break bar.

The problem is that if foo depends on bar and baz, and bar and baz both depend on each other, if you remove foo then neither bar nor baz will will be recognised as a candidates for removal because they both have packages that depend on them - each other. Now, Debian policy 7.2 strongly recommends against creating circular "Depends" relationships between packages because of the issues it can cause, but circular "Recommends" relationships (or where foo depends on bar, and bar recommends foo) are not discouraged - and are actually quite common. But circular "Recommends" also inhibit automatic removal - which is likely what is happening here.

I've thought it might be nice if apt autoremove had an option where it could find groups of packages where none of them were manually installed, and there is no "Depends" or "Recommends" relationship from any manually installed package to any package in the group.

But on top of that, there is the virtual package issue where if foo has a dependency like kwin | x-window-manager, and you install openbox which provides x-window-manager, then I think that even if you have kwin installed then openbox won't be a candidate for removal because it provides a virtual package that is depended on by another package.

Basically, apt errs on the side of keeping anything it thinks another package on your system might need, unless you specifically tell it otherwise. Which I think is pretty sensible.

}

What a bummer. I thought that if you install a metapackage, it should be equally easy to revert back to the former state by removing it.

I tried using apt-get purge -o Apt::AutoRemove::RecommendsImportant=false --autoremove openbox but it seems to want to delete stuff related to other desktop environments as well.

Other distros really handle this better.

}
Edited

Agreed. This is really the only major complain from me. Every time I install Debian I have to carefully plan for what I install (with --no-install-recommends).

The only really reliable way of uninstalling something in Debian is to track down /var/log/apt/history*, and purge packages from the buttom until the step of the target package, then re-install any leaf package which was installed later than the package removed. If at a later stage I decide it to be too much harassment to retract installations by tracking /var/log/apt/history* step by step then I'd just nuke the whole installation of Debian and reinstall it, so that I can get rid of the sick feeling of being bloated when I try to remove something.

pacman -Rs for Arch and apk del for Alpine both do a very job at uninstalling packages without bloat leftover.

}
More replies
More replies

aptitude why lxde

}

I recently switched from LXDE to Cinnamon, I logged out, ctrl+alt+F1 for text terminal and ran:

$ sudo -s
# apt purge task-lxde-desktop && apt autoremove
# apt purge `dpkg -l | cut -d ' ' -f3 | grep lxde` && apt autoremove
# apt install task-cinnamon-desktop
}

I suppose best way is "apt-get remove --purge <package>*" for example:

apt-get remove --purge lxde*

should remove package and all the config files.

}

In the same vein, there's apt purge <package> and also apt autopurge, which is the same as apt autoremove --purge

}
More replies

The easiest way to figure out this sort of thing is through aptitude, which allows you to easily browse through the dependencies and reverse dependencies of packages. Recursively, even. You can remove the packages you're sure you want to get rid of, and mark as dependency-only the packages you're not sure of that somehow don't already have that mark. All quickly and interactively.

Figuring out virtual dependencies, where you may have multiple packages that all Provide the same virtual package name and you only need one, is the trickiest bit. But even there, aptitude can make it a lot easier, as it actually does allow you to browse virtual packages!

}
Profile Badge for the Achievement Top 1% Commenter Top 1% Commenter

Just save state before, and remove the added packages after.

E.g.:

$ dpkg --get-selection | awk '{if($2=="install")print $1;}' | sort -u > before
...
# apt-get -y purge $(awk '{if($2=="install")print $1;}' | sort -u | comm -23 - before)

Can also extract the information from /var/log/dpkg.log* file(s) if necessary.

}