How to Check Available Package Versions in Ubuntu Using apt-cache madison

When managing software packages on Ubuntu, system administrators and developers often need to inspect all available versions of a specific package across configured repositories before initiating an installation, rollback, or APT version pin. While apt-cache policy displays installed and candidate versions along with repository pin priorities, it can produce extensive, verbose output. To obtain a concise, tabular summary of package versions and their originating repository URLs, Ubuntu administrators rely on a dedicated command: apt-cache madison.

What Is apt-cache madison in Ubuntu?

The apt-cache command interfaces directly with the local Advanced Package Tool (APT) cache generated from repository index files. The madison subcommand is a native APT implementation of the Debian archive management tool used on the Debian project server (known historically as “dak madison”). In Ubuntu, running apt-cache madison <package_name> parses your cached package records and presents every available binary or source version in a clear, pipe-delimited table format.

Why Use apt-cache madison?

Using apt-cache madison offers several distinct operational benefits:

  • Concise Tabular Overview: Quickly view package names, exact version strings, repository URLs, component sections (such as main, universe, or updates), and system architectures on single lines.
  • Pre-Installation Version Verification: Verify whether security backports, PPAs (Personal Package Archives), or proposed updates contain newer or patched releases without running a live network query.
  • Syntax Extraction for APT Pinning: Copy exact version strings directly from the output to specify strict installation requirements via apt-get install <package>=<version>.
  • Fast Local Execution: Because the utility queries the locally cached indices in /var/lib/apt/lists/, it runs instantly without network latency.

Basic Syntax and Usage

The standard syntax for querying available package versions is straightforward:

apt-cache madison <package_name>

Before querying package versions, ensure your local APT database is synchronised with the upstream mirrors:

sudo apt update

Inspecting Available Package Versions

To inspect the available versions for a common utility such as the Nginx web server, execute:

apt-cache madison nginx

The output resembles the following structured layout:

     nginx | 1.24.0-2ubuntu7.1 | http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
     nginx | 1.24.0-2ubuntu7   | http://archive.ubuntu.com/ubuntu noble/main amd64 Packages
     nginx | 1.24.0-2ubuntu7   | http://archive.ubuntu.com/ubuntu noble/main Sources

Each line is divided into three distinct columns separated by vertical bars:

  1. Package Name: The official canonical package identifier.
  2. Exact Version String: The full Debian/Ubuntu version number, including epoch, upstream release, and distribution patch revisions.
  3. Repository Origin: The mirror archive URL, the suite/component classification (e.g., noble-updates/main), the target CPU architecture, and whether the record represents binary packages or source trees.

Checking Multiple Packages Simultaneously

You can query several packages in a single execution by appending multiple package names to the command:

apt-cache madison curl openssl git

The utility evaluates each package sequentially, listing all matching records. This makes it effortless to audit dependencies and interrelated libraries when planning system maintenance.

How to Install an Exact Package Version Listed by madison

Once you identify the required version from the apt-cache madison table, pass the exact version string to the apt install command using an equals sign (=):

sudo apt install nginx=1.24.0-2ubuntu7

APT will resolve dependencies and lock the installation to that specific release. To prevent unattended upgrades or routine updates from replacing this version, hold the package using:

sudo apt-mark hold nginx

apt-cache madison vs apt-cache policy

While both subcommands inspect package availability, they serve different administrative purposes:

  • Use apt-cache madison: When you need a quick, readable summary of available versions and repository locations formatted for parsing or rapid reading.
  • Use apt-cache policy: When you need to inspect the currently installed version, the candidate version chosen by the package manager, and the numerical repository pinning priorities (Pin-Priority weights).

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.