Lesson 77: rpm Command
In this lesson, you'll learn how to use the rpm command to install, update, remove, query, and verify packages on RPM-based Linux distributions.
RPM (Red Hat Package Manager) is a default open-source and most popular package management utility for Red Hat-based systems like RHEL, CentOS, and Fedora.
The tool allows system administrators and users to install, update, uninstall, query, verify, and manage system software packages in Unix/Linux operating systems.
The RPM, formerly known as a .rpm file, includes compiled software programs and libraries needed by the packages.
This utility only works with packages that are built in .rpm format.
Let's discuss some useful RPM command examples so that you can manage to install, update, and remove packages in your Linux systems.
Some Facts About RPM
- RPM is free and released under GPL (General Public License).
- RPM keeps the information of all the installed packages under the
/var/lib/rpmdatabase. - RPM is the only way to install packages under Linux systems. If you've installed packages using source code, then
rpmwon't manage it. - RPM deals with
.rpmfiles, which contain the actual information about the packages such as: what it is, where it came from, dependency info, version info, etc.
Five Basic Modes for the rpm Command
| Mode | Description |
|---|---|
| Install | Used to install any RPM package |
| Remove | Used to erase, remove, or uninstall any RPM package |
| Upgrade | Used to update the existing RPM package |
| Verify | Used to verify RPM packages |
| Query | Used to query any RPM package |
Note: You must be a root user when installing packages in Linux. With root privileges, you can manage rpm commands with their appropriate options.
rpm Command Syntax
# rpm [OPTIONS] [PACKAGE]
rpm Command Options
| Option | Description |
|---|---|
--checksig |
Check the PGP signature of a package |
-i |
Install a package |
-v |
Verbose output for nicer display |
-h |
Print hash marks while unpacking |
-U |
Upgrade a package |
-e |
Erase/remove a package |
-q |
Query a package |
-qa |
Query all installed packages |
-ql |
List all files of an installed package |
-qf |
Find which package a file belongs to |
-qi |
Display information about an installed package |
-qip |
Display information about an uninstalled package file |
-qpR |
List dependencies of a package file |
-qdf |
List documentation files of an installed package |
-Vp |
Verify a specific package |
-Va |
Verify all installed packages |
--nodeps |
Ignore dependency checks during install or remove |
--import |
Import a GPG key |
--rebuilddb |
Rebuild the RPM database |
1. Check the Signature of an RPM Package
Always check the PGP signature of packages before installing them on your Linux systems and make sure their integrity and origin are OK. Use the following command with the --checksig (check signature) option to check the signature of a package called pidgin.