How to List Installed Packages on Debian

By 

Updated on

6 min read

List Installed Packages with apt and dpkg on Debian

Knowing how to list installed packages on your Debian system is useful when you need to replicate the same setup on another machine, audit what is installed, or troubleshoot dependency issues.

This guide explains how to list, filter, and count installed packages on Debian using apt, dpkg-query, and apt-mark. The commands work on Debian 13 and older supported Debian releases. Listing commands only read the local package database, so they do not need sudo.

Quick Reference

TaskCommand
List all installed packagesapt list --installed
Check if a package is installedapt list --installed package_name
Filter installed packagesapt list --installed 2>/dev/null | grep '^package_name/'
Show installed package versiondpkg-query -W -f='${Version}\n' package_name
List manually installed packagesapt-mark showmanual
Count installed packagesdpkg-query -W -f='${db:Status-Abbrev}\n' | awk '$1 == "ii" { count++ } END { print count }'
Export manual package listapt-mark showmanual > manual-packages.txt

For a printable quick reference, see the APT cheatsheet .

List Installed Packages with apt

The apt command provides a straightforward way to list installed packages during interactive work:

Terminal
apt list --installed
output
adduser/trixie,now 3.152 all [installed]
apt/trixie,now 3.0.3 amd64 [installed]
base-files/trixie,now 13.8+deb13u5 amd64 [installed]
bash/trixie,now 5.2.37-2+b9 amd64 [installed]
coreutils/trixie,now 9.7-3 amd64 [installed]
...

The output shows the package name, release channel, version, architecture, and installation status. Packages marked [installed,automatic] were installed as dependencies of another package.

Since the list is long, you can pipe the output to less for easier reading:

Terminal
apt list --installed | less

Check a Specific Package

To check whether a specific package is installed, pass the package name to apt list --installed:

Terminal
apt list --installed nginx
output
nginx/trixie,now 1.26.3-3 amd64 [installed]

For a broader search, pipe the installed package list to grep :

Terminal
apt list --installed 2>/dev/null | grep '^nginx/'

The 2>/dev/null suppresses the apt stability warning that appears when piping. For scripts and repeatable exports, use dpkg-query because its formatted output is more stable.

Show the Installed Version

To print only the installed version of a package, use dpkg-query:

Terminal
dpkg-query -W -f='${Version}\n' nginx
output
1.26.3-3

If you want the package description, dependencies, and repository metadata, use apt show nginx.

List Installed Packages with dpkg-query

The dpkg-query command queries the dpkg database directly and offers more formatting options than apt.

To list all installed packages:

Terminal
dpkg-query -l
output
||/ Name           Version        Architecture Description
+++-==============-==============-============-=================================
ii  adduser        3.152          all          add and remove users and groups
ii  apt            3.0.3          amd64        commandline package manager
ii  base-files     13.8+deb13u5   amd64        Debian base system misc files
ii  bash           5.2.37-2+b9    amd64        GNU Bourne Again SHell
...

The ii at the beginning of each line means the package is installed. The columns show the package name, version, architecture, and a short description.

To check a specific package:

Terminal
dpkg-query -l nginx

Custom Output Format

You can control the output format with the -f option. For example, to print only package names and versions:

Terminal
dpkg-query -W -f='${binary:Package} ${Version}\n'

For an installed-only package name list, include the dpkg status abbreviation and filter for ii, which means the package is installed:

Terminal
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | awk '$1 == "ii" { print $2 }'

List Manually Installed Packages

The apt-mark showmanual command lists packages marked as manually installed, excluding packages marked as automatic dependencies:

Terminal
apt-mark showmanual

This is particularly useful when you want to recreate your system on a new machine. Manual packages are a better starting point than every dependency, but the list can include base packages marked manual during installation.

Export and Restore Package Lists

To save only manually installed packages to a file:

Terminal
apt-mark showmanual > manual-packages.txt

To install those packages on another Debian system:

Terminal
sudo apt update
sudo xargs -a manual-packages.txt apt install

This installs fewer packages and lets apt resolve dependencies automatically.

If you need a full installed package list for auditing, export installed package names with dpkg-query:

Terminal
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | awk '$1 == "ii" { print $2 }' > packages.txt

Restoring a full package list works best on the same Debian release and architecture with the same repositories enabled. Packages may fail to install on a different release if names changed, packages were removed, or third-party repositories are missing.

View Install History

The current package list tells you what is installed now, but sometimes you need to see when packages were installed or upgraded. Debian records APT actions in /var/log/apt/history.log:

Terminal
less /var/log/apt/history.log

Older logs may be compressed. Use zgrep to search all history files for install actions:

Terminal
zgrep "^Install:" /var/log/apt/history.log*

Count Installed Packages

To find out how many packages are installed on your system, count packages whose dpkg status is ii:

Terminal
dpkg-query -W -f='${db:Status-Abbrev}\n' | awk '$1 == "ii" { count++ } END { print count }'
output
487

To count only manually installed packages:

Terminal
apt-mark showmanual | wc -l

Troubleshooting

apt prints a warning about unstable CLI output
This warning appears when using apt in scripts or piped commands. For scripted exports and automation, prefer dpkg-query because its output format is more stable.

Some packages fail to install on the new system
The destination system may use different repositories, architecture, or release versions. Run sudo apt update, verify your enabled repositories, and install missing third-party repositories before replaying the package list.

xargs restore command fails with permission errors
Package installation requires administrative privileges. Use sudo with the install command and ensure your user has sudo access.

FAQ

What is the difference between apt list and dpkg-query?
apt list --installed provides a user-friendly output with release channel information. dpkg-query queries the dpkg database directly and offers more control over the output format. Both show the same installed packages.

How do I check the version of an installed package?
Use apt list --installed package_name or dpkg-query -W -f '${Version}\n' package_name to display the installed version.

What does [installed,automatic] mean in the apt list output?
It means the package was automatically installed as a dependency of another package, not explicitly requested by the user.

How do I list packages that need updates?
Run apt update to refresh the package list, then use apt list --upgradable to see packages with available updates.

How do I remove a package from the system?
Use apt remove package_name to remove the package while keeping its configuration files, or apt purge package_name to remove everything including configuration files.

Conclusion

You can list installed packages on Debian using apt list --installed for a quick overview, dpkg-query for custom formatting, and apt-mark showmanual for packages marked as manually installed. Export the manual list when rebuilding a system, and use the APT history log when you need to see when packages were installed or upgraded.

For more package management commands, see the guide on using the apt command .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page