Knowing how many packages are installed on your computer is often essential. Often there are many packages installed on your computer that you do not even know about. Many of them are pre-installed when you do a fresh install of your operating system. You may want to see and list these packages. In this article, you will learn how to list installed packages in the Ubuntu Linux system. You will learn how to:
- List only installed packages with apt
- List installed packages with dpkg-query
- List recently installed packages
- list the number of installed packages
- List snap packages
For this process, we use the Terminal command line application. You can invoke the Terminal command line by pressing Ctrl+Alt+T.
We have tested the commands on Ubuntu 20.04 and Ubuntu 22.04. But they will work on Debian and earlier Ubuntu versions as well.
List Installed Packages with apt
The apt package manager comes pre-installed with the Ubuntu system. Not only it helps with installing, updating, or removing the software packages, but it also helps to list the installed packages on your system.
To list installed packages on your system, issue the following command in the Terminal:
$ sudo apt list --installed
From the output of the above command, you will get a list of all the packages, including the ones installed as dependencies. The result lists the installed packages’ names along with their versions.
If you want to find the specific package from the list, you can do so with the following grep command in the Terminal:
$ apt list --installed | grep <package>
For instance, to find out the ‘ssh’ package, the command would be:
$ apt list --installed | grep ssh
The output shows that zoom version 5.2.446620.0816 is installed on your system. If it were not installed, you would see the blank output.
List Installed Packages with dpkg-query
With dpkg, you can install and remove packages in your Ubuntu system. You can also use it for listing the installed packages in your system. Contrary to apt command, it displays the output in a more user-friendly way. It shows the result in various columns, making it easier to understand.
To list installed packages on your system, issue the following command in the Terminal:
$ sudo dpkg-query -l
The above output lists the installed packages, the versions, the architecture, and a short description.
If you want to find the specific package from the list, you can do with the following command in Terminal:
$ dpkg-query -l | grep <package>
For instance, to find out the ‘ssh’ package, the command would be:
$ dpkg-query -l | grep ssh
If the output returns the package name and the version, it means the package is installed. Otherwise, you will receive a blank output.
List Recently Installed Packages
In some cases, you only want to list the recently installed packages. To do so, issue the following command in the Terminal:
$ grep " install " /var/log/dpkg.log
Get a Count of Installed Packages
You can also find the number of packages installed in your system using the apt package manager. Issue the following command in the Terminal to do so:
$ apt list --installed | grep -v "^Listing" | wc -l
This command will give you a quick count of the total number of packages installed in your system. The output in the below screenshot tells us there are currently 1716 packages installed in your Ubuntu system.
The dpkg-query command also gives you a quick count of installed packages. To find how many packages are installed in your system, issue the following command in the Terminal:
$ dpkg-query -l | tail -n +6 | awk '{print $1}' | sort | uniq –c
The output in the below screenshot tells us there are currently 1716 packages installed in your Ubuntu system, while one package is removed but only has the configuration file left behind.
List Snap Packages
The commands we have discussed do not list the installed snap packages. To list the installed snap packages, issue the following command in the Terminal:
$ snap list
In this article, we have explained some ways to list the installed packages in Ubuntu. We have explained how to list the packages installed by Debian’s package manager or those installed as snap packages. Additionally, listing the recently installed packages and getting a quick overview of all installed packages were also explained in this article.