How to List Installed Packages in Ubuntu With APT

When you want to remove unwanted software from your system, having a list of all installed packages right in front of you can help. On Ubuntu, APT makes it easier for users to get a list of packages currently installed on their system.

In this guide, you will learn how to list installed packages on Ubuntu using APT, the default package manager on Debian-based distributions.

Get a List of Installed Packages on Ubuntu

To output a list of packages that are currently installed, are upgradeable, or available on Ubuntu, you can use the list method of the APT command. To only print packages installed on your system, specify the –installed flag with the command.

sudo apt list --installed

Output:

The output generated by the aforementioned command contains additional information, including the version number and package state.

To get a clean output suitable for use in scripts and output transfer, you can use string manipulation tools like sed or awk. For example, to print only the package names:

sudo apt list --installed | awk '{split($0, a, "/"); print a[1]}'

Output:

Related: These sed Examples Will Make You a Linux Power User

You can also count the total number of packages. All you have to do is pipe the output of the aforementioned command with wc. Word count, abbreviated wc, is a Linux utility that counts the number of characters, words, or lines present in a text file.

sudo apt list --installed | wc -l

Output:

As you can see in the output above, 2177 Linux packages are currently installed on the system.

Using dpkg-query

Users running older versions of Ubuntu can use the dpkg-query command to get a list of installed packages.

sudo dpkg-query -l

Dpkg will present the output in a clean, tabular format by default.

To strip out additional information and print only the names of the packages, run the following command:

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

Output:

Learn More: What Is the Difference Between APT and dpkg in Ubuntu?

Package Management Made Effortless With APT

In addition to the list method, APT has several other functions that provide information associated with Linux packages. It also takes away the headache of removing unnecessary dependencies by keeping records of installed and uninstalled packages on your system.

Like APT, several other package managers are available for Linux, including DNF, pacman, and YUM. Most Debian-based distros ship with APT, while Arch Linux and RHEL-based systems use pacman and DNF as their default package managers respectively.

Author: Deepesh Sharma

Source: Deepesh Sharma.” How to List Installed Packages in Ubuntu With APT”. Retrieved From https://www.makeuseof.com/apt-list-installed-packages/

All Rights Of This Article Reserved To MakeUseOf

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: