The RPM (Red Hat Package Manager) command is a fundamental tool in the world of Linux package management. It is widely used in Red Hat-based distributions like Fedora and CentOS, as well as other RPM-based distributions. The RPM command allows users to install, query, verify, and manage software packages, making it an essential tool for system administrators and Linux enthusiasts. In this article, we will explore the various aspects of the RPM command, including its usage, common options, and real-world examples.
What is RPM?
RPM is a software package management system for installing, updating, and removing software packages on Linux-based systems. Red Hat originally developed it but has been adopted by many other Linux distributions. RPM packages, often denoted with the `.rpm`
file extension contains all the necessary files, metadata, and scripts required to install and manage software on a Linux system.
Basic Syntax of RPM in Linux
The basic syntax of the rpm command is as follows:
rpm [options] [package_name]
Here,
[options] represent various command-line options that control the behavior of the rpm command.
[package_name] refers to the name of the RPM package you want to work with.
Options Available in the `rpm` command in Linux
These options provide a wide range of functionalities and control when working with RPM packages on Linux systems. You can use them to install, upgrade, query, and manage packages effectively.
Install an RPM package.
|
Upgrade an RPM package.
|
Query RPM package(s) or display information about installed packages.
|
Used with -q, lists all installed packages.
|
Verify the integrity of installed packages.
|
Uninstall or erase an RPM package
|
Upgrade packages but only if a package with the same name is already installed.
|
Ignore package dependencies during installation or removal.
|
Test mode; shows what the rpm command would do without making any changes.
|
Display hash marks (#) to indicate progress during installation or removal.
|
Force installation, even if it overwrites files from other packages or has other issues.
|
Reinstall an RPM package.
|
Import a GPG key for package signature verification.
|
Resign an RPM package with a new GPG key.
|
Used with -q, queries which package owns a particular file.
|
Used with -q, queries information about an RPM file or package.
|
Set permissions of package files to their default values.
|
Set user and group ownership of package files to their defaults.
|
Skip digest checks when installing or upgrading packages.
|
Rebuild the RPM database.
|
Test the digital signature of an RPM package.
|
Show RPM configuration settings.
|
Display help information.
|
Display the RPM version.
|
Common RPM Commands and Options
1. Installing RPM Packages
To install an RPM package, you can use the `rpm`
a command followed by the `-i`
(or `--install`
) option and the name of the RPM package file. For example:
rpm -i package.rpm
This command installs the specified package on your system.
Here we are installing Jenkins.
rpm -i /root/jenkins-2.282-1.1.noarch.rpm
Installing Packages
2. Upgrading RPM Packages
To upgrade an installed package with a newer version, use the `-U`
(or `--upgrade`
) option:
rpm -U package.rpm
This command will replace the older version of the package with the new one if it’s already installed
Upgrading Packages
3. To list all installed packages in RPM
To list all installed packages on your system, use the -q (or –query) option with the -a (or –all) flag:
rpm -qa
This will display a list of installed packages along with their names and versions.
Listing Installed Packages
4. Querying RPM Package
To retrieve detailed information about a specific package, use the `-q` (or `–query`) option followed by the package name:
rpm -q package_name
This command will display information like the package name, version, architecture, and more.
Querying Package Information
5. Verifying RPM Package
You can verify the integrity and authenticity of an RPM package without installing it using the `-V`
(or `--verify`
) option. This checks if the package’s files have been modified or deleted:
rpm -V package_name
This command checks whether the package’s files on disk match the information in the RPM database.
Verifying Package Integrity
6. Uninstalling RPM Packages
To remove an installed package, use the `-e` (or `–erase`) option followed by the package name:
rpm -e package_name
This command will uninstall the specified package from your system.
Uninstalling Packages
Real-World Examples of RPM Command in Linux
Let’s explore some practical examples of using the rpm command:
Installing a Package using RPM Command in Linux
Suppose you want to install a package named example.rpm:
rpm -i example.rpm
This command will install the `example. , rpm` package on your system.
Upgrading a Package using RPM Command in Linux
If you have a newer version of the example.rpm package and want to upgrade it, you can use the following command:
rpm -U example.rpm
This will replace the older version with the newer one.
Checking if a Package is Installed using RPM Command in Linux
To retrieve information about the installed example package:
rpm -q example
This will display details like the package name, version, and architecture.
Verifying Package Integrity using RPM Command in Linux
Check the integrity of the example package:
rpm -V example
This command will report any file discrepancies in the package.
Uninstalling a Package using RPM Command in Linux
To remove the example package from your system:
rpm -e example
This will uninstall the package and its associated files.
Conclusion
In this article, we discussed the RPM command which is a versatile tool for managing software packages on Linux systems, especially in RPM-based distributions. Whether you need to install, query, verify, or upgrade packages, RPM provides many options to meet your package management needs. By understanding and mastering the RPM command, you can efficiently maintain and optimize your Linux system.
Share your thoughts in the comments
Please Login to comment...