Removing alternative Ubuntu flavors completely

When Ubuntu users want to try other Ubuntu flavors, e.g. Xubuntu and Lubuntu, they usually just install their meta packages:

$ sudo apt-get install xubuntu-desktop

or

$ sudo apt-get install lubuntu-desktop

apt-get can install their dependencies automatically. However, when users want to remove the alternative Ubuntu flavors completely, they are out of luck, because inter-dependencies among many packages can be rather complex, and apt tools simply does not automatically remove the dependencies of meta packages.

A nice solution to this problem is to find out installed packages by parsing the dpkg log file: /var/log/dpkg.log. Of course, the prerequisite is that you still have the log of your *ubuntu meta package installation session lying around.

I installed Xubuntu between “2015-09-26 20.12.30” and “2015-09-26 20:18:03” last night. The dpkg log of the installation session goes as follows:

If you feed the above output to apt-get through a pipe via xargs, apt-get would simply abort after pompting for confirmation, because its standard input is already connected to the pipe by xargs, and it cannot read key stokes from the terminal. Therefore, I had to copy and paste the output into a separate “apt-get purge” command:

Adding the “-y” option to the apt-get command, which causes apt-get to run non-interactively, is also feasible, but it’s not recommended unless you’ve confirmed what packages apt-get is going to remove.

If you have installed other Ubuntu flavors, you’d better re-install their meta packages to make sure their dependencies are met, because the “apt-get purge …” command above could have removed their dependencies: