APT repositories store package metadata that determines what software is available for installation on Debian-based distributions such as Ubuntu, Linux Mint, Kali, etc. In some situations, it is useful to view every package published by a specific repository, whether for auditing, package discovery, or troubleshooting purposes. This tutorial explains how to get all available packages from APT repository.
APT stores downloaded repository index files under the /var/lib/apt/lists directory. These files contain package information retrieved during the last apt update operation and can be examined directly to obtain package names.
To view the package index files currently available on the system, run:
ls /var/lib/apt/lists/*_Packages
The command displays all downloaded package index files, with each file corresponding to a particular repository component and architecture. For example:
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_resolute-updates_main_binary-amd64_Packages
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_resolute-updates_multiverse_binary-amd64_Packages
/var/lib/apt/lists/ppa.launchpadcontent.net_git-core_ppa_ubuntu_dists_resolute_main_binary-amd64_Packages
For example, to extract package names from the Git Core PPA package index:
grep -Po '^Package: \K.*' /var/lib/apt/lists/ppa.launchpadcontent.net_git-core_ppa_ubuntu_dists_resolute_main_binary-amd64_Packages | sort -u
Example output:
git
git-all
git-cvs
git-daemon-run
git-daemon-sysvinit
git-doc
git-email
git-gui
gitk
git-man
git-mediawiki
git-svn
gitweb
In this example, grep searches for lines beginning with Package: and prints only the package name portion. The sort -u command sorts the results alphabetically and removes duplicate entries. Duplicate entries can occur because the same package name may appear multiple times within the repository metadata, often due to multiple available versions. The resulting list represents all packages currently available from the selected repository index file.
Leave a Comment
Cancel reply