Debian

List All Installed Packages on Debian 11

This tutorial explains how to list all installed packages on Debian 11 Bullseye, previous and future versions, using different available techniques. It is also valid for Debian-based Linux distributions like Ubuntu.

By reading this tutorial, you will not only get simple instructions to list installed packages. You also will become more familiar with different package managers and their commands to administrate packages.

All instructions described in this tutorial include screenshots, making it easy for all Linux users to understand and follow them.

A Brief Introduction to Debian Package Managers

Before showing the practical techniques to list all packages on Debian, let’s introduce you to each.

The dpkg packages manager is the Debian base of all packages managers. Other known alternatives like apt or apt-get are frontends for dpkg, while aptitude is a frontend for apt.

The apt and apt-get frontends have important advantages over dpkg:

  • They can resolve dependencies.
  • They can install packages from the internet with a simple command.
  • They can provide information not only on local files but also on the remote.

The aptitude frontend is even better, including the following features:

  • It can resolve dependencies better than apt.
  • It informs how packages were installed (Manually or automatically).
  • It shows package changes in the system.
  • It offers both command line and interactive ncurses-based interfaces.

Listing All Installed Packages on Debian 11 Using dpkg/dpkg-query

This tutorial’s section explains how to list installed packages on Debian using both dpkg and dpkg-query tools.

The first command taught in this article will display a full list of all installed packages in our Debian 11 system using dpkg.

To do it, just run dpkg followed by the -l (list) flag, as shown in the screenshot below.

dpkg -l

As you can see, the command will display the following five columns explained below.

Understanding dpkg Output

  • The first column will show 2 characters showing the package’s status (In the previous screenshot, “i”). Each letter has its own meaning, where the first shows desired package status as explained in the first line of the output. Possible desired status include:
  • i: The package is chosen to be installed.
  • r: The package is chosen to be removed.
  • p: The package is chosen to be purged (Removed, including all related files and directories).
  • u: The package status is unknown.
  • h: The package is kept and not managed by dpkg.
  • The second character (in the screenshot below also “i”) shows the package’s current status. Therefore if the second character is “r” and the first character is “i,” the meaning is the package is currently installed but selected for removal by the user. There are 8 possible letters for a package’s current status:
  • i: The package is installed.
  • n: The package is not installed in the system.
  • c: The package is not installed, but its configuration files remain.
  • f: The system failed to remove configuration files.
  • u: The package is unpacked.
  • h: The package installation started but wasn’t installed for an unknown reason.
  • f: The package was unpacked and partially configured but not installed for an unknown reason.
  • w: The package is waiting to be triggered by another package.
  • t: The package has been triggered by another package.
  • The second column displays package names.
  • The third column shows package versions.
  • The fourth column shows package architecture.
  • Finally, the fifth column shows package descriptions.

Another way to get the same output is the dpkg-query command, also followed by the -l flag, as shown in the image below.

dpkg-query -l

The dpkg-query command has additional functions; for example, you can export the full list of installed packages to a file, which can be used later to install all listed packages in the file. This is a great method to install all packages in your current system in a new system.

The following command will create a file named installedpackages containing a list of all present packages. The name of the file is arbitrary.

dpkg-query -f '${binary:Package}\n' -W > inststalledpackages

You can see the exported list using reading commands like the less command, as shown below.

less installedpackages

That’s how you can list installed packages in Debian Linux using both dpkg and dpkg-query commands. Keep reading below to list packages using alternative commands.

List All Installed Packages on Debian 11 Using apt

The apt (Advanced Package Tool) command is another package manager available on Debian and Ubuntu-based Linux distributions. Although finding information on packages with dpkg has advantages over apt, apt is better since it can resolve dependencies when installing software. But also apt can be useful to list packages and get information on them.

To print a full list of installed packages using apt, run the command shown below:

apt list --installed

As you can see, the output is human-readable, but both dpkg and dpkg-query return a more user-friendly output sorted by columns.

Listing Packages by Status on Debian 11 Using aptitude

As said in the introduction of this article, the aptitude command is a frontend for apt with both interactive and command-line interfaces.

To list all installed files with a command-line interface using aptitude, run the aptitude command followed by the search ~i option, as shown in the following screenshot.

aptitude search ~i

As you can see, the command returns 4 columns, where the first shows the package status (i means the package is installed). The second column shows how the package was installed; in the example above, the A letter indicates the package was automatically installed. The third column shows the package name, and the fourth column shows the package’s description.

To list installed packages using the interactive mode, run aptitude followed by the -i flag as shown below.

aptitude -i

The output will show all installed packages, including their status. As shown in the previous screenshot, the list will start showing installed packages chosen to be removed. By scrolling down, you will see packages chosen to be held back and packages being automatically installed.

You also can display all installed packages sorted by status by simply running aptitude without flags.

aptitude

As you can see in the image below, you can display all files in your system sorted by the following categories:

  • Upgradable packages.
  • New packages.
  • Not installed packages.
  • Obsolete and locally created packages.
  • Virtual packages.
  • Tasks.

This interactive interface is intuitive; browse them depending on the status of packages you want to list.

These are the available methods to list installed packages on Debian 11, its previous versions and Debian-based Linux distributions.

Conclusion

As you can see, each program (dpkg, dpkg-query, apt and aptitude) has its own advantages and disadvantages. Any Linux user level can run the commands explained in this tutorial to list installed packages in the system. Knowing your software is mandatory for any system administrator. All alternatives explained in this article are useful, being aptitude the best for users who don’t like to deal with the Linux terminal. My recommendation is to learn all of them to be familiar with different package managers.

Thank you for reading this tutorial explaining how to list all installed packages on Debian 11. I hope it was useful to you. Keep reading Linux Hint for more Linux tips and tutorials.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.