How to List Installed Packages on Ubuntu

In this guide, you will learn how to list the packages installed on your Ubuntu operating system.

Ubuntu list installed packages

Listing packages in Ubuntu is a straightforward process thanks to both the apt package manager and the dpkg tool.

Checking for installed packages can be useful if you want to see what packages have already been installed on your machine.

Most users can use the apt package manager to list out the packages installed to your Ubuntu system.

However, if you are using a Ubuntu version older than 14.04, you can use dpkg instead. Additionally, if you want to use the package list result within a script, you should also use dpkg.

You will complete all of the following steps within the terminal. If you are on a desktop version of Ubuntu, you can easily open the terminal by pressing CTRL + ALT + T.

Additionally, you can list installed packages for Ubuntu by using an SSH connection.

Table of Contents

Using apt to List Installed Packages on Ubuntu

In this section, you will learn how to list the packages installed to your Ubuntu system by using the apt package manager.

We will walk you through a couple of different ways you can utilize this command.

Only Listing Installed Packages

The first method we will show is how to use apt to only list the packages installed to your Ubuntu system.

Thanks to apt, this process is very straightforward as, since Ubuntu 14.04, it has featured a special option that we can use.

All we need to do is use “apt list” followed by the “--installed” argument.

apt list --installed

From this command, you will get a list of every single package that has been installed on your system,

Below is an example of what will be outputted by this command. Each line will have “[installed]” to indicate that it is installed on the system.

ssh/stable,now 1:7.9p1-10+deb10u2 all [installed]
strace/stable,now 4.26-0.2 armhf [installed]
sudo/now 1.8.27-1+deb10u2 armhf [installed,upgradable to: 1.8.27-1+deb10u3]

List if a Specific Package is Installed

If you only want to list a specific package’s installed status on an Ubuntu system, then apt can also do that.

We have to re-adjust the command slightly and use the “-a” argument. This argument tells the list command to print all available versions of the package.

Below is an example of the syntax of the apt list command to list a single package.

apt list -a [PACKAGENAME]

Make sure that you replace “[PACKAGENAME]” with the name of the package you want to check the status of.

Example of Listing a Specific Packages Installed Status

To show you how this works, let us list if a specific package is installed on Ubuntu.

For this example, we will check to see if our system has the unzip packages installed

apt list -a unzip

From this command, you should get a result like we have below.

Listing... Done
unzip/stable,now 6.0-23+deb10u2 armhf [installed]

If the package is installed, you will see the text “[installed]” at the end of the line.

List all Packages with Installation Status

It is possible to list the status of all of the packages available to your Ubuntu system and its installation status.

When you list packages this way, you will get a massive list. Each line will list a package that’s either installed or can be installed on your Ubuntu system.

This command is the simplest way to use the “apt list” command but will give you way too much information.

apt list

If you want to use this result to filter with something like, grep you are better off using dpkg.

When attempting to pipe the apt command result, you will receive a warning message, as we have shown below.

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

Counting the Number of Installed Packages on Ubuntu

If you are interested in how many packages are installed on your Ubuntu system, then there is also a command we can use for that.

While you can use the apt result for this, it is better to use the dpkg package as it is more friendly to scripting.

1. Instead of piping (|) the results of the apt list command to grep, it will instead be piped to the “wc” command.

This command allows us to count the number of lines in the command output, giving us the rough number of installed packages.

apt list --installed | wc -l

2. Below is an example of the output produced by the command above.

732

List Installed Packages on Ubuntu using dpkg

Using the apt package manager is not the only way to list packages installed on Ubuntu.

We can also use the dpkg tool to get similar results. This tool can be a little bit harder to use, but it is pretty versatile.

Listing Installed Packages with dpkg

Listing installed packages on Ubuntu using dpkg is just as simple as using the apt package manager.

All you need to do to list the installed packages is to use the following command.

By using the “-l” ()--list) option we are telling dkpg that we want it to list all installed packages.

dpkg -l

Below is an example of the result you will get from this command. What we have here is only a short snippet of what will be displayed.

If a package is currently installed, it will use “ii” at the start of the line. Alternatively, if the package is not installed, it will be prefixed with “un“.

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                  Version                                Architecture Description
+++-=====================================-======================================-============-===================================================
ii  acl                                   2.2.53-4                               armhf        access control list - utilities
ii  adduser                               3.118                                  all          add and remove users and groups
ii  adwaita-icon-theme                    3.30.1-1                               all          default icon theme of GNOME
ii  agnostics                             0.6                                    armhf        Raspberry Pi Diagnostics
ii  alacarte                              3.11.91-4+rpt2                         all          easy GNOME menu editing tool

You can navigate up and down the list by using the arrow keys on your keyboard.

List a Specific Packages Installation Status on Ubuntu

We can also use dpkg to list the status of a specific package by defining a pattern.

The syntax for this is relatively similar to that for listing all packages with dpkg. The main difference is that we need to define a pattern.

dpkg -l PATTERN

When using the command in this way, replace “PATTERN” with the package you want to search for. The pattern can even include extra characters such as a wildcard (*).

Example of Listing Specific Packages with dpkg

To show you how this works, we will give a quick example where we check the status of any package containing the word zip.

dpkg -l *zip*

By using the wildcards on either side of the word “zip“, the list command will find every package containing that word.

Below is an example of what we got when running this command.

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version           Architecture Description
+++-==========================-=================-============-======================================================
ii  bzip2                      1.0.6-9.2~deb10u1 armhf        high-quality block-sorting file compressor - utilities
un  bzip2-doc                                     (no description available)
ii  gzip                       1.9-3             armhf        GNU compression utilities
un  libcompress-raw-bzip2-perl                    (no description available)
un  libio-compress-bzip2-perl                     (no description available)
un  lrzip                                         (no description available)
un  lzip                                          (no description available)
un  p7zip-full                                    (no description available)
ii  unzip                      6.0-23+deb10u1    armhf        De-archiver for .zip files
ii  zip                        3.0-11            armhf        Archiver for .zip files

Counting the Number of Installed Packages on Ubuntu using dpkg

The final thing we will show you is how to count the number of installed packages on Ubuntu while using the dpkg command.

1. To count the number of installed packages, we need to pass the result of “dpkg” to “grep” and then finally to the “wc” command to count the number of entries.

dpkg --get-selections | grep -v deinstall | wc -l

2. With the result below, you can see how many packages are installed on our system.

731

Conclusion

Hopefully, by this stage, you will now know how to list installed packages on Ubuntu.

We have shown two different methods for handling this. One is to list packages using the apt package manager.

The other way is to list the installed packages using the dpkg tool.

If you have had issues with either one of these methods, please leave a comment below.

Be sure to check out our other Ubuntu tutorials to learn how to use the system better.

Leave a Reply

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