rpm
rpm
The rpm
command is a package management tool for managing RPM (Red Hat Package Manager) packages. It is used in Red Hat-based distributions, such as Fedora, CentOS, and RHEL (Red Hat Enterprise Linux). The rpm
command allows users to install, query, verify, update, and remove RPM packages.
Basic Usage
Installing a Package
To install an RPM package, use:
sudo rpm -i package_name.rpm
Options:
-i
: Install the specified package.
Removing a Package
To remove an installed package, use:
sudo rpm -e package_name
Options:
-e
: Erase (remove) the specified package.
Upgrading a Package
To upgrade an existing package or install it if it's not already installed, use:
sudo rpm -U package_name.rpm
Options:
-U
: Upgrade the specified package.
Querying Packages
To query installed packages or specific package files, use:
rpm -q package_name
Options:
-q
: Query the specified package.
Example: To query if a package is installed:
rpm -q httpd
To get detailed information about an installed package:
rpm -qi package_name
Options:
-i
: Display package information.
Listing Files in a Package
To list files installed by a package, use:
rpm -ql package_name
Options:
-l
: List the files in the package.
Verifying a Package
To verify the integrity and authenticity of an installed package, use:
rpm -V package_name
Options:
-V
: Verify the specified package.
Importing a GPG Key
RPM packages can be signed with GPG keys to ensure their integrity. To import a GPG key:
sudo rpm --import /path/to/RPM-GPG-KEY
Advanced Usage
Installing from a Repository
For installing packages from repositories, you would typically use yum
or dnf
(the newer package manager for Fedora and RHEL-based distributions). However, you can combine rpm
with yum
/dnf
if you need to:
sudo yum install package_name
Or with dnf
:
sudo dnf install package_name
Force Install/Upgrade
To forcefully install or upgrade a package, ignoring some dependency issues:
sudo rpm -ivh --force package_name.rpm
Options:
--force
: Force the installation or upgrade.-v
: Verbose mode.-h
: Print hash marks as the package archive is unpacked.
Checking Dependencies
To check the dependencies of an RPM package:
rpm -qpR package_name.rpm
Options:
-p
: Query a package file.-R
: List the requirements (dependencies) of the package.
Example Usage
Installing a Package
To install a package named example-1.0-1.x86_64.rpm
:
sudo rpm -i example-1.0-1.x86_64.rpm
Querying a Package
To get information about the installed httpd
package:
rpm -qi httpd
Listing Files in a Package
To list all files installed by the httpd
package:
rpm -ql httpd
Verifying a Package
To verify the integrity of the httpd
package:
rpm -V httpd
Conclusion
The rpm
command is an essential tool for managing software packages on Red Hat-based systems. It provides a comprehensive set of options for installing, querying, verifying, updating, and removing packages. Understanding how to use rpm
effectively can help you manage your system's software efficiently.
help
Last updated