How to List Installed Packages on Debian

Updated on

3 min read

List Installed Packages with apt and dpkg on Debian

In this guide, we’ll explain how to list and filter installed packages on Debian. We will also show you how to check whether a specific package is installed, count installed packages and find out the version of an installed package.

Knowing how to list installed packages on your Debian based system can be helpful in situations where you need to install the same packages on another machine or if you want to re-install your system.

List Installed Packages with Apt

Apt is a command-line interface for the package management system and combines the most commonly used functionalities from apt-get and apt-cache including an option to list installed packages.

To lists all packages installed on your system run the following command:

sudo apt list --installed
adduser/stable,now 3.115 all [installed]
apt/stable,now 1.4.8 amd64 [installed]
apt-listchanges/stable,now 3.10 all [installed]
apt-utils/stable,now 1.4.8 amd64 [installed]
autoconf/stable,now 2.69-10 all [installed]
automake/stable,now 1:1.15-6 all [installed]
autotools-dev/stable,now 20161112.1 all [installed,automatic]
base-files/stable,now 9.9+deb9u5 amd64 [installed]
base-passwd/stable,now 3.5.43 amd64 [installed]
bash/stable,now 4.4-5 amd64 [installed]

The command will display a list of all installed packages including information about the packages versions and architecture. The rightmost column in the output shows whether the package was automatically installed as a dependency of another package.

Since the packages list is long it is a good idea to pipe the output to the less command to make it easier to read:

sudo apt list --installed | less

To find out whether a specific package is installed, use the grep command to filter the output. For example to find whether the tmux package is installed on the system you would type:

sudo apt list --installed | grep tmux
tmux/stable,now 2.3-4 amd64 [installed]

The output above shows that you have tmux 2.3-4 installed on your system.

List Installed Packages with dpkg-query

dpkg-query is a command line that can be used to display information about packages listed in the dpkg database.

To get a list of all installed packages type:

sudo dpkg-query -l | less
List installed packages with dpkg-query

The command will display a list of all installed packages including the packages versions, architecture, and a short description.

You can filter the dpkg-query -l output using the grep command:

sudo dpkg-query -l | grep package_name_to_search

Create a List of all Installed Packages

The following command will store the list of all installed packages on your Debian system to a file called packages_list.txt:

sudo dpkg-query -f '${binary:Package}\n' -W > packages_list.txt

Now that you have the list, you can install the same packages on your new server with:

sudo xargs -a packages_list.txt apt install

Count the Number of Installed Packages

To find out how many packages are installed on your system you can use the same command as when creating a packages list but instead of redirecting the output to a file you can pipe it to the wc command to count the lines:

sudo dpkg-query -f '${binary:Package}\n' -W | wc -l

The output will show the number of installed packages:

466

Conclusion

In this tutorial, you learned how to list and filter installed packages on your Debian system.

Feel free to leave a comment if you have any questions.