Cleaning cruft in a Ubuntu installation

I have been running Linux on my laptops for as long as I have been owning laptops. My current one has been through quite a few versions of Ubuntu Linux. There are normally no big changes from version to version, but it steadily improves. In that process some software packages that previously were installed by default are replaced or become obsolete. Most of this software is still updated, but it is no longer present on new installations and it may have no value to me.

Every time I update to a new version of Ubuntu I have a feeling that the cruft is building up, but there is no obvious way that I have found to remove software that has no longer been found worthy of being part of the default install. So, this time I decided to write a script to identify these packages. The script takes a list of software packages to keep, i.e the software that I use directly when I use my machine. From this list it finds all the packages that must be present for my prefered software to work, and lists all the other that can in princible be removed.

In reality, it is hard to come up with a list of all the software that is required for a Ubuntu installation to work properly, so I also made the script read the newest list of default packages. Any of these that happen to be installed are also kept along with their dependencies.

The script itself, unnecessarry-packages.py can be found on Bitbucket. It does not uninstall any packages by itself, but suggest packages that you can uninstall by running apt purge PCKGNAME or similar. I put it online and write about it here in the hope that it will be useful to someone else.

I started out with the following list of packages to keep,

python3 unnecessarry-packages.py ubuntu-desktop krita thunderbird firefox ubuntu-minimal digikam gimp darktable gedit Downloads/ubuntu-16.10-desktop-amd64.manifest -v

and after some trial and error I ended up with the following by noticing packages suggested for removal that I in reality wanted to keep and adding them to the command line invocation,

python3 unnecessarry-packages.py ubuntu-desktop krita thunderbird firefox ubuntu-minimal digikam gimp darktable gedit clang bcmwl-kernel-source systemsettings enfuse ffmpegthumbs flashplugin-installer gstreamer1.0-nice gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-faad  gstreamer1.0-plugins-bad-videoparsers gstreamer1.0-plugins-ugly gstreamer1.0-plugins-ugly-amr hugin hugin-tools inkscape gimp-ufraw git  gmsh gphoto2 gstreamer1.0-libav gimp-plugin-registry  ttf-mscorefonts-installer mercurial kipi-plugins gimp-gmic sshfs Downloads/ubuntu-16.10-desktop-amd64.manifest -v

This allowed me to get rid of approximately 4 GB of cruft without any noticeable problems afterwards. Note that I did not blindly remove all packages suggested by the above final invocation, but I removed maybe 90% of them. The script is not smart, it can easily suggest that you remove your network driver, so use with caution!

Yay!

Hoarfrost / Yay!

Tagged as: Code Python Ubuntu Debian apt