How to List Installed Packages in Debian 12 Bookworm System
Categories:
3 minute read
Debian 12, codenamed “Bookworm,” is a robust and stable Linux distribution widely used for servers and desktops. As a Debian user or system administrator, managing installed packages is crucial for system maintenance, troubleshooting, and auditing. In this guide, we will explore different methods to list installed packages on Debian 12 Bookworm.
Why List Installed Packages?
Knowing what packages are installed on your system is useful for several reasons:
- System Auditing: Check which software is installed for security and compliance.
- Dependency Management: Identify dependencies when installing or removing software.
- System Migration & Backup: Reinstall the same set of packages on a new system.
- Troubleshooting: Diagnose conflicts or missing packages.
Now, let’s explore various methods to list installed packages in Debian 12.
1. Using dpkg
Command
dpkg
(Debian Package Manager) is a low-level package management tool in Debian-based systems.
Listing All Installed Packages
To display all installed packages, run:
dpkg --get-selections
This will output a list of all installed packages along with their statuses (e.g., installed, deinstall, purge).
Filtering Specific Packages
To check if a specific package is installed, use grep
:
dpkg --get-selections | grep <package-name>
For example, to check if nginx
is installed:
dpkg --get-selections | grep nginx
Displaying Detailed Package Information
For a more detailed view of a package, use:
dpkg -l | grep <package-name>
Or list all installed packages in a tabular format:
dpkg -l
The output includes:
- Desired state (ii: installed, rc: removed but config files remain, etc.)
- Package name
- Version
- Architecture
- Description
2. Using apt
Command
The apt
(Advanced Package Tool) command-line utility is commonly used for package management.
Listing All Installed Packages
To list all installed packages:
apt list --installed
This command provides a list of installed packages, including their versions and architectures.
Searching for a Specific Package
To find if a specific package is installed, use:
apt list --installed | grep <package-name>
For example, to check if curl
is installed:
apt list --installed | grep curl
3. Using dpkg-query
Command
The dpkg-query
command provides another way to query installed packages.
List All Installed Packages
Run the following command:
dpkg-query -l
This works similarly to dpkg -l
, displaying package names, versions, and descriptions.
Get Package Details
To get detailed information about a specific package:
dpkg-query -W -f='${binary:Package} ${Version}\n' <package-name>
For example:
dpkg-query -W -f='${binary:Package} ${Version}\n' openssh-server
This outputs the package name and its version.
4. Using apt-mark
Command
The apt-mark
command helps check manually installed packages.
List All Manually Installed Packages
apt-mark showmanual
This displays packages explicitly installed by the user.
List Packages Installed as Dependencies
To see packages installed as dependencies (automatically installed):
apt-mark showauto
5. Using snap
Command (For Snap Packages)
Snap packages are not managed by apt
or dpkg
. To list installed Snap packages:
snap list
This shows all Snap-installed applications with their versions.
6. Using flatpak
Command (For Flatpak Packages)
If your system uses Flatpak, list installed Flatpak applications with:
flatpak list
This displays installed Flatpak applications with details.
7. Exporting Installed Package List
For backup or migration, save the installed package list and restore it later.
Save Installed Packages to a File
dpkg --get-selections > installed-packages.txt
To restore packages on a new system:
dpkg --set-selections < installed-packages.txt
apt-get dselect-upgrade
For apt
:
apt list --installed > installed-packages.txt
Conclusion
Managing installed packages in Debian 12 Bookworm is essential for system administration, troubleshooting, and migration. This guide covered multiple methods:
dpkg
for basic listing.apt
for detailed package management.dpkg-query
for formatted queries.apt-mark
for tracking user-installed packages.snap
andflatpak
for non-standard package managers.
By mastering these commands, you can efficiently monitor and manage software installations on your Debian 12 system. Whether you’re auditing, troubleshooting, or migrating, knowing how to list installed packages will be a valuable skill.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.