Different Linux distributions have developed a system for bundling already compiled applications for distribution called a package. Now, package management is the process of installing, removing and managing the entire application as a singe package in the system. The implementation of package management is based on using a database to track the installed packages on the system. The database keeps track of;

  • Installed packages
  • Exact files and file locations required for each application

Over the years, different Linux distributions have created package management systems and there are main popular which are being used widely today;

  • Red Hat package management (RPM)
  • Debian package management (Apt)
  • ZYpp

1. Red Hat Package Management (RPM)

Red Hat developed RPM Package Manager and its corresponding tool (rpm) which are widely used today not only on RHEL (Red Hat Enterprise Linux) but also in other distributions like CentOS, Fedora, and other operating systems like IBM’S AIX. There are other package management tools popular on Red Hat compatible distributions like yum (YellowDog Updater Modified) and dnf (Dandified YUM). These tools made it much easier to install, configure or remove software from a system.

Using rpm package management commands

There we go, here we are going to learn how use RPM commands to accomplish tasks like installing, searching, querying, verifying, and removing, software in the system. We are going to use the following commands:

  • rpm command
  • yum command

Using yumdownloader Command

To obtain copies of RPM packages for installation on Red Hat based distributions such as CentOS and Fedora use yumdownloader utility. i.e yumdownloader telnet at CLI to download telnet RPM file to your current directory.

$ yumdownloader telnet
CentOS Linux 8 - AppStream                                                                                                              1.1 MB/s | 6.3 MB     00:05    
CentOS Linux 8 - BaseOS                                                                                                                 1.0 MB/s | 2.3 MB     00:02    
CentOS Linux 8 - Extras                                                                                                                  20 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                  179 kB/s | 557 kB     00:03    
Extra Packages for Enterprise Linux 8 - x86_64                                                                                          917 kB/s | 9.1 MB     00:10    
telnet-0.17-73.el8_1.1.x86_64.rpm                                                                                                       170 kB/s |  72 kB     00:00

Installing RPM Packages

When installing a package or software, use rpm -i PACKAGENAME. Where PACKAGENAME is the name of the .rpm package you want to install.  You can add the -v parameter to get a verbose output (more information is shown during the installation) and -h to get hash signs (#) printed as a visual aid to track installation progress.

$ sudo rpm -ivh telnet-0.17-73.el8_1.1.x86_64.rpm
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:telnet-1:0.17-73.el8_1.1         ################################# [100%]

Querying RPM Packages

To perform a simple query on the package management database for installed packages use -q parameter followed by package name.

$ rpm -q telnet
telnet-0.17-73.el8_1.1.x86_64

To get information about an installed package, such as its version number, architecture, install date, packager, summary, etc., -qi parameter followed by package name.

$ rpm -qi telnet
Name        : telnet
Epoch       : 1
Version     : 0.17
Release     : 73.el8_1.1
Architecture: x86_64
Install Date: Wed 24 Mar 2021 05:25:24 AM 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

Verifying RPM Packages

Package verification is very important in terms of security measures. Use -V parameter to query a package, if you get no output or a single dot (.) your package is in good condition.

$ rpm -V telnet

Removing RPM Packages

To remove an installed package in the system use -e parameter. You can add the -v parameter to get a verbose output (more information is shown during the removal) and -h to get hash signs (#) printed as a visual aid to track removal progress.

$ rpm -evh telnet
Preparing...                          ################################# [100%]
Cleaning up / removing...
   1:telnet-1:0.17-73.el8_1.1         ################################# [100%]

2. Using yum Command to manage packages

Searching for Packages using yum

For you to install a package, you need to know its name. You can perform a search with yum search PATTERN, where PATTERN is the name of the package you are searching for. You will obtain a list of packages that contain the search pattern specified.

$ yum search telnet
Last metadata expiration check: 2:21:50 ago on Wed 24 Mar 2021 05:10:14 AM UTC.
==================================================================== Name & Summary Matched: telnet ====================================================================
telnet.x86_64 : The client program for the Telnet remote login protocol
dcap-tunnel-telnet.x86_64 : Telnet tunnel for dCache
libguac-client-telnet.x86_64 : Telnet support for guacd
libtelnet.x86_64 : TELNET protocol parsing framework
libtelnet-devel.x86_64 : Header files for libtelnet
libtelnet-utils.x86_64 : TELNET utility programs from libtelnet
rubygem-net-telnet.noarch : Provides telnet client functionality
telnet-server.x86_64 : The server program for the Telnet remote login protocol
======================================================================= Summary Matched: telnet ========================================================================
procServ.x86_64 : Process server with telnet console and log access

Installing Packages using yum

To install a package using yum, use the command yum install PACKAGENAME, where PACKAGENAME is the name of the package. yum will fetch the package and corresponding dependencies from an online repository, and install everything in your system.

$ yum install telnet
Last metadata expiration check: 10:21:33 ago on Tue 23 Mar 2021 08:58:34 PM UTC.
Dependencies resolved
========================================================================================================================================================================
 Package                             Architecture                        Version                                           Repository                              Size
========================================================================================================================================================================
Installing:
 telnet                              x86_64                              1:0.17-73.el8_1.1                                 appstream                               72 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package

Total download size: 72 k
Installed size: 153 k
Is this ok [y/N]: y
Downloading Packages:
telnet-0.17-73.el8_1.1.x86_64.rpm                                                                                                        35 kB/s |  72 kB     00:02    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    35 kB/s |  72 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                1/1 
  Installing       : telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 
  Running scriptlet: telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 
  Verifying        : telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 

Installed:
  telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                                       

Complete!

Querying Packages using yum

To obtain information about a package, such as its version, architecture, description, size and more, use yum info PACKAGENAME where PACKAGENAME is the name of the package you want information for.

$ yum info telnet
Last metadata expiration check: 2:30:02 ago on Wed 24 Mar 2021 05:10:14 AM UTC.
Available Packages
Name         : telnet
Epoch        : 1
Version      : 0.17
Release      : 73.el8_1.1
Architecture : x86_64
Size         : 72 k
Source       : telnet-0.17-73.el8_1.1.src.rpm
Repository   : appstream
Summary      : The client program for the Telnet remote login protocol
URL          : http://web.archive.org/web/20070819111735/www.hcs.harvard.edu/~dholland/computers/old-netkit.html
License      : BSD
Description  : Telnet is a popular protocol for logging into remote systems over the
             : Internet. The package provides a command line Telnet client

Removing Packages using yum

To remove an installed package, use yum remove PACKAGENAME, where PACKAGENAME is the name of the package you wish to remove.

$ yum remove telnet
Dependencies resolved.
========================================================================================================================================================================
 Package                             Architecture                        Version                                          Repository                               Size
========================================================================================================================================================================
Removing:
 telnet                              x86_64                              1:0.17-73.el8_1.1                                @appstream                              153 k

Transaction Summary
========================================================================================================================================================================
Remove  1 Package

Freed space: 153 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                1/1 
  Erasing          : telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 
  Running scriptlet: telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 
  Verifying        : telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                1/1 

Removed:
  telnet-1:0.17-73.el8_1.1.x86_64                                                                                                                                       

Complete!

3. Debian Package Management (Apt)

Debian developed another package manager, Debian Package format (.deb) and its package tool dpkg which are used widely not only on Debian itself, but also on its derivatives i.e Ubuntu and those derived from it. There is another package management tool which has gained popularity in on Debian-based systems, Advanced Package Tool (apt). These tools helped in completing tasks like installing, maintenance and removal of packages does making it much easier.

Example Usage of apt and dpkg Commands

The Debian Package (dpkg) tool is the essential utility to install, search, query and remove software packages on Debian-based systems. We are going to use the following commands:

  • dpkg command
  • apt command

Using dpkg Command

To obtain copies of Debian package files on a Debian-based distro, such as Ubuntu, employ the apt download PACKAGE command. Where PACKAGE is the package name to download i.e. type apt download telnet at the command line to download the telnet Debian package file to your current working directory.

$ apt download telnet
Get:1 http://ke.archive.ubuntu.com/ubuntu focal/main amd64 telnet amd64 0.17-41.2build1 [64.0 kB]
Fetched 64.0 kB in 0s (161 kB/s)
Installing Package

Installing .deb package can be done with dkpg -i PACKAGENAME. Where PACKAGENAME is the name of the .deb file you want to install.

$ sudo dpkg -i telnet_0.17-41.2build1_amd64.deb
Selecting previously unselected package telnet.
(Reading database ... 332472 files and directories currently installed.)
Preparing to unpack telnet_0.17-41.2build1_amd64.deb ...
Unpacking telnet (0.17-41.2build1) ...
Setting up telnet (0.17-41.2build1) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
Processing triggers for man-db (2.9.1-1) ...
Searching Packages

Search command locates the package that owns the specified files. To perform search on Debian-based package system .deb use dpkg -S PACKAGE command. Where PACKAGE is the package name. i.e. dpkg -S telnet

$ dpkg -S telnet
vagrant: /opt/vagrant/embedded/lib/ruby/gems/2.6.0/gems/net-telnet-0.2.0
gns3-server: /usr/share/gns3/gns3-server/lib/python3.8/site-packages/gns3server/utils/asyncio/telnet_server.py
telnet: /usr/share/doc/telnet
telnet: /usr/share/man/man1/telnet.netkit.1.gz
vagrant: /opt/vagrant/embedded/lib/ruby/gems/2.6.0/gems/net-telnet-0.2.0/lib/net
gns3-gui: /usr/share/gns3/gns3-gui/lib/python3.8/site-packages/gns3/__pycache__/telnet_console.cpython-38.pyc
telnet: /usr/share/doc/telnet/README
liburi-perl: /usr/share/perl5/URI/telnet.pm
Querying Packages

To get information about a .deb package, such as its version, architecture, maintainer, dependencies and more, use the dpkg command with the -I parameter, followed by the filename of the package you want to inspect.

$ dpkg -I telnet_0.17-41.2build1_amd64.deb
 new Debian package, version 2.0.
 size 64016 bytes: control archive=1452 bytes.
     979 bytes,    24 lines      control              
     524 bytes,     8 lines      md5sums              
     442 bytes,    15 lines   *  postinst             #!/bin/sh
     172 bytes,     5 lines   *  postrm               #!/bin/sh
     137 bytes,     9 lines   *  prerm                #!/bin/sh
 Package: telnet
 Source: netkit-telnet
 Version: 0.17-41.2build1
 Architecture: amd64
 Maintainer: Ubuntu Developers <[email protected]>
 Original-Maintainer: Mats Erik Andersson <[email protected]>
 Installed-Size: 159
 Depends: netbase, libc6 (>= 2.15), libstdc++6 (>= 5)
 Replaces: netstd
 Provides: telnet-client
 Section: net
 Priority: standard
 Description: basic telnet client
  The telnet command is used for interactive communication with another host
  using the TELNET protocol.
  .
  For the purpose of remote login, the present client executable should be
  depreciated in favour of an ssh-client, or in some cases with variants like
  telnet-ssl or Kerberized TELNET clients.  The most important reason is that
  this implementation exchanges user name and password in clear text.
  .
  On the other hand, the present program does satisfy common use cases of
  network diagnostics, like protocol testing of SMTP services, so it can
  become handy enough.
Removing Packages

To remove a package, pass the -r parameter to dpkg, followed by the package name. i.e. dpkg -r telnet will remove the package telnet in the system.

$ sudo dpkg -r telnet
(Reading database ... 332481 files and directories currently installed.)
Removing telnet (0.17-41.2build1) ...
Processing triggers for man-db (2.9.1-1) ...

Passing the -P parameter to package dpkg followed by package name will remove the package together with its configuration files. i.e dpkg -P telnet.

$ sudo dpkg -P telnet
(Reading database ... 332481 files and directories currently installed.)
Removing telnet (0.17-41.2build1) ...
Purging configuration files for telnet (0.17-41.2build1) ...
Processing triggers for man-db (2.9.1-1) ...

Using apt Command

The Advanced Package Tool (APT) is a package management system, including a set of tools, that greatly simplifies package installation, searching,querying and removal. APT provides features like advanced search capabilities and automatic dependency resolution.

Installing Packages

Before installing software with APT, it is recommended to update the package index first in order to retrieve information about new and updated packages. This is done with the apt update command.

$ sudo apt update
Hit:1 http://ke.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 https://linux.teamviewer.com/deb stable InRelease                                                                                                                
Get:3 http://ke.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                                                                                             
Hit:4 http://ppa.launchpad.net/gns3/ppa/ubuntu focal InRelease                                                                                                         
Get:5 http://dl.google.com/linux/chrome/deb stable InRelease [1,811 B]                                                                                                 
Hit:6 https://repo.skype.com/deb stable InRelease                                                                                                                      
Get:7 http://ke.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]                                                                      
Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]                                                                                   
Fetched 5,300 kB in 5s (1,134 kB/s)                                        
Reading package lists... Done

With the package index updated you may now install a package. This is done with apt install, followed by the name of the package you wish to install. i.e. apt install telnet

$ sudo apt install telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfprint-2-tod1 libllvm9 ubuntu-system-service
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  telnet
0 upgraded, 1 newly installed, 0 to remove and 247 not upgraded.
Need to get 64.0 kB of archives.
After this operation, 163 kB of additional disk space will be used.
Get:1 http://ke.archive.ubuntu.com/ubuntu focal/main amd64 telnet amd64 0.17-41.2build1 [64.0 kB]
Fetched 64.0 kB in 0s (185 kB/s) 
Selecting previously unselected package telnet.
(Reading database ... 332472 files and directories currently installed.)
Preparing to unpack .../telnet_0.17-41.2build1_amd64.deb ...
Unpacking telnet (0.17-41.2build1) ...
Setting up telnet (0.17-41.2build1) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
Processing triggers for man-db (2.9.1-1) ...
Searching Packages

The apt-cache utility can be used to perform operations on the package index, such as searching for a specific package or listing which packages contain a specific file. To perform a search, use apt-cache search followed by a package name.

$ sudo apt-cache search telnet
curl - command line tool for transferring data with URL syntax
libcurl3-gnutls - easy-to-use client-side URL transfer library (GnuTLS flavour)
libcurl3-nss - easy-to-use client-side URL transfer library (NSS flavour)
libcurl4 - easy-to-use client-side URL transfer library (OpenSSL flavour)
libcurl4-doc - documentation for libcurl
libcurl4-gnutls-dev - development files and documentation for libcurl (GnuTLS flavour)
libcurl4-nss-dev - development files and documentation for libcurl (NSS flavour)
libcurl4-openssl-dev - development files and documentation for libcurl (OpenSSL flavour)
libwrap0 - Wietse Venema's TCP wrappers library
libwrap0-dev - Wietse Venema's TCP wrappers library, development files
Removing Packages

To remove a package use apt remove, followed by the package name. i.e apt remove telnet will remove package telnet in the system.

$ sudo apt remove telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfprint-2-tod1 libllvm9 ubuntu-system-service
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  telnet
0 upgraded, 0 newly installed, 1 to remove and 247 not upgraded.
After this operation, 163 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 332481 files and directories currently installed.)
Removing telnet (0.17-41.2build1) ...
Processing triggers for man-db (2.9.1-1) ...

 When a package is removed the corresponding configuration files are left on the system. To remove the package and any configuration files, use the purge parameter instead of remove or the remove parameter with the --purge option.

$ sudo apt remove --purge telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfprint-2-tod1 libllvm9 ubuntu-system-service
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  telnet*
0 upgraded, 0 newly installed, 1 to remove and 247 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 332472 files and directories currently installed.)
Purging configuration files for telnet (0.17-41.2build1) ...

ZYpp Package Manager

OpenSUSE has developed its own package management tool called ZYpp (libzypp) though it uses RPM package management system and distributes software in .rpm files but doesn’t use the yum or dnf tools. It uses zypper command which allows you to install, query, and remove software packages on your system directly from openSUSE repository.

Example Usage of ZYpp Commands

ZYpp is the package management tool used on SUSE Linux and OpenSUSE. Feature-wise it is similar to apt and yum, being able to install, search, query, verify and remove packages from a system, with automated dependency resolution.

Installing Packages

To install a software package, use the install (or in) operator, followed by the package name. i.e zypper in telnet

$ sudo zypper in telnet
Loading repository data...
Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  telnet

1 new package to install.
Overall download size: 57.3 KiB. Already cached: 0 B. After the operation, additional 113.4 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package telnet-1.2-lp151.2.3.x86_64                                                                                     (1/1),  57.3 KiB (113.4 KiB unpacked)
Retrieving: telnet-1.2-lp151.2.3.x86_64.rpm ......................................................................................................................[done]

Checking for file conflicts: .....................................................................................................................................[done]
(1/1) Installing: telnet-1.2-lp151.2.3.x86_64 ....................................................................................................................[done]

Searching Packages

To search for a package, use the search (or se) operator, followed by the package name. i.e zypper se telnet

$ zypper se telnet
Loading repository data...
Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...

S  | Name            | Summary                                               | Type   
---+-----------------+-------------------------------------------------------+--------
   | perl-Net-Telnet | interact with TELNET port or other TCP ports          | package
i+ | telnet          | A client program for the telnet remote login protocol | package
   | telnet-server   | A Server Program for the Telnet Remote Login Protocol | package

Querying Packages

Use the info operator followed by the package name. i.e zypper info telnet This will provide you with the origin repository, package name, version, architecture, vendor, installed size, if it is installed or not, the status (if it is up-to-date), the source package and a description.

$ 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.

Verifying Packages

Use the verify or ve operator, it verifies that installed packages have their needed dependencies satisfied. i.e zypper ve

$ zypper ve
Loading repository data...
Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...

Dependencies of all installed packages are satisfied.

Removing Packages

To remove a package, use the remove (or rm) operator, followed by the package name. i.e zypper rm telnet

$ zypper rm telnet
Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
  telnet

1 package to remove.
After the operation, 113.4 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing telnet-1.2-lp151.2.3.x86_64 .......................................................................................................................[done]

Conclusion

This marks the end of our guide on Managing Software Packages on Linux using different package management tools like Red Hat package management (RPM), Debian package management (Apt) and ZYpp. I hope this guide has been useful.

Here is a list of other articles you can check out:

LPIC 101 – Managing Processes in Linux Systems

LPIC 101 – Managing Shared Libraries in Linux Systems

How To Enable Command Autosuggestions on Zsh

Install and Configure Kitty Terminal Emulator on Linux | macOS