Table of Contents Introduction Redhat recently introduced the System Storage Manager (SSM), a unified user interface that allows uses to manage complicated systems in a
In this article, we will review the most commonly used RPM commands in Linux. These commands play a pivotal role in package management, allowing users to install, update, query, and manage software packages seamlessly on their Linux systems.
In this article, we will review the most commonly used RPM commands in Linux. Every systems administrator should be familiar with most if not all of these commands. In addition, we will review commonly used RPM commands that address the following five RPM modes: Installing, removing, upgrading, verifying, and querying.
Adapted from The Irish Times website – Red Hat Founder Marc Ewing (right) and co-founder Robert Young in 1998. Photograph: Candice C Cusic/AP
In fact, RPM or .rpm
, is a file format or extension referring to the package itself. It has since been adopted by many Linux distributions (distros) like CentOS, OpenSUSE, Oracle Linux, and AIX, just to name a few. Although, yum (for version 7 Linux distros), and now dnf (for version 8+ Linux distros), are more popular options for sysadmins, they are all package managers essentially–with differences in their functionality. However, this article will focus on popular rpm commands familiar to systems administrators, system engineers, and Linux enthusiasts around the world.
Before we begin, let’s download some rpms to install. Click any of the links below to download rpm packages for your Linux distribution. For this demonstration, we will utilize a CentOS7 Linux virtual machine (VM).
Ensure that you have sudo privileges to run rpm commands as root as any attempts to install or remove rpm packages will fail without it. In addition, we will demonstrate rpm installs using the following rpm packages (below):
mlocate-0.26-30.el9.x86_64.rpm
gedit-40.0-6.el9.x86_64.rpm
vsftpd-3.0.2-29.el7_9.x86_64.rpm
vsftpd-3.0.5-5.el9.x86_64.rpm
NOTE: We can also download individual rpms from the CentOS repository by using the yumdownloader
command. Reference this yum article for further details.
This rpm command (below) is used to install mlocate, a Linux utility for finding files. It was executed using the (-ivh) option. The i stands for install and installs the package, v stands for verbose and is responsible for the pretty display. The h stands for print the hash (#) symbol. The hash symbol is printed as the package archive is being unpacked.
[admin@localhost ~]$ sudo rpm -ivh mlocate-0.26-30.el9.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mlocate-0.26-30.el9 ################################# [100%]
More often than not, rpm packages require dependencies and these dependent rpms contain files and libraries that applications rely on to run properly. This is where the yum command is more useful. It automatically accounts for and resolves dependencies. Also, depending on the situation and the package we want installed, we can force a rpm install using the --nodeps
(or ignore dependencies) option (below).
[admin@localhost ~]$ sudo rpm -ivh gedit-40.0-6.el9.x86_64.rpm --nodeps
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:gedit-40.0-6.el9 ################################# [100%]
However, this is not considered best practice. Forcing a rpm install can cause an application to lose some functionality or fail to run entirely. The image below illustrates the rpm install of gedit, a small yet powerful text editor designed for the GNOME desktop.
[admin@localhost ~]$ sudo rpm -ivh gedit-40.0-6.el9.x86_64.rpm
error: Failed dependencies:
desktop-file-utils >= 0.22-6 is needed by gedit-2:40.0-6.el9.x86_64
gsettings-desktop-schemas is needed by gedit-2:40.0-6.el9.x86_64
gspell(x86-64) >= 1.0 is needed by gedit-2:40.0-6.el9.x86_64
gtk3(x86-64) >= 3.22 is needed by gedit-2:40.0-6.el9.x86_64
gtksourceview4(x86-64) >= 4.0.2 is needed by gedit-2:40.0-6.el9.x86_64
gvfs is needed by gedit-2:40.0-6.el9.x86_64
libatk-1.0.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libcairo.so.2()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libgdk-3.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libgdk_pixbuf-2.0.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libgspell-1.so.2()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libgtk-3.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libgtksourceview-4.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libpango-1.0.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libpeas-1.0.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libpeas-gtk-1.0.so.0()(64bit) is needed by gedit-2:40.0-6.el9.x86_64
libpeas-loader-python3(x86-64) is needed by gedit-2:40.0-6.el9.x86_64
python3-gobject >= 3.0.0 is needed by gedit-2:40.0-6.el9.x86_64
zenity is needed by gedit-2:40.0-6.el9.x86_64
As you can see (above), when the gedit package is installed without the --nodeps
option, a number of dependencies are required to install it. The list of failed dependencies does not fully represent what’s missing as some of those dependent rpms also have dependencies. We will review how to check a package for dependencies later on in this post.
The rpm command (below) used to remove the vsftpd (very secure FTP Daemon) package is executed using the (-evh) option. The e stands for erase and removes the package, v stands for verbose, and h prints the hash symbol.
[admin@localhost ~]$ sudo rpm -evh vsftpd
Preparing... ################################# [100%]
Cleaning up / removing...
1:vsftpd-3.0.5-5.el9 ################################# [100%]
The same procedure applies for removing rpm packages using the--nodeps
option. It is possible but not advised. From a best practice standpoint, exercising this option can also negatively affect other running applications on our machine.
[admin@localhost ~]$ sudo rpm -evh vsftpd --nodeps
Preparing... ################################# [100%]
Cleaning up / removing...
1:vsftpd-3.0.5-5.el9 ################################# [100%]
Using the rpm command to remove or install rpms should only be exercised in rare one-off cases where the package requires no dependencies to install it. Or, if the package does not belong to any available repositories. In this instance however, the vsftpd package requires no dependencies to install it properly. Therefore, using the --nodeps
option to remove it will have no impact on our machine.
Photo by admingeek from Infotechys
Referring to the image above, an older version of the vsftpd package (vsftpd-3.0.2-28.el7.x86_64.rpm) was installed. Then, it was updated to its latest version (vsftpd-3.0.2-29.el7_9.x86_64.rpm) as of the date of this publication.
In order to verify an rpm package for potential errors and ensure that everything checks out, pass the -V (verify) option to the rpm command along with the package name.
For this demonstration, we will verify the vsftpd package.
[admin@localhost ~]$ sudo rpm -V vsftpd
You will not see any output from running this command if everything checks out with the installed package (above). The rpm verify command only reports a problem if one exists, and displays the output to your terminal. It will report missing files and dependencies.
[admin@localhost ~]$ sudo rpm -V vsftpd
missing c /etc/vsftpd/vsftpd.conf
missing d /usr/share/doc/vsftpd/COPYING
This is a sample output (above) of what we should expect to see if there’s a problem to report. The letter c in front of the file listing, indicates a configuration file is missing (vsftpd.conf). The d character represents missing documentation files.
[root@localhost ~]# rpm -Va
S.5....T. c /etc/dnf/dnf.conf
....L.... c /etc/pam.d/fingerprint-auth
....L.... c /etc/pam.d/password-auth
....L.... c /etc/pam.d/postlogin
....L.... c /etc/pam.d/smartcard-auth
....L.... c /etc/pam.d/system-auth
.......T. c /etc/openldap/ldap.conf
To verify every package installed on a machine, pass the (-Va) option (a means all) to the rpm command (above). This process could take a few minutes depending on how many rpms are installed on a machine.
The table below displays the letter codes used to indicate a problem with the rpm and what they mean.
Letter Code | Meaning |
c | Missing configuration file(s) |
d | Missing documentation file(s) |
S | File size is different |
M | File mode is different |
5 | MD5 Checksum is different |
D | Major and minor version numbers on a device file are different |
L | Mismatch Link |
U | File ownership is different |
G | File group ownership is different |
T | File time (mtime) is different |
[admin@localhost ~]$ sudo rpm -qa
libgcc-11.4.1-2.3.el9.x86_64
crypto-policies-20231113-1.gite9247c2.el9.noarch
tzdata-2023c-1.el9.noarch
gawk-all-langpacks-5.1.0-6.el9.x86_64
python3-setuptools-wheel-53.0.0-12.el9.noarch
publicsuffix-list-dafsa-20210518-3.el9.noarch
pcre2-syntax-10.40-4.el9.noarch
ncurses-base-6.2-10.20210508.el9.noarch
linux-firmware-whence-20231030-141.el9.noarch
linux-firmware-20231030-141.el9.noarch
libssh-config-0.10.4-11.el9.noarch
libreport-filesystem-2.15.2-6.el9.noarch
dnf-data-4.14.0-9.el9.noarch
kbd-misc-2.4.0-9.el9.noarch
kbd-legacy-2.4.0-9.el9.noarch
hwdata-0.348-9.11.el9.noarch
fonts-filesystem-2.0.5-7.el9.1.noarch
dejavu-sans-fonts-2.37-18.el9.noarch
langpacks-core-font-en-3.0-16.el9.noarch
firewalld-filesystem-1.2.5-1.el9.noarch
coreutils-common-8.32-34.el9.x86_64
[admin@localhost ~]$ sudo rpm -qa | wc -l
675
[admin@localhost ~]$ sudo rpm -ql mlocate
/etc/updatedb.conf
/usr/bin/locate
/usr/bin/updatedb
/usr/lib/.build-id
/usr/lib/.build-id/1c
/usr/lib/.build-id/1c/e0df0507d0a878ad36e20f6879590b1136fdb0
/usr/lib/.build-id/45
/usr/lib/.build-id/45/f571493b6b362c198cb71edd1a0e1a7e383545
/usr/lib/systemd/system/mlocate-updatedb.service
/usr/lib/systemd/system/mlocate-updatedb.timer
/usr/libexec/mlocate-run-updatedb
/usr/share/doc/mlocate
/usr/share/doc/mlocate/AUTHORS
[admin@localhost ~]$ sudo rpm -qf /var/ftp/pub
vsftpd-3.0.5-5.el9.x86_64
--last
option to the rpm -qa (rpm query all installed packages) command, displays recently installed rpm packages to your terminal.
[admin@localhost ~]$ rpm -qa --last
vsftpd-3.0.5-5.el9.x86_64 Sat 20 Jan 2024 12:17:54 AM UTC
mlocate-0.26-30.el9.x86_64 Fri 19 Jan 2024 11:55:52 PM UTC
haveged-1.9.18-1.el9.x86_64 Mon 01 Jan 2024 11:06:48 AM UTC
tuned-2.21.0-1.el9.noarch Mon 01 Jan 2024 11:06:37 AM UTC
python3-perf-5.14.0-391.el9.x86_64 Mon 01 Jan 2024 11:06:37 AM UTC
libtraceevent-1.5.3-3.el9.x86_64 Mon 01 Jan 2024 11:06:37 AM UTC
hdparm-9.62-2.el9.x86_64 Mon 01 Jan 2024 11:06:37 AM UTC
virt-what-1.25-5.el9.x86_64 Mon 01 Jan 2024 11:06:36 AM UTC
python3-pyudev-0.22.0-6.el9.noarch Mon 01 Jan 2024 11:06:36 AM UTC
python3-linux-procfs-0.7.3-1.el9.noarch Mon 01 Jan 2024 11:06:36 AM UTC
polkit-pkla-compat-0.1-21.el9.x86_64 Mon 01 Jan 2024 11:06:36 AM UTC
polkit-libs-0.117-11.el9.x86_64 Mon 01 Jan 2024 11:06:36 AM UTC
polkit-0.117-11.el9.x86_64 Mon 01 Jan 2024 11:06:36 AM UTC
We’ve reviewed the most commonly used rpm commands by Linux professionals and enthusiasts. However, we’re not scratching the surface of what’s possible. What do you think of our list? Are there rpm commands options you believe should belong on this list? If so, let us know in the comments section.
Related Posts
Table of Contents Introduction Redhat recently introduced the System Storage Manager (SSM), a unified user interface that allows uses to manage complicated systems in a
Table of Contents Introduction According to the Linux manual pages (man yum), there are 35 standard YUM commands. That number increases to the hundreds when
Configuring autofs in Linux is a straightforward task. This article will guide you through the process of setting up and enabling the autofs service. Table