In this tutorial, we are going to provide you with step-by-step instructions on how to list all installed packages with apt on Debian 9. The apt command is a simple, yet powerful command-line tool, used for performing operations such as an installation of new software packages, upgrade of existing software packages, updating of the package list index, listing the installed and available packages and even upgrading the entire Debian based system.
1. List all installed packages on Debian
In order to list all installed packages on a server with Debian 9 installed on it, we can use the ‘apt list’ command:
apt list --installed
The output will be a long list of installed packages, so it will be easier to read if we use the less command:
apt list --installed | less
2. List specific software package on Debian
We can search for a specific software package or group of packages installed on the server, using the grep command. For example, to get a list of all PHP packages installed on the server, we can use the following command-line command:
apt list --installed | grep -i php
This command will list all the packages that have string php within their name.
libapache2-mod-php/stable,now 1:7.0+49 all [installed] libapache2-mod-php7.0/stable,now 7.0.19-1 amd64 [installed,automatic] php/stable,now 1:7.0+49 all [installed] php-cli/stable,now 1:7.0+49 all [installed] php-common/stable,now 1:49 all [installed] php-curl/stable,now 1:7.0+49 all [installed] php-gd/stable,now 1:7.0+49 all [installed] php-json/stable,now 1:7.0+49 all [installed] php-mcrypt/stable,now 1:7.0+49 all [installed] php-mysql/stable,now 1:7.0+49 all [installed] php-readline/stable,now 1:7.0+49 all [installed] php7.0/stable,now 7.0.19-1 all [installed,automatic] php7.0-cli/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-common/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-curl/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-gd/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-json/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-mcrypt/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-mysql/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-opcache/stable,now 7.0.19-1 amd64 [installed,automatic] php7.0-readline/stable,now 7.0.19-1 amd64 [installed,automatic]
3. List installed packages by package name on Debian
We can search for a specific package by supplying the package name, or a part of the package name as an argument:
apt list sendmail Listing... Done sendmail/stable,now 8.15.2-8 all [installed]
4. List specific installed package details on Debian
In order to view specific installed package details, use the ‘apt show ‘ command:
apt show php7.0-mysql
Maintainer: Debian PHP Maintainers <firstname.lastname@example.org>
Installed-Size: 489 kB
Provides: php-mysqli, php-mysqlnd, php-pdo-mysql, php7.0-mysqli, php7.0-mysqlnd, php7.0-pdo-mysql
Depends: php-common (>= 1:35), ucf, php7.0-common (= 7.0.19-1), libc6 (>= 2.15)
Download-Size: 124 kB
APT-Sources: http://httpredir.debian.org/debian stretch/main amd64 Packages
Description: MySQL module for PHP
This package provides the MySQL module(s) for PHP.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
an open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML.
There is no need to run any of these commands as the root user, so no sudo or any other variants are necessary here.
5. List all manually installed packages on Debian
To get a list of all manually installed packages, use the following command-line command:
zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline: apt-get install (?!.*--reinstall)\K.*'
6. List all upgradeable OS packages on Debian
To list the upgradeable OS packages, use:
sudo apt-get update apt list upgradeable | less
7. List all available versions on Debian
To list all available versions, use the following command:
apt list --all-versions | less
8. List both the installed packages and information on available package versions
Another useful utility for listing both the installed packages and information on available package versions which comes with a specific Debian based Linux distribution is apt-show-versions.
The installation of apt-show-versions package is quite simple:
sudo apt-get update sudo apt-get install apt-show-versions
apt-show-versions dovecot-imapd dovecot-imapd:amd64/stretch 1:2.2.27-3+deb9u1 uptodate If you would like to list all packages with apt on Ubuntu 16.04, please click here.
Of course, you don’t have to List All Installed Packages with apt on Debian 9 if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to help you with this. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.