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.rpmOptions:
- -i: Install the specified package.
Removing a Package
To remove an installed package, use:
sudo rpm -e package_nameOptions:
- -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.rpmOptions:
- -U: Upgrade the specified package.
Querying Packages
To query installed packages or specific package files, use:
rpm -q package_nameOptions:
- -q: Query the specified package.
Example: To query if a package is installed:
rpm -q httpdTo get detailed information about an installed package:
rpm -qi package_nameOptions:
- -i: Display package information.
Listing Files in a Package
To list files installed by a package, use:
rpm -ql package_nameOptions:
- -l: List the files in the package.
Verifying a Package
To verify the integrity and authenticity of an installed package, use:
rpm -V package_nameOptions:
- -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-KEYAdvanced 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_nameOr with dnf:
sudo dnf install package_nameForce Install/Upgrade
To forcefully install or upgrade a package, ignoring some dependency issues:
sudo rpm -ivh --force package_name.rpmOptions:
- --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.rpmOptions:
- -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.rpmQuerying a Package
To get information about the installed httpd package:
rpm -qi httpdListing Files in a Package
To list all files installed by the httpd package:
rpm -ql httpdVerifying a Package
To verify the integrity of the httpd package:
rpm -V httpdConclusion
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