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 auto lets apt autoremove clean up packages you no longer need

Apt
~/tips/tip-apt-mark-auto

sudo apt-mark auto build-essential libssl-dev

Marks packages as dependencies so autoremove can remove them when nothing needs them.

apt only autoremoves packages it installed as dependencies. Everything you installed by name stays forever, even helper libraries you only needed once. apt-mark auto moves them to the other pile.

Mark the package, then see what autoremove would do:

sudo apt-mark auto build-essential libssl-dev
apt-mark showauto | grep libssl-dev
sudo apt -s autoremove

From now on apt treats these as dependencies. If another installed package still needs them, they stay. If nothing does, the next apt autoremove takes them away.

I find this handy after compiling something from source. You install a list of -dev packages to build it, and once it’s built they just sit there. Marking them auto means a later autoremove cleans them up without you keeping a list.

The reverse is apt-mark manual. That one is worth knowing too: if autoremove wants to remove something you use directly, like curl pulled in by another package, mark it manual and it stays.

Always run the simulated autoremove first. Marking something auto that nothing depends on means it goes on the next autoremove, and some packages are things you use every day without ever having asked for them by name. Read the list before you confirm.

Further reading: apt-mark(8) manual page

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