As a full-stack developer and Linux professional, having granular visibility into your environment‘s installed packages is invaluable. Whether tackling a bug, preparing servers for deployment, or addressing an urgent security alert, knowing your Ubuntu machine‘s package state saves precious time and effort.

Over years of coding, I‘ve compiled key package listing tools and techniques to share with fellow developers, aspiring Linux wizards, and open source audiences. This post provides a layered, structured approach to achieve full installed package insight on Ubuntu 22.04 LTS or 20.04 LTS systems. Let‘s dive in!

Package Listing Use Cases

First, understanding common use cases for listing installed packages frames why mastering these commands matters:

Troubleshooting mysteries: When facing application crashes, odd behavior, or performance issues, scanning installed packages helps uncover potential culprits through process of elimination. You can validate expected runtimes and dependencies are present, or identify rogue packages causing conflicts.

Technical audits: Enterprises often require evidence of licensed software installs, security package statuses, and other standards. Generating a full package manifest provides tangible proof during audits and compliance activities.

Performance tuning: Bloated systems accrue unused libraries, widgets, tools that drag down speed over time. Listing and pruning excess packages helps optimize performance.

Environment duplication: For consistent development, QA testing, or infrastructure stability, engineers need to replicate package sets across environments. Listing the entire inventory enables this ecosystem duplication.

Upgrades/refreshing: Seeing installed versions allows systematically upgrading packages without breaking dependencies. This helps smooth major distro version migrations like Ubuntu 20.04 to 22.04.

There are certainly more niche use cases, but the above cover 80% of situations where experts like myself run package queries. Let‘s jump into the commands and outputs.

Package Primer

Before listing techniques, a quick package primer will be helpful. At a high level, we care about:

Format: How the software is packaged – as a .deb file, snap, flatpak, etc. This affects the installer tools.

.deb packages: The traditional Linux package structure that dominates Ubuntu‘s archives and defaults. Installed via dpkg and managed with apt.

Snaps: Containerized software packages, managed by the snapd daemon. Enables cross-distribution delivery for ISVs.

Flatpak: Another containerized packaging format, focused on app distribution through Flathub store. Gaining steam on desktop Linux.

Repository vs Local: Was the package installed from a configured repository source vs a direct local file? This dictates listing methodology.

With this context, let‘s demonstrate the tools!

Graphical: Leveraging Ubuntu Software Center

Let‘s start with the most basic method – the Software Center GUI. This discoverability focused application shows desktop applications and packages grouped into categories like Internet and Office. For GUI-first users, it delivers a visual way to browse installed vs available apps.

Ubuntu software center

To show just installed applications and packages:

  1. Open the Activities menu and search for "Software"
  2. Click the "Installed" tab

This reveals all graphical apps and underlying libraries installed locally. While simple, often CLI outputs are easier to parse for developers. But when used alongside command line tools, the Software Center reinforces what graphical desktop apps reside on your system.

Now let‘s level up and see what terminal commands uncover.

dpkg: Low-level Package Query Tool

The dpkg command offers maximum flexibility for package listing, installation, removal, and analysis. It interrogates local .deb packages installed via repositories or directly. This makes dpkg ideal for developers focused on environment forensics and replication.

To retrieve your full list of packages through dpkg, run:

dpkg --list | grep ^ii

Breaking this command down:

  • dpkg --list shows all packages dpkg knows about
  • grep ^ii filters just installed packages marked ii

And voila! You have a list like:

dpkg sample output

With dpkg, you get the nitty gritty details on all repository and manually installed .deb packages:

  • Package name
  • Specific version – critical for dependencies!
  • Architecture – good for audits
  • Concise description

Beyond raw listing, dpkg enables power-user package analysis:

  • Count all packages with dpkg -l | grep ^ii | wc -l
  • Check for packages by name dpkg -l | grep firefox
  • Match versions with regexes

This raw insight aids troubleshooting and environment duplication situations for developers. Now let‘s level up to repository management with apt.

APT: Repository Package Handling

The apt toolkit is the Swiss army knife for repository package manipulation on Debian, Ubuntu and relatives. While dpkg handles local .deb installation, apt enables:

  • Installing/removing packages from configured repositories
  • Updating repository package lists
  • Upgrading entire system across repositories
  • Caching packages for offline use

So for managing packages from Ubuntu 22.04‘s main archives, PPAs, or internal repos – apt is perfect.

To list all installed packages via apt, simply run:

apt list --installed

This returns traditional .deb packages from repositories:

Sample APT list output

apt has similar filtering abilities to dpkg:

  • Get package counts with | wc -l
  • Grepping specific names
  • Matching via regex

But apt adds visibility into:

  • Origin repository for updates, removals, rollbacks
  • More metadata like priority, section
  • Multiversion support

Together dpkg + apt give complete visibility into .deb packages on a system irrespective of install method.

Now let‘s handle snaps!

Snappy Package Commands

With Ubuntu‘s introduction of snaps starting with 16.04, developers need awareness of this parallel package ecosystem. Snaps aim to simplify application delivery for ISVs by containerizing apps + dependencies into a single artifact. This means snaps can deliver desktop apps, languages, databases and more.

Major vendors like Spotify, VS Code, and Slack now distribute their Linux apps as snaps by default. To manage these packages, the snap command offers intuitive control.

To list all installed snaps, run:

snap list

You‘ll see output like:

Sample snap list output

The {app}-{developer} naming convention provides transparency into a snap‘s upstream source vs cryptic .deb names.

You can also query rich details on a specific snap:

snap info {snapname}

And remove unneeded ones with:

snap remove {snapname}

For coding workflows, snaps simplify getting favorite IDEs, debuggers, and toolchain components on Ubuntu. Combining snap visibility with .deb package info completes the picture.

Emerging Package Trends

While .deb and snaps dominate today‘s Ubuntu desktops, as a forward-looking Linux professional you should remain aware of emerging package tech. Namely:

Flatpak: This RedHat sponsored, cross-distro containerized package format has gained momentum, especially for desktop apps. Like snaps, flatpaks bundle app runtime dependencies for simplicity and portability. Steam now utilizes Flatpak for its Linux game delivery.

AppImages: One of the original self-contained app package types, AppImages never required privileged installs. They continue to provide lightweight delivery, especially for niche Linux tools.

Universal Packages: Canonical aims to bridge .deb and snap capabilities under a new unified packaging standard that simplifies publishing anywhere. This bears watching as a potential future successor.

I suggest lightly tracking these alternative package types using:

flatpak list
appimagelauncher --list

As Ubuntu platforms expand to cloud, IoT and appliances, developers should stay alert around new package formats entering our ecosystems.

Consolidated Package Reporting

Individually, dpkg, apt, snap provide installed package visibility on Ubuntu. Each tool has situational advantages described above. However, to operate efficiently Linux professionals need an aggregated, unified view.

After years of honing my workstation and server management practices, I have a streamlined approach. The end goal is generating a single inventory document or spreadsheet covering ALL installed packages across format and origin.

With this "source of truth" artifact, you and other administrators can:

  • Quickly validate if expected packages are actually present
  • Identify unknown or unused packages for removal
  • Support license and security audits
  • Duplicate or migrate environments
  • Inform refresh decisions

So how do we build this consolidated output? My method:

  1. Run dpkg --list | grep ^ii > dpkg-packages.txt to dump the local .deb package listing
  2. Run apt list --installed > apt-packages.txt to capture repository packages
  3. Run snap list > snaps.txt
  4. Concat or merge outputs into a single document or spreadsheet

From this aggregate package manifest, charts and summaries can be built programmatically to convey trends. You now have an authoritative reference on your Ubuntu environment‘s true state – revolutionary for developers and administrators!

Conclusion

I hope this post has armed Linux professionals with battle-tested tactics for unlocking installed package insight on Ubuntu. While GUI tools like Software Center have a place, smart leveraging of dpkg, apt, snap, and emerging package commands gets you the details. Consolidating outputs builds the master inventory artifact for so many critical operations. Ultimately, factual visibility into your Linux environment saves time, cost and headaches for developers. Please reach out with any questions or suggestions as you hone your Ubuntu package wizardry!

Similar Posts