Debian Package Pinning: Controlling Which Repository Versions Are Used

APT pinning gives fine-grained control over which repository/version APT prefers for specific packages — useful when mixing sources (like Backports) or preventing specific packages from being upgraded past a certain version.

Why Pinning Matters

Without pinning, APT resolves version conflicts using default priority rules that might not match your actual intent — especially relevant once you've added additional repositories (Backports, third-party sources) alongside the standard Debian repositories.

Understanding APT Priority Numbers

PriorityEffect
1000+Install even if it's a downgrade from currently installed version
990Default priority for the current/target release
500Default priority for other available sources
100Default priority for Backports
Below 0Never install this version

Creating a Pin Configuration

sudo nano /etc/apt/preferences.d/backports
Package: *
Pin: release a=bookworm-backports
Pin-Priority: 100

This matches the default backports priority — explains why you need -t bookworm-backports to explicitly opt into backported packages rather than them being installed automatically.

Pinning a Specific Package to a Higher Priority

Package: nginx
Pin: release a=bookworm-backports
Pin-Priority: 500

Raises priority specifically for Nginx from backports, making APT prefer the backported version for this package automatically without needing -t each time, while other packages remain unaffected.

Pinning a Package to Prevent Upgrades

Package: critical-app
Pin: version 2.5.1-1
Pin-Priority: 1001

Locks a specific package at an exact version, preventing any upgrade even during a general apt upgrade — useful if a newer version has a known compatibility issue with your specific setup.

Checking Current Pin Priorities

apt-cache policy PACKAGE_NAME

Shows the effective priority for each available version, helping you verify your pinning configuration is actually working as intended.

An Alternative to Pinning: apt-mark hold

sudo apt-mark hold PACKAGE_NAME

A simpler mechanism for the common case of just preventing a specific package from upgrading at all — see How to Use apt/dpkg Effectively: Package Management Deep Dive; use full pinning when you need more nuanced priority control across sources, not just a simple hold.

Common Pinning Mistakes

  • Setting priorities too high broadly, causing unexpected automatic upgrades to less-tested repository versions
  • Forgetting a pin exists, leading to confusion later about why a specific package isn't updating as expected
  • Overly complex pinning configurations that become difficult to reason about over time

Common Errors

Pin doesn't seem to take effect — verify the pin file syntax is correct and run apt-cache policy to confirm the actual effective priority, since a syntax error in the pin file can cause it to be silently ignored.

Continue Reading

Browse more articles in Debian VPS Tutorials.

  • debian apt pinning, apt preferences, pin-priority debian, control package versions debian
  • 0 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

What Is Debian? Advantages, Disadvantages, and Debian vs Other Linux Distributions

Introduction Debian is one of the oldest, most stable, and most trusted Linux distributions...

Debian VPS vs Ubuntu VPS: Which One Should You Choose?

Introduction When ordering a VPS, one of the first decisions you'll make is choosing the...

Top 10 Reasons to Choose a Debian VPS for Your Server

Introduction Debian has earned a reputation as one of the most reliable Linux operating systems...

Top 10 Applications You Should Install on a Debian VPS

Introduction One of Debian's greatest strengths is its enormous software repository and...

How to Upgrade Debian 11 to Debian 12 (Complete Step-by-Step Guide)

Introduction Upgrading your Debian VPS to the latest stable release ensures better security,...