In this tutorial, you are going to learn how to check if a package
is installed on Linux using different package management tools. Linux distros ships with quite a number of default system packages installed. However, in most cases, some user specific packages may not be installed by default. As such most Linux users would want to download and install an application/package for their own use.
Linux distributions have created a system for bundling already compiled applications for distribution. This bundle is called a package
, and it consists of most of the files required to run a single application.
Tracking software packages on a Linux system is called package management
. Linux implements package management by using a database to track the installed packages on the system. There are two main package management tools developed by Linux distributions:
- Red Hat package management (RPM)
- Debian package management (APT)
Check If a Package is Installed on Linux
Querying Packages on RHEL Based Distros
Check If a Package is Installed on Linux using RPM command
Developed at Red Hat, the RPM Package Manager (RPM) utility lets you install, modify, and remove software packages. It also eases the process of updating software.
The Red Hat Linux distribution, along with other Red Hat–based distros such as Fedora and CentOS, use RPM
. In addition, there are other distributions that are not Red Hat based, such as openSUSE and OpenMandriva Lx, also employ RPM as well.
RPM package files have an .rpm file extension and follow this naming format:
PACKAGE-NAME-VERSION-RELEASE.ARCHITECTURE.rpm
The main tool for working with RPM files is the rpm
program. The rpm utility is a command-line program that installs, modifies, and removes RPM software packages.
Syntax;
rpm ACTION [OPTION] PACKAGE-FILE
Querying RPM Packages
Using -q
option, it perform a simple query on the package management database to check whether the package is installed or not. i.e, Let’s check if telnet package is installed;
rpm -q telnet
package telnet is not installed
According to the above output the telnet package is not installed.
Now, what if the package is installed?
rpm -q telnet
telnet-0.17-73.el8_1.1.x86_64
You notice that for installed packages, such as telnet, the entire package filename, minus the .rpm file extension, displays.
Perform Detailed Query
The -qi
options provide a great deal of information on the package;
rpm -qi telnet
Name : telnet
Epoch : 1
Version : 0.17
Release : 73.el8_1.1
Architecture: x86_64
Install Date: Sat 24 Apr 2021 02:24:42 PM UTC
Group : Applications/Internet
Size : 156776
License : BSD
Signature : RSA/SHA256, Mon 13 Apr 2020 06:13:23 PM UTC, Key ID 05b555b38483c65d
Source RPM : telnet-0.17-73.el8_1.1.src.rpm
Build Date : Mon 13 Apr 2020 05:58:20 PM UTC
Build Host : x86-01.mbox.centos.org
Relocations : (not relocatable)
Packager : CentOS Buildsys <[email protected]>
Vendor : CentOS
URL : http://web.archive.org/web/20070819111735/www.hcs.harvard.edu/~dholland/computers/old-netkit.html
Summary : The client program for the Telnet remote login protocol
Description :
Telnet is a popular protocol for logging into remote systems over the
Internet. The package provides a command line Telnet client
You notice that from the detailed query, you can determine the package’s version number, installation date, signature, and so on.
Check If a Package is Installed on Linux using YUM
The core tool used for working with Red Hat repositories is the YUM
utility (short for YellowDog Update Manager, originally developed for the YellowDog Linux distribution). Its yum
command allows you to query, software packages on your system directly from an official Red Hat repository.
Syntax;
yum [OPTIONS] [COMMAND] [PACKAGE…]
To check if the package is installed or not with yum
. Use list
command, it displays information of installed packages.Let’s check if telnet package is installed;
yum list telnet
Last metadata expiration check: 0:05:19 ago on Sat 24 Apr 2021 02:42:49 PM UTC.
Available Packages
telnet.x86_64
The above output shows that the telnet command is not installed but it is available in its repository.
Now, what if the package was installed?
yum list telnet
Last metadata expiration check: 0:25:40 ago on Sat 24 Apr 2021 02:42:49 PM UTC.
Installed Packages
telnet.x86_64
The above output shows that the package telnet is installed.
Check If a Package is Installed on Linux using DNF
DNF
is the next upcoming major version of Yum
, a package manager for RPM-based Linux distributions. It roughly maintains CLI compatibility with Yum and defines a strict API for extensions and plugins. The dnf
program (short for dandified yum) is included as part of the Fedora Linux distribution as a replacement for yum
.
Syntax;
dnf [options] <command> [<args>...]
To check if the package is installed or not with dnf
. Use list installed
command, it displays information of installed packages.Let’s check if telnet package is installed;
dnf list installed telnet
Error: No matching Packages to list
The command above, Error: No matching Packages to list shows that the package is not installed.
For the installed packages;
dnf list installed telnet
Installed Packages
telnet.x86_64
The output above shows that the package telnet is installed.
Check If a Package is Installed on Linux using ZYPPER
The openSUSE Linux distribution uses the RPM package management system and distributes software in .rpm files but doesn’t use the yum
or dnf
tool. Instead, openSUSE has created its own package management tool called ZYpp
(also called libzypp). Its zypper
command allows you to query software packages on your system directly from an openSUSE repository.
To check if the package is installed with zypper
utility, use info
command. It displays information about the specified package. Let’s check if telnet package is installed;
zypper info telnet
Loading repository data...
Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
Information for package telnet:
-------------------------------
Repository : Main Repository
Name : telnet
Version : 1.2-lp151.2.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 113.4 KiB
Installed : No
Status : not installed
Source package : telnet-1.2-lp151.2.3.src
Summary : A client program for the telnet remote login protocol
Description :
Telnet is an old protocol for logging into remote systems. It is
rarely used, since the transfer is not encrypted (ssh is mostly used
these days). The telnet client is often used for debugging other
network services. The command
telnet localhost 25
connects to the local smtp server, for example
In the above output, when we check the installed part highlighted in Vivid red it is No
to mean that the telnet package is not installed.
Now let’s check when the package is installed;
zypper info telnet
Loading repository data...
Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
Information for package telnet:
-------------------------------
Repository : Main Repository
Name : telnet
Version : 1.2-lp151.2.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 113.4 KiB
Installed : Yes
Status : up-to-date
Source package : telnet-1.2-lp151.2.3.src
Summary : A client program for the telnet remote login protocol
Description :
Telnet is an old protocol for logging into remote systems. It is
rarely used, since the transfer is not encrypted (ssh is mostly used
these days). The telnet client is often used for debugging other
network services. The command
telnet localhost 25
connects to the local smtp server, for example.
In the above output, when we check the installed part highlighted in Vivid red it is Yes
to mean that the telnet package is installed.
Querying Packages on Debian Based Distros
Debian package management system is mostly used on Debian-based Linux distros, such as Ubuntu. With this system you can install, modify, upgrade, and remove software packages.
Debian Package File Conventions
Debian bundles application files into a single .deb
package file for distribution that uses the following filename format:
PACKAGE-NAME-VERSION-RELEASE_ARCHITECTURE.deb
Using dpkg Command
The core tool to use for handling .deb files is the dpkg
program, which is a command-line utility that has options for installing, updating, and removing .deb package files on your Linux system.
Syntax;
dpkg [OPTIONS] ACTION PACKAGE-FILE
With dpkg
command, to check if the package is installed or not use -l
or --list
option which lists all installed packages matching a specified pattern.
Let’s check if telnet package is installed;
dpkg -l telnet
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un telnet <none> <none> (no description available)
The above output shows that telnet package is not installed.
Now, let’s check when the package is installed;
dpkg -l telnet
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-===============-============-=================================
ii telnet 0.17-41.2build1 amd64 basic telnet client
In the above output, ii means that telnet is installed.
Using apt command
The workhorse of the APT suite of tools is the apt
program. It’s used to install, update, query and remove packages from a Debian package repository.
With apt
program, to check if the package is installed or not use list
action which lists all installed packages matching a specified pattern.
Let’s check if telnet package is installed;
apt list telnet
Listing... Done
telnet/focal 0.17-41.2build1 amd64
The above command shows that telnet is available in its repository but it is not installed in the system.
Now, let’s check when the package is installed;
apt list telnet
Listing... Done
telnet/focal,now 0.17-41.2build1 amd64 [installed]
The output above show that the package telnet is installed
That marks the end of our tutorial on how to check if a package is installed on Linux. Enjoy.
Other Tutorials
How To List Running Services on Linux
How To Check Memory Usage on Linux