How To List Installed Packages In Ubuntu, Debian, Kali, Mint – POFTUT

How To List Installed Packages In Ubuntu, Debian, Kali, Mint


Ubuntu, Debian, Kali and Mint distributions uses apt-get and dpkg commands for package management. We generally use this commands to install or remove packages from Linux systems. But in some cases we may need to list and count installed packages. In this tutorial we will look how to list and count all ready installed packages in Ubuntu, Debian, Kali and Mint.

List Installed Packages and Details with dpkg

We will start with dpkg package manager in order to list installed packages. We will use -l option which will list installed packages with their details. The detailed will provide following information.

$ dpkg -l
List Installed Packages and Details with dpkg
List Installed Packages and Details with dpkg
  • name the package name
  • Version the package version number
  • Architecture the package cpu architecture
  • Description brief information about package

List Installed Packages Names Only with dpkg-query

As we have seen previous example dpkg will list a lot of information. But this will be problem in some cases and we will need only the package name. We can use dpkg-query to only list package names. We also provide some regex for this like below.

$ dpkg-query -f '${binary:Package}\n' -W
List Installed Packages Names Only with dpkg-query
List Installed Packages Names Only with dpkg-query

List Installed Packages Names Only with dpkg

We can also list only installed package names with dpkg too. We will use --get-selections option and some grep to remove lines those contains deinstall like below.

$ dpkg --get-selections | grep -v deinstall | cut -f 1
List Installed Packages Names Only with dpkg
List Installed Packages Names Only with dpkg

List Installed Packages and Details with apt-get or apt

We can also use apt or apt-get inorder to list installed packages and their details. In this example we will use apt and list command by providing --installed parameter to list installed packages.

$ apt list --installed
List Installed Packages and Details with apt-get or apt
List Installed Packages and Details with apt-get or apt

Count Installed Packages with dpkg

We can also count installed packages by simply using wc command. In this example we will list installed package count with dpkg command.

$ dpkg -l | grep -e "^ii" | wc -l
Count Installed Packages with dpkg
Count Installed Packages with dpkg

Count Installed Packages with apt-get

We can also use apt and apt-get for installed package counting like below.

$ apt list --installed | wc -l

Search and Filter In Installed Packages with dpkg and grep

What if we are looking for a specific package and want to list wheter it is installed or not. We can search or filter installed packages with dpkg and grep .

$ dpkg -l  | grep apache2
Search and Filter In Installed Packages with dpkg and grep
Search and Filter In Installed Packages with dpkg and grep

Search and Filter In Installed Packages with apt and grep

We can filter installed packages with apt or apt-get and grep too.

$ apt list --installed | grep apache2
Search and Filter In Installed Packages with apt and grep
Search and Filter In Installed Packages with apt and grep

Save Installed Packages List To A File

As a system administrator we generally need to migrate, clone or setup similar systems with required packages. We can get list of installed packages and install them another system easily. We save installed package names to a file like below.

$ dpkg --get-selections | grep -v deinstall > installed_packages.txt

Install Packages From List File with dpkg

We can restore given file which contains package names we want to install like below. We will use --set-selections.

$ dpkg --set-selections < installed_packages.txt

LEARN MORE  How To Update and Upgrade Ubuntu, Debian, Mint, and Kali?

Leave a Comment