How To List All Packages In A Repository On Ubuntu, Debian Or Linux Mint [APT]

This article explains how to list all the packages available in an Ubuntu, Linux Mint or Debian repository (installed and available for install), be it an official repository or a third-party source like a PPA, and so on.

Below you'll find 2 ways of listing packages from a repository: using a GUI or from the command line.

From the same series:


List all packages in a Debian, Ubuntu or Linux Mint repository using a GUI


If you want to list all the packages in a repository on your desktop, you can use Synaptic Package Manager.

Synaptic is a graphical package management application for APT (APT being the main command line package manager for Debian and its derivatives).

If you don't have Synaptic installed, you can install it on Debian, Ubuntu, and any Debian or Ubuntu based Linux distribution, including elementary OS, Linux Mint and so on, by using this command:

sudo apt install synaptic

To list all the packages in a particular software repository using Synaptic, launch the application and click on Origin in the bottom left-hand side of its window. Next, select the repository for which you want to list all available packages (both installed and available for installation) from the list that's displayed in the left-hand side of Synaptic Package Manager.

For example, here's Synaptic showing all the packages available in the Google repository, listing Google Chrome stable, beta and unstable, as well as Google Earth Pro and EC:

Synaptic list all packages in a repository on Ubuntu or Debian

As you can see, all the software sources are listed here, including the official repositories.

Launchpad PPA repositories are supported as well. Their name begins with LP-PPA, followed by the actual PPA name. Synaptic lists 2 entries for each PPA - make sure you select the PPA entry ending with /ubuntu-codename, for example /bionic, /cosmic, etc. The entry ending in /now doesn't list all the available packages in the PPA.

This is a screenshot showing all the packages available in the Ubuntu Graphics Drivers PPA (for Ubuntu 18.10 Cosmic Cuttlefish, since that's what I'm using), including showing which are installed on my system:

Synaptic list all packages in a repository

I'm not sure why, but some packages are listed multiple times for PPA sources (and only for PPA repositories). That only a display thing, and it doesn't break any functionality.

List all packages in a repository in Ubuntu, Debian or Linux Mint from the command line


Listing all packages in a repository from the command line in Ubuntu, Debian or Linux Mint is a bit tricky, but still quite easy to do.

There are multiple ways of doing this from the command, but I'll only list one. The command to list all packages available in repository-name is the one that follows:

grep ^Package /var/lib/apt/lists/repository-name*_Packages | awk '{print $2}' | sort -u

I'll explain later on how to find out the repository name from /var/list/apt/lists and how to use it. Before that I'll explain what this command does:

  • grep ^Package ... searches for lines beginning with ^Package in the /var/lib/apt/lists/*_Packages file
  • awk '{print $2}' prints the second column for each line (so it filters out everything but the package name)
  • sort -u sorts the lines and outputs only unique lines (removes duplicates)

The first thing you need to do is find the name of the repository *_Packages file from /var/lib/apt/lists/. You can list all the repository _Packages files available in /var/lib/apt/lists/ by using a simple ls:

ls /var/lib/apt/lists/*_Packages

Since the results may be very long, you can run the command output through more for easier reading:

ls /var/lib/apt/lists/*_Packages | more

If you know part of the repository name (I'm using KEYWORD in the command below as the name), you can filter the ls results using grep, like this:

ls /var/lib/apt/lists/*_Packages | grep KEYWORD

For example, let's say you want to list all the packages in the official Tor repository, and you know the repository name must contain tor. In this case, you'd use this command to find out the _Packages filename from /var/lib/apt/lists/

ls /var/lib/apt/lists/*_Packages | grep tor

For short queries, some unrelated repositories might be displayed, but it's still easier to see what you're looking for using grep than listing all the repositories _Packages files.

Now that you know the _Packages filename, you can list all the packages available in that repository by issuing this command:

grep ^Package /var/lib/apt/lists/some-repository-amd64_Packages | awk '{print $2}' | sort -u

Use the file containing the architecture for which you want to list all available packages in that repository. The example above is for 64bit (amd64), but you could use i386 for 32bit, etc.

You don't need the complete repository _Packages filename. Back to my Tor repository example, the _Packages filename for Tor is deb.torproject.org_torproject.org_dists_cosmic_main_binary-amd64_Packages. In this case, you could use deb.torproject followed by *_Packages to simplify things, like this:

grep ^Package /var/lib/apt/lists/deb.torproject*_Packages | awk '{print $2}' | sort -u

Which outputs the following:

deb.torproject.org-keyring
tor
tor-geoipdb

Another example. Let's say you want to see all packages available in the Linux Uprising Oracle Java 11 PPA (ppa:linuxuprising/java). You can list them by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net_linuxuprising_java*_Packages | awk '{print $2}' | sort -u

Which outputs this:

oracle-java11-installer
oracle-java11-set-default

To use this with other PPA repositories, replace linuxuprising with the first part of the PPA name, and java with the second part of the PPA name, and the command will list all the packages from that PPA (both installed and not installed).

You can also list all the packages available in all the PPA repositories you have added on your system, by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net*_Packages | awk '{print $2}' | sort -u

For easy access, you could bookmark this command using Marker commands bookmark manager (while used primarily for searching, HSTR can bookmark commands as well).

No comments: