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 hold keeps one package on the version you have

Apt
~/tips/tip-ubuntu-apt-mark-hold

sudo apt-mark hold postgresql-16

Freezes one package at its current version while everything else keeps updating.

Sometimes one package has to stay exactly as it is. A database version you have not tested against, a driver that finally works. The rest of the system can still update.

apt has a switch for this:

sudo apt-mark hold postgresql-16
apt-mark showhold
sudo apt-mark unhold postgresql-16

According to the man page, a held package is not automatically installed, upgraded or removed. showhold lists what you have pinned, which matters more than it sounds. A hold you forgot about is a security update you are quietly skipping.

The example uses PostgreSQL because that is a classic case, but any package name works. Use the real name from dpkg -l, not the name of the program.

Pair it with a habit: when you hold something, write down why. Future me never remembers.

My caveat: a hold does not expire, and apt will not nag you about it. If I set one, I put a reminder in my calendar to look at it again. Also, other packages that depend on a newer version can end up held back or refused, so read apt’s messages when it complains.

Further reading: apt-mark(8) man page (Ubuntu 24.04), On this site: apt changelog shows why a package wants to update, On this site: apt policy tells you which version you get and where it comes from

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