Ubuntu is a popular Linux distribution that uses *.deb packages. The package management can be done via different ways or tools like apt, apt-get, dpkg, GUI Package manager, etc. You may ask how can you list installed packages in Ubuntu for different cases by using different tools.
List Installed Packages with apt Command
The apt command is the next generation tool used to manage packages in deb based distributions like Debian, Ubuntu, Mint, Kali, etc. The apt command can be used to list installed packages. Also, the root privileges are required to list installed packages which can be provided with the sudo command like below.
sudo apt list --installed
As we can see that there are a lot of output which lists the installed packages with the following information.
- Package name
- Versions
- Repository
The output can be displayed in a more comfortable way by using the less command. The less command shows the output page by page. The space key can be used to view next page. Also the “page up” and “page down” keys can be used for navigation in the list of the installed packages.
sudo apt list --installed | less
Installed packages can be filtered according to their names by using the grep command. For example, the packages containing the zsh can be listed below.
sudo apt list --installed | grep zsh
List Installed Packages with dpkg Command
The dpkg command can be used to list installed packages. The -l option is provided to the dpkg command to list installed packages like below.
dpkg -l
We can see that the installed packages are listed with their names, version, architecture and description information. The output is not printed to the command line interface completely and the “page up” and “page down” commands can be used to navigate up and down in pages.
We can use the -l option and provide a filter term in order to list installed packages for the specified term. In the following example, we will filter installed packages for the “zsh”.
dpkg -l zsh
List Installed Packages with dpkg-query Command
The dpkg-query is the same command as the dpkg command which provides an alias. The -l option can be used with the dpkg-query command which lists installed packages.
dpkg-query -l
Similar to the dpkg command we can see that the installed packages are listed with their names, version, architecture and description information. The output is not printed to the command line interface completely and the “page up” and “page down” commands can be used to navigate up and down in pages.
The list of the installed packages can be formatted with the dpkg-query command. The -f option is used to specify the output format. Int the following example we will only print the package names.
pkg-query -f '${binary:Package}\n' -W
List Installed Packages with Package Manager
Ubuntu also provides a tool named “Software” in order to manage packages via the GUI. This GUI based package manager can be used to list installed packages. First, open the Software tool and then click on the “Installed” tab like below.
List Installed Snap Packages
Up to now we have provided the way to list installed packages via the package managers apt, dpkg, apt-get etc. where all of them uses the same package database. But with the recent versions of the Ubuntu the snap packages are provided which are stored different package database. So installed snap packages can not be listed with the previous methods. By using the following “snap list” command all installed snap packages can be listed easily.
snap list