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-mark minimize-manual marks metapackage dependencies as automatic

Apt
~/tips/tip-apt-mark-minimize-manual-metapackages

sudo apt-mark minimize-manual

Lets apt autoremove clean up dependencies of metapackages that were once marked manual.

After years of installing things, the list of manually installed packages on my systems is a mess, and apt autoremove can only clean what is marked automatic. This command shrinks that list.

sudo apt-mark minimize-manual

The man page says minimize-manual marks the (transitive) dependencies of metapackages as automatically installed. It suggests using it after an installation to reduce the number of manually installed packages. It can also be run continuously on systems managed by system configuration metapackages.

Here is how I’d use it. First look at what is marked manual:

apt-mark showmanual | wc -l
sudo apt-mark minimize-manual
apt-mark showmanual | wc -l
apt autoremove --dry-run

The first and third commands show how many packages dropped off the manual list. The last one only simulates, so you can read what autoremove would delete before anything is touched.

The caveat: once a dependency of a metapackage is automatic, apt may remove it as soon as nothing manual needs it. That is the point, but it also means a tool you use by hand and that happens to be a dependency of a metapackage can show up in the autoremove list. If you want to keep it, mark it again:

sudo apt-mark manual somepackage

The manual page does not say more about what happens to specific packages, so read the dry run output first. State is kept in the file extended_states in the directory set by Dir::State, unless you pass another file with -f.

Further reading: apt-mark(8)

More Apt tips 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 apt show nginx All Apt tips (42) All topics

Link