Weed unnecessary Debian packages with debfoster

debfoster

From the man page:

debfoster maintains a list of installed packages that were explicitly requested rather than installed as a dependency.

After months of use, I end up with a lot of packages that I don't need, that I installed to build something, or just to try to solve a specific problem (that I no longer have). But it's very difficult to keep track of those packages.

Of course, we have apt-get autoremove and deborphan, but it's difficult to whitelist packages in those tools.

Here comes debfoster to the rescue. The usage is very simple, you just need to run it and interactively mark the packages that you want to keep.

For example:

sudo debfoster

imagemagick is keeping the following 10 packages installed:
  gsfonts imagemagick-6-common imagemagick-6.q16 libjxr-tools
  liblqr-1-0 libmagickcore-6.q16-6 libmagickcore-6.q16-6-extra
  libmagickwand-6.q16-6 libnetpbm11 netpbm
Keep imagemagick? [Ynpsiuqx?], [H]elp:

If you enter y, debfoster will remember that you keep that package.

If you enter n, debfoster will delete imagemagick and all the dependencies.

How it works? It keeps the whitelist of wanted packages in a plaintext file, so it's very easy to edit it and remove previously whitelisted packages:

$ cat /var/lib/debfoster/keepers
apt-xapian-index
build-essential
colordiff
(...)

Available options

These are the available options (reported by entering H):

  Yes        Keep imagemagick. [default]
  No         Delete imagemagick.
  Prune      Delete imagemagick and the packages it is keeping installed.
  Skip       Skip this question.
  Help       Print this message.
  Info or ?  Show information about imagemagick.
  Undo       Undo last response.
  Quit       Exit without removing packages.
  Exit       Remove unwanted packages and exit.
0
Subscribe to my newsletter

Read articles from Horacio G. de Oro directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Horacio G. de Oro
Horacio G. de Oro

Developer; SRE; Security; Agile