Last week we learned how to identify cruft on your Debian system. This week, for the last article in this series, we’ll learn more about automatically installed packages and how to get rid of them when you don’t need them any longer.
APT tracks automatically installed packages
When you install a new package with apt-get/aptitude/synaptic, it’s very common to end up installing many more packages: those are the dependencies of the installed package. Here’s an example:
$ sudo apt-get install pino [...] The following extra packages will be installed: libdbusmenu-glib1 libgee2 libindicate4 libnotify1 notification-daemon The following NEW packages will be installed: libdbusmenu-glib1 libgee2 libindicate4 libnotify1 notification-daemon pino 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 478 kB of archives. After this operation, 2531 kB of additional disk space will be used. Do you want to continue [Y/n]?
After this installation, the 5 “extra packages” will be marked as “automatically installed”. What does this mean? It means that you have not explicitly requested their installation and that the system should be free to remove them as soon as they are no longer needed.
You can verify that this is effectively the case with “apt-mark showauto” (it returns a list of the automatically installed packages).
$ apt-mark showauto |grep libdbusmenu libdbusmenu-glib1 $ apt-mark showauto |grep pino $
Aptitude shows this information with the “A” letter in its interactive interface and in the “aptitude search” output. “aptitude show” has a dedicated field for this:
$ aptitude show libdbusmenu-glib1 Package: libdbusmenu-glib1 New: yes State: installed Automatically installed: yes Version: 0.3.7-1 [...]
In Synaptic, it’s not very visible but once you have selected an installed package, you can verify in the “Package” menu whether “Automatically installed” is checked or not.
APT tells you which packages are no longer needed
Over time, some of those automatically installed packages become unnecessary because the packages that depended on them no longer do. It might be that they are using a newer version of the same library, or they switched to use something else, or they are able to do the task themselves.
Whatever the reason, the original dependency has vanished and the automatically installed package is no longer needed on the system.
Aptitude will automatically remove those unneeded packages the next time you run it but apt-get and synaptic do not.
Apt-get will inform you that some packages are no longer needed and will even tell you how you can get rid of them:
$ sudo apt-get remove pino [...] The following packages were automatically installed and are no longer required: notification-daemon libdbusmenu-glib1 libnotify1 libgee2 libindicate4 Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: pino 0 upgraded, 0 newly installed, 1 to remove and 219 not upgraded. After this operation, 1225 kB disk space will be freed. Do you want to continue [Y/n]? [...] $ sudo apt-get autoremove [...] The following packages will be REMOVED: libdbusmenu-glib1 libgee2 libindicate4 libnotify1 notification-daemon 0 upgraded, 0 newly installed, 5 to remove and 219 not upgraded. After this operation, 1307 kB disk space will be freed. Do you want to continue [Y/n]? [...]
Synaptic will show you the packages that can be removed in a new section name “Installed (auto removable)” if you select the “Status” button in the bottom-left pane.
It’s thus a good habit to get rid of those unneeded package from time to time.
Use this feature to trim down your system
While APT usually sets the “Automatically installed” flag, you can also set it manually. It’s a very simple way to tell the system “I don’t need this package directly, feel free to remove it if nothing else requires it”.
# With apt-get $ sudo apt-mark markauto libxml-simple-perl # Or with aptitude $ sudo aptitude markauto libxml-simple-perl
You can also do it in the interactive interface of aptitude with the key “M” (and “m” for unmarking). To do it in Synaptic, you have to use the menu entry “Package > Automatically installed”.
Many users like to have a minimal set of packages installed but they don’t really know which packages are really important and trying to remove every package to look what happens is cumbersome.
Thanks to this feature, you don’t try removing packages but you flag them as automatically installed. There is few risks in doing so when it concerns libraries (including python/perl modules). If the package is not indirectly needed by one of your important packages, it will be removed by apt-get autoremove, otherwise it’s kept for as long as it’s needed.
I would suggest to not mark as such packages of priority higher or equal to important to avoid nasty surprises (although I say this to not be blamed in case you remove too much, in theory the system should not remove essential components and all dependencies should be complete).
Also be aware of the consequences when you mark “task” packages like “gnome” as automatically installed… it will suggest you to remove your whole desktop. If you want to trim down the default desktop, you should “unmark” the desktop packages that you want to keep:
$ sudo apt-mark unmarkauto gnome-session gnome-panel
Do you want to read more tutorials like this one? Click here to subscribe to my free newsletter, you can opt to receive future articles by email.