How to uninstall all but the default Ubuntu packages?

Solution 1:

The solution to this question will probably solve your problem too.

Ubuntu pre-12.04

From a gnome-terminal do:

cat filesystem.manifest-desktop | awk '{print $1}' | sort > default.txt

This will get rid of the package versions and leave you with a sorted list default.txt containing all packages that are installed by default. As mentioned in the linked question, keep in mind that you might changed the default installation when installing updates and/or restricted packages during the installation of Ubuntu.

Ubuntu 12.04

The above step has changed a bit. To get a list of the packages that are initially installed, you need to unpack two files:

  1. filesystem.manifest
  2. filesystem.manifest-remove

To get what you want, you need to remove the latter from the former:

comm -3 <(cat filesystem.manifest | awk '{print $1}' | sort) <(cat filesystem.manifest-remove | sort) > default.txt

Now continue like pre-12.04:

dpkg --get-selections | awk '{print $1}' | sort > current.txt

This will get you a sorted list current.txt of all currently installed packages.

diff -u default.txt current.txt | grep "^+[^+]" | cut -c 2- > installed.txt
diff -u default.txt current.txt | grep "^-[^-]" | cut -c 2- > uninstalled.txt

This will get you the differences between the two package lists, where installed.txt contains all packages not part of the default installation, and uninstalled.txt contains all packages you are missing compared to a default installation.

Solution 2:

If you insist on removing those packages manually you can fire up Ubuntu Software Center or even good old but slighly more risky Synaptic, browse the 'installed' section and start removing whatever you think you do not need. That can include all the old programs but even programs that are in your current install but you never will use.

I bet it will be an odd 10 or so you want to remove and that might take you a 15 minutes,