As times goes by and ubuntu releases arrive i keep updating my good old home server and laptop. This leaves behind removed packages with remaining files.
These are my steps to keep ubuntu nice and tidy. I don't do this often, so i'm writing it here to remember on my next LST upgrade.
The first util is deborphan, deborphan finds packages that have no packages depending on them. Which makes them a perfect candidate for removal. As usual, read the deborphan man page before start using it
sudo apt install deborphan
deborphan
This will list packages that according to deborphan (you might want to double check this) are not needed. To remove the packages you can run
sudo apt remove $(deborphan)
For example, this is what i get on my server
$ deborphan
libkrb5-26-heimdal
libpython3.5
And to remove all orphan packages i run sudo apt remove $(deborphan)
$ sudo apt remove $(deborphan)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
libkrb5-26-heimdal libpython3.5
0 upgraded, 0 newly installed, 2 to remove and 2 not upgraded.
After this operation, 5,309 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 185217 files and directories currently installed.)
Removing libkrb5-26-heimdal:amd64 (7.7.0+dfsg-3ubuntu1) ...
Removing libpython3.5:amd64 (3.5.2-2ubuntu0~16.04.4) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
You might want to do this a couple of times. As you remove packages new pacakages might become "orphans".
$ deborphan
libhx509-5-heimdal
The next thing is to purge removed packages with remaining files. To do this you need to list packages with dpkg --list
and identify the removed packages with remaining configuration, firs column = rc
$ dpkg --list | grep ^rc
rc acl 2.3.1-1 amd64 access control list - utilities
rc adwaita-icon-theme 3.28.0-1ubuntu1 all default icon theme of GNOME (small subset)
rc alsa-utils 1.2.6-1ubuntu1 amd64 Utilities for configuring and using ALSA
rc apt-cacher-ng 3.1-1build1 amd64 caching proxy server for software repositories
rc at-spi2-core 2.28.0-1 amd64 Assistive Technology Service Provider Interface (dbus core)
rc aufs-tools 1:4.14+20190211-1ubuntu1 amd64 Tools to manage aufs filesystems
rc certbot 0.40.0-1ubuntu0.1 all automatically configure HTTPS using Let's Encrypt
rc cgroupfs-mount 1.4 all Light-weight package to set up cgroupfs mounts
rc colord 1.3.3-2build1 amd64 system service to manage device colour profiles -- system daemon
rc consolekit 0.4.6-5 amd64 framework for defining and tracking users, sessions and seats```
As we are interested in the package name, se will run this to get all the package names
dpkg --list | grep ^rc| cut -d ' ' -f 3
And finally purge everything
sudo apt purge $(dpkg --list | grep ^rc| cut -d ' ' -f 3)
Enjoy!
Leave me a comment below if your are doing anything else to keep your linux clean.
gnzsnz