Ubuntu

How to List Installed Packages on Ubuntu

Knowing the installed packages on Ubuntu can be useful if you want to replicate your environment from one machine or reinstall your Ubuntu operating system on the machine. The list of installed packages will help you know more about your system packages and their related information. On the other hand, when installing, reinstalling, or uninstalling packages, the first step you should do is to list the installed packages on your system. This operation allows you to check the package version and cross-check whether the package needs to be updated or not.

However, how can you tell which package is installed or how you can retrieve the list of the installed packages on your system? Do you know how to do that? We are here to rescue you. Now we will demonstrate how to list installed packages on Ubuntu. So let’s get started!

How to list installed packages on Ubuntu using apt command

The apt stands for Advanced Packaging Tool whereas the “apt command” is used to interact with this package management system. For the first time, it was embedded in Ubuntu 14.04. This package management utility has the collective features of the most regularly used commands from apt-cache and apt-get. It can also list the installed packages while the apt-get command lacks this basic option.

Using the apt utility, if you want to list installed packages on your system, for that, write out the below-given command in your terminal:

$ sudo apt list --installed

The execution of the above-given command will list all the packages that you have installed with apt. It will also list out the dependencies present on your system. This implies that the list will show you the installed applications; moreover, you will see the large number of libraries and packages that you did not install directly:

The simple “apt list –installed” command also lists information related to packages, such as their version and architecture. If you want to make this list easier to read, you can pipe the output of the apt to the “less” command using [“|”] pipe operator. The less command will show you the list of installed packages one page at a time:

$ sudo apt list --installed | less

You have to press “Enter” to move to the next page of the list:

How to list a specific installed package on Ubuntu using apt command

The grep command can be utilized to filter the apt command’s output for verifying if our searched package exists on the system or not. This command lookout for lines that have the pattern specified in the input and then it outputs the matched line to the terminal. For instance, we will combine apt and grep commands using the pipe operator [“|“] to see if “firefox” exists on our system or not:

sudo apt list --installed | grep firefox

The output will show you the following information:

How to list installed packages on Ubuntu using dpkg command

The apt utility might not be available on systems running older versions of Ubuntu. Alternatively, those users can utilize the “dpkg” command. The dpkg utility is used for managing Debian packages. It provides various options, including dpkg-query, which can display information about packages in the dpkg database.

The “-l” option is added in the “dpkg-query” command for listing the installed packages. You can also use the pipe operator [“|”] to pipe the output of the “dpkg-query” command to the “less” command. This will list the installed packages one page at a time:

$ sudo dpkg-query -l | less

The execution of the above-given command will print out a list of installed packages on your system with their version, architecture, and a brief description:

How to list a specific installed package on Ubuntu using dpkg command

To search for a specific package installed on your system, you execute the dpkg command with the grep command. Adding the pipe operator [“|”] will pipe the output of the “dpkg” command to the “grep”. Then the grep command will search for the specific package in the provided output.

For instance, we will search for the “firefox” in the list of installed packages as follows:

$ sudo dpkg-query -l | grep firefox

How to create a list of installed packages on Ubuntu using dpkg command

If you want to create a list of installed applications, you can also perform this operation with the help of “dpkg-query” command. To do so, execute the below-given command in your Ubuntu terminal. This command will save the list of installed packages in the “list.txt” file:

$ sudo dpkg-query -f '${binary:Package}\n' -W > list.txt

Now, write out the cat command with the name of the file containing the list, which is “list.txt” in our case:

$ cat list.txt

This will show you the following output:

Conclusion

It is quite helpful to know how to list installed packages on your Ubuntu system in situations where you have to install the same packages on your system, for instance, when you are reinstalling Ubuntu or replicating the environment on any other machine. This article demonstrated how you can list the installed packages on your Ubuntu system. Try them out for a better understanding and keep following Linux Hint.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.