brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: apt autoremove --purge also deletes the leftover config files

Apt
~/tips/tip-ubuntu-apt-autoremove-purge

sudo apt autoremove --purge

Removes unused dependency packages together with their leftover configuration files.

Plain apt autoremove clears out dependencies that nothing needs anymore. It leaves their config files behind.

sudo apt autoremove --purge

The man page says --purge makes removals use purge instead of remove, which deletes the configuration files as well. Over a few years of installing and removing things, that adds up to a lot of stale files in /etc.

I look first. Run it once with the simulate flag:

apt-get -s autoremove --purge

Read the list. If a package in there surprises me, I stop and ask why apt thinks it is unused. Usually it was pulled in as a dependency of something I removed. Sometimes it is a thing I installed by hand and never marked as manual, and then apt-mark manual saves it.

Run it after a big cleanup too. Removing a desktop app tends to leave a long tail of libraries behind, and this is the command that sweeps them up.

Caveat: purge is permanent. If you ever want that package back with your old settings, you will not get them. Take a copy of any config you care about first.

Further reading: apt-get(8) man page (Ubuntu 24.04), On this site: apt changelog shows why a package wants to update, On this site: –no-install-recommends stops apt from dragging in extras

More Apt tips sudo apt-mark minimize-manual apt list '~c' grep -E ' (install|upgrade|remove) ' /var/log/dpkg.log | tail -o Dpkg::Options::="–force-confold" upgrade sudo apt-get -d -y full-upgrade All Apt tips (42) All topics

Link