Website Vidya
Linux & ServersStep-by-Step Guide

How to List Installed Packages on Ubuntu

Learn how to list installed packages on ubuntu with apt list, dpkg-query, dpkg, snap list, counting packages, and exporting installed package lists.

RR
Rajesh RayLead Systems Educator
Published:
5 min read
PDF Cheat Sheet
How to List Installed Packages on Ubuntu
AI Executive SummaryWebsiteVidya AI

5 min read

Learn how to list installed packages on ubuntu with apt list, dpkg-query, dpkg, snap list, counting packages, and exporting installed package lists.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Listing Installed Packages with apt list --installed
  • Step 2: Listing Installed Packages with dpkg -l and dpkg-query
Grounded in full engineering runbookWebsiteVidya AI Engine

Maintaining an accurate inventory of installed software is one of the most fundamental responsibilities of Linux system administration, security compliance, and disaster recovery.

Whether you are migrating to a newly provisioned server, performing a routine security vulnerability audit, freeing up disk space, or diagnosing package version conflicts, knowing exactly what software resides on your machine is essential.

Ubuntu provides multiple native tools to query the underlying package database, ranging from high-level APT utilities to low-level dpkg query tools and modern Snap package managers.

In this guide, we walk through how to list installed packages on ubuntu across command-line methods, filter packages with grep, count total installed software, and export lists for automated deployment.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A computer or server running Ubuntu 24.04 LTS, Ubuntu 22.04 LTS, or any Debian-based system.
  • Access to a command-line terminal shell.
  • No root privileges are required to inspect installed packages.

Step 1: Listing Installed Packages with apt list --installed

The modern, user-friendly method for querying installed software is using apt list --installed.

Advertisement

This command queries the APT cache and displays each package's name, installed version, CPU architecture, and whether it was installed manually or automatically as a dependency:

Because thousands of packages are installed on a typical system, pipe the output through less to scroll through the list, or grep to search for a specific application:

# List all installed packages with scrollable pagination:
apt list --installed | less

# Filter for a specific installed package (e.g., nginx or python):
apt list --installed | grep -i "nginx"
apt list --installed | grep -i "python3"

# Example output snippet:
# nginx/noble-updates,now 1.24.0-2ubuntu7 amd64 [installed]
# python3/noble,now 3.12.3-0ubuntu1 amd64 [installed]

Step 2: Listing Installed Packages with dpkg -l and dpkg-query

For shell scripts or fast terminal queries, dpkg and dpkg-query are significantly faster than APT because they query the local status file (/var/lib/dpkg/status) directly without parsing package repositories.

The classic command dpkg -l formats output into organized columns showing package status, name, version, and architecture.

Advertisement

Packages with status ii are properly installed and operational:

# List installed packages with dpkg:
dpkg -l | grep "^ii" | less

# High-speed clean listing of package names only using dpkg-query:
dpkg-query -f '${binary:Package}\n' -W | head -n 25

# High-speed listing of package names with version numbers:
dpkg-query -f '${binary:Package}	${Version}\n' -W | head -n 25

Step 3: Counting the Total Number of Installed Packages

System administrators frequently need to quantify how many packages are installed to evaluate system bloat or compare different server baseline images.

Combine dpkg-query with the word count utility wc -l to count all registered packages:

Execute the following command in your terminal:

# Count total Debian/Ubuntu packages installed:
dpkg-query -f '${binary:Package}\n' -W | wc -l
# Typical output for server: ~600 - 900 packages
# Typical output for desktop: ~1,500 - 2,500 packages

# Count manually installed packages (excluding auto-installed dependencies):
apt-mark showmanual | wc -l

Step 4: Listing Installed Snap Packages

Ubuntu 24.04 and 22.04 ship with Canonical's Snap package system enabled by default for desktop and server utilities.

Standard APT and dpkg commands do not inspect Snap packages because Snaps are containerized SquashFS images managed independently by snapd.

Use the snap list command to display all installed Snap applications, tracking channels, and revisions:

# List all installed Snap packages:
snap list

# Expected output confirms:
# Name               Version        Rev    Tracking       Publisher   Notes
# core22             20240408       1380   latest/stable  canonical✓  base
# snapd              2.62           21465  latest/stable  canonical✓  snapd

Step 5: Listing Packages by Installation Date and Time

When diagnosing unexpected system behavior or sudden breakages, identifying which packages were recently installed or upgraded is critical.

The dpkg log file located at /var/log/dpkg.log records every package installation, status change, and removal with exact timestamps.

Query recent installations using grep and awk:

# List packages installed or updated today/recently:
grep " installed " /var/log/dpkg.log | tail -n 25

# Inspect the APT history log for complete transaction sessions:
cat /var/log/apt/history.log | tail -n 35

Step 6: Exporting Installed Packages and Replicating on Another Server

To replicate your software environment across another Ubuntu server, export your list of manually installed packages to a text file.

The apt-mark showmanual command outputs only the packages you explicitly requested, filtering out hundreds of automatic dependency libraries.

Export the package list and restore it on a target system with these commands:

# Export list of manually installed packages on source server:
apt-mark showmanual > ~/installed_packages.txt

# On the new destination server, update repositories and install the list:
sudo apt update
xargs -a ~/installed_packages.txt sudo apt install -y

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Cause: Running apt list inside automated bash scripts or pipes triggers a standard informational warning.

Resolution: Use dpkg-query -f '${binary:Package}\n' -W or apt-mark showmanual inside scripts for stable, machine-readable output.

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

grep: /var/log/dpkg.log: No such file or directory

Cause: Operating in a minimal container environment where system logs are suppressed, or log rotation archived the file.

Resolution: Check rotated logs using zgrep ' installed ' /var/log/dpkg.log.*.gz.

ls -la /var/log/dpkg*

snap: command not found

Cause: Operating on a minimal Ubuntu image where snapd has been uninstalled or disabled.

Resolution: Install snapd if needed: sudo apt update && sudo apt install -y snapd.

sudo apt install -y snapd

Security Best Practices and Hardening

Regularly review your manually installed package list (apt-mark showmanual) to identify and remove unused server software that increases attack surface.

Export package lists before major release upgrades so you have a complete inventory in the event of package removal during upgrade conflicts.

Use debsums -c to verify the cryptographic checksums of installed package files against maintainer baselines to detect unauthorized file tampering.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
A manually installed package is one you explicitly requested via apt install [name]. An automatically installed package was pulled in as a dependency by another application. If the parent application is removed, auto-installed packages can be cleaned with apt autoremove.
Run dpkg -s [package_name]. If installed, the status line displays Status: install ok installed.
Run apt list --upgradable after refreshing your cache with sudo apt update.
Yes. If Flatpak is installed, execute flatpak list to view installed Flatpak applications and runtimes.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout