
RPM
Red Hat Package Manager, also known as RPM, is a program for installing, uninstalling, and managing software packages in RPM-based Linux distributions. There are various utilities that make use of the rpm utility in the backend, such as yum and dnf, to name two. This is similar in nature to its counterpart, the dpkg utility. Whenever there are dependency requirements, you usually have to go out and manually find the necessary files in order to install them. The packages that rpm manages all end with an rpm extension.
To begin with, we can check for an rpm signature against a package, and we will use the --checksig option:
[root@localhost Downloads]# rpm --checksig gnome-calculator-3.22.3-1.el7.x86_64.rpm
gnome-calculator-3.22.3-1.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
[root@localhost Downloads]#
Based on the preceding output, the signatures have passed the checks using the rpm utility. We can also check for dependencies for a particular package. We use the qpR options for this:
[root@localhost Downloads]# rpm -qpR gnome-calculator-3.22.3-1.el7.x86_64.rpm
/bin/sh
/bin/sh
libatk-1.0.so.0()(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libgmp.so.10()(64bit)
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1
[root@localhost Downloads]#
Note that q means to query, p means to list the capabilities the package provides, and R means to list the capabilities on which the package depends.
In order to view all packages which were recently installed, we can use qa in combination with --last:
[root@localhost Downloads]# rpm -qa --last
gpg-pubkey-f4a80eb5-53a7ff4b Tue 31 Jul 2018 08:30:07 AM PDT
words-3.0-22.el7.noarch Wed 20 Jun 2018 09:29:01 AM PDT
iwl6000-firmware-9.221.4.1-56.el7.noarch Wed 20 Jun 2018 09:29:01 AM PDT
iwl6050-firmware-41.28.5.1-56.el7.noarch Wed 20 Jun 2018 09:29:00 AM PDT
iwl6000g2b-firmware-17.168.5.2-56.el7.noarch Wed 20 Jun 2018 09:29:00 AM PDT
iwl4965-firmware-228.61.2.24-56.el7.noarch Wed 20 Jun 2018 09:29:00 AM PDT
iwl3945-firmware-15.32.2.9-56.el7.noarch Wed 20 Jun 2018 09:29:00 AM PDT
iwl100-firmware-39.31.5.1-56.el7.noarch Wed 20 Jun 2018 09:29:00 AM PDT
iwl7265-firmware-22.0.7.0-56.el7.noarch Wed 20 Jun 2018 09:28:59 AM PDT
fontpackages-filesystem-1.44-8.el7.noarch Wed 20 Jun 2018 09:15:44 AM PDT
centos-release-7-4.1708.el7.centos.x86_64 Wed 20 Jun 2018 09:15:44 AM PDT
[root@localhost Downloads]#
We can also search for a specific package by passing the package name:
[root@localhost Downloads]# rpm -qa ntp
ntp-4.2.6p5-25.el7.centos.2.x86_64
[root@localhost Downloads]#
In this case, we search for the ntp package. We can get more information about a particular package. We can pass the qi options:
[root@localhost Downloads]# rpm -qi ntp
Name : ntp
Version : 4.2.6p5
Vendor : CentOS
URL : http://www.ntp.org
Summary : The NTP daemon and utilities
Description :
The Network Time Protocol (NTP) is used to synchronize a computer's
time with another reference time source. This package includes ntpd
(a daemon which continuously adjusts system time) and utilities used
to query and configure the ntpd daemon.
[root@localhost Downloads]#
Interestingly, before we install a package, we can actually get information on the said package and then make a decision as to whether to abort or continue installation:
[root@localhost Downloads]# rpm -qa gnome-calculator
gnome-calculator-3.22.3-1.el7.x86_64
[root@localhost Downloads]# rpm -e gnome-calculator
[root@localhost Downloads]# rpm -qa gnome-calculator
[root@localhost Downloads]#
We queried for the GNOME calculator because it came preinstalled in this CentOS 7 system. We then removed the package and queried once again. Now we'll pass qip on the rpm package, which we downloaded as follows:
[root@localhost Downloads]# rpm -qip gnome-calculator-3.22.3-1.el7.x86_64.rpm
Name : gnome-calculator
Version : 3.22.3
Release : 1.el7
Architecture: x86_64
Install Date: (not installed)
Group : Unspecified
Size : 5053847
Summary : A desktop calculator
Description :
gnome-calculator is a powerful graphical calculator with financial,
logical and scientific modes. It uses a multiple precision package
to do its arithmetic to give a high degree of accuracy.
[root@localhost Downloads]#
And voila! As we can see, the rpm utility is very powerful. To install a package, we use the -i or --install options:
[root@localhost Downloads]# rpm --install gnome-calculator-3.22.3-1.el7.x86_64.rpm
[root@localhost Downloads]# rpm -qa gnome-calculator
gnome-calculator-3.22.3-1.el7.x86_64
[root@localhost Downloads]#
From the preceding output, we can see that our package was successfully installed using the rpm utility.
We can view all of the files for a particular package:
[root@localhost Downloads]# rpm -ql gnome-calculator
/usr/bin/gcalccmd
/usr/bin/gnome-calculator
/usr/lib64/gnome-calculator
/usr/share/applications/gnome-calculator.desktop
/usr/share/man/man1/gnome-calculator.1.gz
[root@localhost Downloads]#
Likewise, we can remove a package by passing the -e option. We can also view the process of removing a package by adding the -v option:
[root@localhost Downloads]# rpm -ev gnome-calculator
Preparing packages...
gnome-calculator-3.22.3-1.el7.x86_64
[root@localhost Downloads]#
Awesome! Finally, we can determine which package a particular configuration file belongs to using the -qf option:
[root@localhost Downloads]# rpm -qf /etc/rsyslog.conf
rsyslog-8.24.0-12.el7.x86_64
[root@localhost Downloads]#