How to Check Installed Packages in Ubuntu: Complete Guide for Beginners and Intermediate Users

目次

1. Introduction

Ubuntu is a reliable Linux distribution trusted by many developers and engineers. While using it, you may encounter situations where you want to verify which packages are installed on your system.

For example, this information is useful when checking whether a specific package has been properly installed or identifying unnecessary packages that you may want to remove.

This article provides a detailed explanation of how to check installed packages in Ubuntu. We introduce practical methods suitable for both beginners and intermediate users, so be sure to read through to the end.

2. How to Display a List of Installed Packages

Ubuntu offers several ways to check installed packages. Here are three commonly used methods. You can choose based on your needs and preferences.

Using the apt Command

apt is one of the most frequently used package management commands in Ubuntu. To list installed packages, use the following command:

apt list --installed

Command Explanation

  • apt list: Displays package information in a list format.
  • --installed: Shows only packages already installed on the system.

Example Output

When you run the command, you will see a list of installed packages like this:

accountsservice/now 0.6.55-0ubuntu12 amd64 [installed,automatic]
acl/now 2.2.53-10 amd64 [installed]

Using the dpkg Command

dpkg is a low-level command used to directly manage Debian packages. Use the following command to display installed packages:

dpkg-query -l

Command Explanation

  • dpkg-query: Queries the dpkg database to obtain package information.
  • -l: Lists all installed packages.

Example Output

The output will look like this:

ii  accountsservice   0.6.55-0ubuntu12   amd64   query and manipulate user account information
ii  acl               2.2.53-10          amd64   access control list utilities

Here, ii indicates that the package is installed correctly.

Using the snap Command

snap is a newer package management system used in Ubuntu. To check packages installed via Snap, run:

snap list

Command Explanation

  • snap list: Displays a list of Snap packages installed on the system.

Example Output

The following is an example list of installed Snap packages:

Name     Version    Rev   Tracking       Publisher     Notes
core     16-2.58    12834 latest/stable  canonical✓    core

This command helps you check version and revision data for Snap packages.

Summary

  • apt list --installed: Convenient for a quick overview of installed packages.
  • dpkg-query -l: Suitable for detailed package information.
  • snap list: Used specifically for Snap package verification.

By using these commands appropriately, you can efficiently manage package information on Ubuntu.

3. How to Check Whether a Specific Package Is Installed

Ubuntu provides several efficient ways to verify whether a specific package is installed. Here, we explain how to do this using apt and dpkg.

Checking with the apt Command

Use the apt command to search for a particular package in the installed package list.

Example Command

Combine apt with grep to search for a package name:

apt list --installed | grep package-name

Example Execution

To check if curl is installed, run:

apt list --installed | grep curl

Example Output

curl/now 7.68.0-1ubuntu2.6 amd64 [installed]

This result confirms that curl is installed.

Checking with the dpkg Command

You can also verify installation status using dpkg:

Example Command

dpkg-query -l | grep package-name

Example Execution

To check whether git is installed:

dpkg-query -l | grep git

Example Output

ii  git    1:2.25.1-1ubuntu3.2 amd64 fast, scalable, distributed revision control system

The ii indicates successful installation.

Checking Snap Packages

If the package was installed via Snap, use:

snap list | grep package-name

Example Execution

To check if chromium is installed via Snap:

snap list | grep chromium

Example Output

chromium    97.0.4692.99    1892   latest/stable    canonical✓    -

This confirms that chromium is installed as a Snap package.

Summary

  • apt list --installed | grep package-name: Simple and intuitive.
  • dpkg-query -l | grep package-name: Provides detailed information.
  • snap list | grep package-name: Used for Snap packages specifically.

By using these methods, you can quickly determine whether a package is installed in your system.

4. How to Display Detailed Information About Installed Packages

You may sometimes need detailed information such as functionality, dependencies, or version details of a package. Ubuntu allows you to obtain this information via the following commands.

Using the apt show Command

The apt show command displays detailed package information.

Example Command

apt show package-name

Example Execution

To view details about curl:

apt show curl

Example Output

This command provides detailed information such as:

Package: curl
Version: 7.68.0-1ubuntu2.6
Priority: optional
Section: web
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Description: command line tool for transferring data with URL syntax
 This is a command line tool and library for transferring data with URLs.

Key Information Explained

  • Package: Name of the package.
  • Version: Installed version.
  • Section: Package category (e.g., web, utils).
  • Maintainer: Package maintainer information.
  • Description: Overview of the package.

Using the dpkg Command

You can also view detailed package information using:

Example Command

dpkg -s package-name

Example Execution

dpkg -s git

Example Output

Package: git
Status: install ok installed
Priority: optional
Section: vcs
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Description: fast, scalable, distributed revision control system
 Git is a fast, scalable, distributed revision control system with an
 unusually rich command set that provides both high-level operations
 and full access to internals.

This command also shows package status and summary.

Usage Example: Checking Dependencies

To verify dependencies for a package, use:

apt show curl

The output includes dependency details like:

Depends: libc6 (>= 2.17), libcurl4 (>= 7.68.0-1ubuntu2.6)

This helps identify additional packages required for proper functionality.

Summary

  • apt show package-name: Displays package details and dependencies.
  • dpkg -s package-name: Provides concise package information.

These commands help you better understand installed packages and improve system management and troubleshooting.

5. How to Check the Number of Installed Packages

If you want to verify the total number of installed packages, Ubuntu provides commands to quickly retrieve this information. This is useful when analyzing system size or status.

Using the apt Command

You can combine apt list with wc -l to count installed packages:

Example Command

apt list --installed | wc -l

Command Explanation

  • apt list --installed: Lists installed packages.
  • wc -l: Counts the number of lines in the output.

Example Output

543

In this example, 543 packages are installed on the system.

Using the dpkg Command

You can also count installed packages using:

Example Command

dpkg-query -l | grep '^ii' | wc -l

Command Explanation

  • dpkg-query -l: Lists installed packages.
  • grep '^ii': Filters packages marked as installed.
  • wc -l: Counts the filtered lines.

Example Output

487

This indicates that 487 packages are installed.

Checking Snap Packages

To count installed Snap packages:

snap list | wc -l

Command Explanation

  • snap list: Lists all Snap packages.
  • wc -l: Counts the number of lines.

Example Output

12

This means 12 Snap packages are installed.

Note

Since the snap list output includes a header row, subtract 1 from the count for the correct number:

snap list | tail -n +2 | wc -l

Summary

  • apt: Use apt list --installed | wc -l to get the count quickly.
  • dpkg: Use dpkg-query -l | grep '^ii' | wc -l for detailed filtering.
  • Snap: Use snap list to count Snap-installed packages.

These methods allow you to easily determine how many packages are installed on your Ubuntu system.

6. Conclusion

This article explained several ways to check installed packages in Ubuntu. Each method has its benefits, and you can select one based on your goals and environment.

Methods Introduced

  1. Checking Installed Packages
  • We described how to view all installed packages using apt list --installed and dpkg-query -l.
  • For Snap packages, use snap list.
  1. Checking Specific Packages
  • We introduced how to combine commands with grep to quickly verify package installation.
  1. Retrieving Detailed Information
  • We explained how to use apt show and dpkg -s to view dependencies and version details.
  1. Checking the Number of Installed Packages
  • We covered how to determine the total number of installed packages using wc -l.

Which Method Should You Choose?

  • For beginners: Using the apt command (e.g., apt list --installed) is recommended.
  • If you need more details: Use dpkg commands or apt show.
  • If focusing on Snap packages: Use the snap list command.

Final Thoughts

Understanding these commands is essential for efficient package management in Ubuntu. By applying the techniques described in this article, you can maintain your system more effectively and resolve issues with confidence.

7. FAQ

Here are frequently asked questions related to checking installed packages in Ubuntu. These answers help beginners and intermediate users avoid common confusion.

Q1: What is the difference between apt and dpkg?

A:
apt is a high-level package management command for Ubuntu and Debian-based systems, simplifying tasks such as installation, removal, and updates. dpkg is a lower-level tool for directly manipulating installed package files. Internally, apt uses dpkg.

Main Differences:

  • apt: Uses repositories to download and install packages.
  • dpkg: Manages local Debian package files (.deb).

Q2: What are Snap packages?

A:
Snap is a modern package management system provided by Ubuntu. Unlike traditional Debian packages handled by apt or dpkg, Snap packages bundle dependencies and offer portability across systems.

  • Pros: Avoids dependency conflicts, allows access to the latest applications.
  • Cons: Package sizes may be larger.

Use commands like snap list and snap install when working with Snap.

Q3: What is the easiest way to check whether a specific package is installed?

A:
The fastest method is:

apt list --installed | grep package-name

For example, to check curl:

apt list --installed | grep curl

If it appears in the output, the package is installed.

Q4: What should I do if a command doesn’t work?

A:

  1. Check for typos: Ensure there are no spelling mistakes.
  2. Check permissions: Some commands require sudo.
sudo apt list --installed
  1. Update package lists using:
sudo apt update
  1. Check system logs such as /var/log/syslog or use journalctl to review errors.

Q5: How can I remove an installed package?

A:

  • apt remove package-name: Removes the package, but keeps configuration files.
  • apt purge package-name: Removes the package and its configuration files.

Example:

sudo apt remove curl

To remove configuration files as well:

sudo apt purge curl

Q6: Can I save a list of installed packages to a file?

A:
Yes, use the following command:

apt list --installed > installed_packages.txt

This saves the list to installed_packages.txt. You can later use this with apt install to reinstall packages on another system.

Conclusion

This FAQ section provides answers to common Ubuntu package management questions. Use this information to improve your workflow and enhance your troubleshooting skills as you continue exploring Linux package systems.