Skip to Content

Check which APT repo is being used

Learn how to check which APT repo is being used

karchunt

Kar Chun Tan

Creator

Metadata

Sat May 10 2025

2 min read

239 words

How to check which APT repo is being used

When you have multiple APT repositories configured for the same software, it’s important to know which one is being used. This is especially relevant when you have added a new repository but the system still uses an older one.

Check the Pinned Priority

APT uses the repository with the highest priority. You can check the priority of each repository using the following command:

apt-cache policy

In this example, we will be looking for the docker-ce package (or any Docker-related package) in the output. It will show the repository URL and its priority. For example:

apt-cache policy docker-ce

Sample output:

docker-ce: Installed: (none) Candidate: 5:20.10.24~3-0~ubuntu-jammy Version table: 5:20.10.24~3-0~ubuntu-jammy 500 500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages 5:20.10.24~3-0~ubuntu-focal 500 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

The Candidate version indicates which repository is being used.

Inspect the installed package

If Docker is already installed, you can check the version and match it to the repository:

apt-cache policy docker-ce

The output will show the installed version and the repository it came from.

Manually check the repository

If you want to ensure only one repository is used, you can comment out or remove the unwanted entry in /etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list. For example:

sudo nano /etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list

Comment out the line for focal if you want to use jammy:

# deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable

Then update the package cache:

sudo apt update

Verify the repository again

After making changes, verify the repository being used:

apt-cache policy docker-ce

This will ensure that the correct repository (jammy in this case) is being used.

Last updated on