list all installed packages in Ubuntu

In this article, we would cover how to list all installed packages in Ubuntu. The command-line utility which can be used is dpkg-query. Just from the name of the utility, we can understand that it used to query dpkg database.

But, what the utility queries to show us the list of packages installed?

The answer to the question lies in /var/lib/dpkg/status. We can use cat command-line utility to see how things are structured in there.

cat /var/lib/dpkg/status | less

Now, we switch to the purpose of the article.

list all installed packages in Ubuntu

As already discussed, we use dpkg-query to list all installed packages in Ubuntu. So, open a terminal and issue the following –

dpkg-query -l

where, -l option is for listing packages.

Apart from that, if we want a specific information about a package. Then, even in that case the utility is pretty useful. Following syntax should be used to query a specific package –

dpkg -l [package-name]

For instance, if we are looking for adduser package then –

dpkg -l adduser

Now, at this stage the output we get may seem a bit confusing. It contains three +, Name, Version, Architecture and Description. Apart from first three columns containing +, rest of the columns are self-explanatory. Name would show the name of package, version – available version, supported architecture and lastly the description – which tells us what the package does.

The first three columns are for Desired action, Current package status and Errors. So, we start with Desired action and letters used therein.

Desired action:

  1. i – installed
  2. r – remove
  3. p – purge
  4. h – hold
  5. u – unknown

Next comes, Current package status

  1. i – installed
  2. H – package half installed
  3. n – package not installed
  4. c  – configuration files of the package
  5. U – unpacked
  6. F – package half-configured
  7. W – awaiting triggers
  8. t – pending triggers

Lastly, its the Errors

Ignore if nothing is there or else re-installation required for the package.

So, what does “ii” signifies for us when we query dpkg?

Answer: All it means is, the package’s desired action is for installation. And, next i shows the current status of the package – which tells us that the package is already installed.

Moving ahead, what does “rc” mean for us?

Answer: “rc” here means that package’s desired action was for removal. And, at the moment configuration files are all that we have here.

Similarly, we can find out ourselves for various other combinations.

In conclusion, we have covered here how to list all installed packages in Ubuntu here.