Stop apt from pulling in random crap from unknown repos
Package Management (Apt/Dnf/Pacman Internals)
Stop apt from pulling in random crap from unknown repos
🧩 The Challenge
Ever gone to `apt upgrade` and seen it trying to pull in some weird version of a package, or worse, a package from a repo you barely remember adding? You sit there, staring at the `apt` output, wondering why it’s making *that* choice. And sometimes, it just silently does it, breaking something later. I’ve wasted hours figuring out why some core library suddenly got downgraded because of an old PPA.
💡 The Fix
Don’t guess. Ask `apt` directly where it’s getting its package versions from and what its priorities are. There’s a command that shows you exactly what repositories are active for a package, what versions are available, and *why* `apt` prefers one over another.
apt-cache policy <package_name>
⚙️ Why It Works
This command dumps `apt`’s internal decision-making process for a specific package. It lists all available versions across all your configured repositories, their priority scores, and which one `apt` would pick. Higher numbers mean lower priority, with `100` being default and `500` common for stable. Seeing the priorities helps you understand why that weird version got chosen.
🚀 Pro-Tip: For a system-wide view of all your apt sources and their default priorities, just run `apt-cache policy` without a package name. Useful for debugging unexpected repo interactions.
Linux Tips & Tricks | © ngelinux.com | 10/28/2026
