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
Install yum-utils
package which provides the yumdownloader
command:
sudo yum -y install yum-utils
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-76.el8.x86_64.rpm 660 kB/s | 71 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-*.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
package telnet-1:0.17-76.el8.x86_64 is already installed
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-76.el8.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 : 76.el8
Architecture: x86_64
Install Date: Tue 05 Sep 2023 12:57:33 AM EAT
Group : Applications/Internet
Size : 121656
License : BSD
Signature : RSA/SHA256, Wed 19 May 2021 06:25:21 AM EAT, Key ID 15af5dac6d745a60
Source RPM : telnet-0.17-76.el8.src.rpm
Build Date : Wed 19 May 2021 05:58:45 AM EAT
Build Host : ord1-prod-x86build001.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager : [email protected]
....
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-76.el8 ################################# [100%]
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: 0:58:06 ago on Wed 06 Sep 2023 11:26:11 AM EAT.
=================================================================================== 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
perl-Net-Telnet.noarch : Interact with TELNET port or other TCP ports
rubygem-net-telnet.noarch : Provides telnet client functionality
sdl-telnet-devel.x86_64 : Development files for sdl-telnet
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
putty.x86_64 : SSH, Telnet and Rlogin client
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
Dependencies resolved.
======================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================
Installing:
telnet x86_64 1:0.17-76.el8 appstream 71 k
Transaction Summary
======================================================================================================================================================================================================
Install 1 Package
Total download size: 71 k
Installed size: 119 k
Is this ok [y/N]: y
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
Available Packages
Name : telnet
Epoch : 1
Version : 0.17
Release : 76.el8
Architecture : x86_64
Size : 71 k
Source : telnet-0.17-76.el8.src.rpm
Repository : appstream
...
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
2. 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 update
# apt download telnet
Get:1 https://mirror.hetzner.com/ubuntu/packages jammy/main amd64 telnet amd64 0.17-44build1 [66.9 kB]
Fetched 66.9 kB in 0s (896 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.
# dpkg -i telnet_*_amd64.deb
Selecting previously unselected package telnet.
(Reading database ... 39223 files and directories currently installed.)
Preparing to unpack telnet_0.17-44build1_amd64.deb ...
Unpacking telnet (0.17-44build1) ...
Setting up telnet (0.17-44build1) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
Processing triggers for man-db (2.10.2-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
telnet: /usr/share/doc/telnet
telnet: /usr/share/man/man1/telnet.netkit.1.gz
telnet: /usr/share/doc/telnet/README
python3-twisted: /usr/lib/python3/dist-packages/twisted/conch/test/test_telnet.py
telnet: /usr/share/doc/telnet/changelog.Debian.gz
telnet: /usr/bin/telnet.netkit
telnet: /usr/share/doc/telnet/copyright
telnet: /usr/share/menu/telnet
python3-twisted: /usr/lib/python3/dist-packages/twisted/conch/telnet.py
telnet: /usr/share/lintian/overrides/telnet
libpython3.10-stdlib:amd64: /usr/lib/python3.10/telnetlib.py
ncurses-term: /usr/share/terminfo/t/tgtelnet
telnet: /usr/share/doc/telnet/README.old.gz
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_*_amd64.deb
new Debian package, version 2.0.
size 66948 bytes: control archive=1394 bytes.
1035 bytes, 25 lines control
524 bytes, 8 lines md5sums
435 bytes, 15 lines * postinst #!/bin/sh
165 bytes, 5 lines * postrm #!/bin/sh
137 bytes, 9 lines * prerm #!/bin/sh
Package: telnet
Source: netkit-telnet
Version: 0.17-44build1
Architecture: amd64
Maintainer: Ubuntu Developers <[email protected]>
Installed-Size: 154
Depends: libc6 (>= 2.34), libstdc++6 (>= 5), netbase
Replaces: netstd
Provides: telnet-client
Section: net
Priority: standard
Homepage: http://www.hcs.harvard.edu/~dholland/computers/netkit.html
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.
# dpkg -r telnet
(Reading database ... 39232 files and directories currently installed.)
Removing telnet (0.17-44build1) ...
Processing triggers for man-db (2.10.2-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
.
# dpkg -P telnet
(Reading database ... 39223 files and directories currently installed.)
Purging configuration files for telnet (0.17-44build1) ...
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 https://mirror.hetzner.com/ubuntu/packages jammy InRelease
Hit:2 https://mirror.hetzner.com/ubuntu/packages jammy-updates InRelease
Hit:3 https://mirror.hetzner.com/ubuntu/packages jammy-backports InRelease
Hit:4 https://mirror.hetzner.com/ubuntu/security jammy-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... 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
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
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
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
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.
sudo zypper in telnet
Searching Packages
To search for a package, use the search
(or se
) operator, followed by the package name.
zypper se telnet
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
Verifying Packages
Use the verify or ve operator, it verifies that installed packages have their needed dependencies satisfied.
zypper ve
Removing Packages
To remove a package, use the remove
(or rm
) operator, followed by the package name.
zypper rm telnet
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: