To review system changes or to troubleshoot any package-related issues on Debian 12 or any other Linux distribution it is necessary to list the installed Debian packages. This provides better insights into the details of the installed applications. Generally, the Debian default package installer is used for listing installed packages on Debian but there are other potential ways as well.
How to List Installed Packages on Debian 12
There are primarily five ways to list packages on Debian, whereas there are two other ways as well which solemnly depend on the package manager used for the installation of packages. This guide will discuss all seven ways comprehensively.
1: Through apt
Every Linux distribution has its default package installer and likewise apt is the default app installer of Debian-based Linux systems. So the primary method for listing installed applications on Debian 12 by using the apt app installer. To list all the packages either installed or upgradable on Debian 12 you can use the list command along with apt:
apt list
Next, If you want to list all of the installed packages via apt on Debian 12 then add the installed flag with apt list command:
apt list --installed
Now to not only see the current version of any installed package through the Debian default package manager but to list all of its available versions use the a flag and the respective package name along with the apt list command:
apt list -a [Package-name]
Another way to check if the package is installed on Debian 12. Simply use the installed flag along with the package name as in the image below:
apt list [Package-name] --installed
Now if you are looking for the total number of installed packages on Debian 12 then use the below command:
apt -qq list --installed | wc -l
Here wc is the word count command and -l flag counts the number of lines whereas qq option instructs apt to operate in quiet mode thus reducing the output and showing all the essential details.
Sometimes the applications on Debian 12 are installed manually so in that case you can filter out the manually installed package on Debian by executing:
apt-mark showmanual
Further to get the total number of all the applications installed manually on the Debian then execute the below command:
apt-mark showmanual | wc -l
Note: The apt-mark showmanual command shows packages you explicitly chose to install or those essential for the system’s core functionality that isn’t automatically managed by dependencies.
Last but not least you can save the list of installed packages in a text file which you can use as a requirements.txt file. The saved file further serves the purpose of package installation in virtual environments, automated systems, and more. To save the Debian list of installed packages use the below syntax:
apt list --installed > [file-name].txt
2:Through dpkg
Debian package management (dpkg) is a tool used in Debian-based Linux distributions for installing and removing applications. So to list all the applications either installed via apt or dpkg simply use the l flag as in the command below:
sudo dpkg -l
If you need to see the list interactively use the less flag with dpkg list command:
sudo dpkg -l | less
Here, less flag allows you to view the output one screen at a time. It provides navigation options to scroll up and down through the list:
Now here as you press enter and the list will propagate. Just like the apt package manager, you can also list the details of any specific package by using its name:
sudo dpkg -l | grep [package-Name]
The grep utility filters the output of the preceding command to show only the lines that contain the specified package:
Next, to display information about a specific package installed on your Debian-based Linux system use the w flag and dpkg-query command:
sudo dpkg-query -W [package-Name]
Here the dpkg-query command is used to query the dpkg database and the -w flag tells dpkg-query to show the information about the package.
Note: The sudo dpkg -l | grep [package-Name] command lists all packages and then filters the output to show only lines containing package names. Whereas, the sudo dpkg-query -W [package-Name] command shows information about a specific package that is known to the dpkg database, whether it’s installed or not.
If you want to narrow down your search for installed packages list on Debian 12 based on their starting alphabet then in that case use the below syntax:
dpkg --list '[alphabhet]*'
Now to see the total number of packages installed using the dpkg-query then execute the below command:
sudo dpkg-query -f '${binary:Package}\n' -W | wc -l
Here,the -f ‘${binary:Package}\n’ option specifies a custom format for the output. The ${binary:Package} outputs the binary package name, and \n ensures each package name is on a new line:
To view the first 10 lines of the installed packages list in Debian you can use the head option with the dpkg listing the command:
dpkg-query -l | head
Here you will see only the first ten lines of the list:
Another way to list installed Debian packages on Debian 12 is to use the below command as well:
dpkg --get-selections | grep -w "install" | head
Here, dpkg –get-selections lists all packages along with their current selection state, which can be “install”, “hold”, “deinstall”, or “purge”. Next, grep -w “install” filters the output to only show lines where the word “install”.
This command lists all packages that are marked with the selection state “install” in the dpkg database. However, it’s important to note that this command may also list packages that are set to be installed but have not yet been processed by dpkg.
Now just like we used the apt command to save all the installed files in a text file, the same function can be achieved using the dpky command as well. For that execute the below syntax:
dpkg --get-selections | grep -w "install" | cut -f1 > [file-name.txt]
Here, the cut -f1 cuts out the first field from each line, which is the package name, discarding the selection state:
You can also get more details on the Debian list of installed packages like their status, date, and installation time. This might help you while reviewing the system changes.
zgrep " installed " /var/log/dpkg.log*
Here, zgrep command works just like grep, but it can also handle compressed files (those ending in .gz). However, you can also use the grep instead of it.
3: Through aptitude
Another method to get the list of installed Debian packages on Debian 12 is to use the aptitude package manager. It simplifies package management tasks and provides an efficient way to handle software installation and maintenance on Debian-based systems. To list the installed packages on Debian first execute the below command:
aptitude
Now here you will see a list of options, click on the Installed Packages option:
Now here you can see that packages are divided into different groups and each group has a list of certain packages installed. Now here you can click on any group to see the respective installed packages:
Alternatively, you can use the following syntax for listing the installed packages on Debian 12 using the aptitude package manager:
aptitude search '~i!~M'
Here, in the above command the ‘~i’ is a part of the search pattern that tells aptitude to look for installed packages (i stands for installed). Whereas the ‘!~M’ is a negation (!) of automatically installed packages (M stands for automatically installed). It will, in essence, list every package you have specifically installed yourself:
Further, if you want to list all the packages installed by yourself and automatically then execute:
aptitude search '~i'
Note: By default, the aptitude package manager is not installed on Debian 12 so to install use the apt package manager:
sudo apt install aptitude
4: Through dctrl-tools
The next tool you can use to dctrl tools which are specifically used in Linux to process Debian package information. These tools are particularly useful for managing and querying the database of installed packages on Debian-based Linux distributions. First, you need to install it and for that execute:
sudo apt install dctrl-tools
To list all the tools available in dtcrl tools execute:
dpkg -L dctrl-tools | grep '/usr/bin/'
Next here for a demonstration, I have used the grep-status tool to list all the installed packages on Debian:
grep-status -FStatus -sPackage -n "install ok installed"
Here, the -FStatus option tells grep-status to look specifically at the ‘Status’ field in the package database. The –sPackage option specifies that you want to show the ‘Package’ field from the records. The -n prints the names of the packages, without the field name itself. Lastly, the “install ok installed” lets the grep-status search in the ‘Status’ field. It matches packages that have been properly installed and are in good condition.
5: Through Synaptic Package Manager
The synaptic package manager is a sort of GUI version of the advanced package manager tool on Debian. So if you are not very familiar with using commands on Debian 12 then use this method to list Debian packages. Simply click on the Installed option from the left pane under the Status tab to access the installed Debian packages:
6: Through Snap
To list all the packages installed on Debian 12 via the snap package manager execute the below command:
snap list
7: Through Flatpak
To list all the packages installed on Debian 12 via the Flatpak package manager execute the below command:
flatpak list --app
Conclusion
To get the list of installed packages on Debian 12 there are seven different ways which include apt, dpkg, aptitude, dctrl-tools, synaptic package manager, snap, and Flatpak. The easy and straightforward way to list Debian-installed packages is by using apt list –installed command. If you want to see detailed information on every installed package then use sudo dpkg -l | less command. If you want to use GUI then either use the synaptic package manager or aptitude package manager.