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 policy tells you which version you get and where it comes from

Apt
~/tips/tip-ubuntu-apt-policy

apt policy nginx

Shows the installed version, the candidate version and which repository each comes from.

When apt installs something older than the website says is current, I do not guess. I ask it.

apt policy nginx

The output has an Installed line, a Candidate line and a table of every version apt knows about. Next to each version is the repository it lives in, with a priority number. The Candidate is what apt install would pick.

This answers questions that otherwise eat an evening. Is the package not installed at all, or just not found? Is a newer version sitting in a PPA that I have disabled? Did the security pocket get something the main pocket did not? You see it in one screen.

Example: you read that a tool is at version 2.x, but Ubuntu 24.04 gives you 1.x. apt policy shows the 1.x candidate and that nothing newer exists in your enabled sources. That is not a bug. Ubuntu freezes versions per release and only patches them.

I also use it to check whether a PPA is overriding the Ubuntu version. The priority numbers show which source wins.

Caveat: it only knows what your last apt update fetched. Run that first, or you are reading old data.

Further reading: apt(8) man page (Ubuntu 24.04), On this site: apt autoremove –purge also deletes the leftover config files, On this site: apt changelog shows why a package wants to update

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