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.
Options | Description |
---|
-i, --install | Install an RPM package. |
---|
-U, --upgrade | Upgrade an RPM package. |
---|
-q, --query | Query RPM package(s) or display information about installed packages. |
---|
-a, --all | Used with -q, lists all installed packages. |
---|
-V, --verify | Verify the integrity of installed packages. |
---|
-e, --erase | Uninstall or erase an RPM package |
---|
-F, --freshen | Upgrade packages but only if a package with the same name is already installed. |
---|
--nodes | Ignore package dependencies during installation or removal. |
---|
--test | Test mode; shows what the rpm command would do without making any changes. |
---|
-h, --hash | Display hash marks (#) to indicate progress during installation or removal. |
---|
--force | Force installation, even if it overwrites files from other packages or has other issues. |
---|
--reinstall | Reinstall an RPM package. |
---|
--import | Import a GPG key for package signature verification. |
---|
--resign | Resign an RPM package with a new GPG key. |
---|
-F, --file | Used with -q, queries which package owns a particular file. |
---|
--package | Used with -q, queries information about an RPM file or package. |
---|
--setperms | Set permissions of package files to their default values. |
---|
--setugids | Set user and group ownership of package files to their defaults. |
---|
--nodigest | Skip digest checks when installing or upgrading packages. |
---|
--rebuilddb | Rebuild the RPM database. |
---|
--testsig | Test the digital signature of an RPM package. |
---|
--showrc | Show RPM configuration settings. |
---|
-h, --help | Display help information. |
---|
--version | 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 Packages2. 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 Packages3. 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 Packages4. 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 Information5. 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 Integrity6. 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 PackagesReal-World Examples of RPM Command in Linux
Let's explore some practical examples of using the rpm command:
1. 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.
2. 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.
3. 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.
4. 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.
5. 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.
Similar Reads
dnf Command in Linux Linux is a versatile operating system. It has many commands that can change the Linux working functionality of the operating system. Every Linux has a different package manager that helps us to install the software in the Linux operating system. The `dnf` command is a package manager command in Red-
4 min read
Linux command in DevOps DevOps engineers use Linux every day because itâs free, fast, and easy to customize. More importantly, most DevOps tools like Docker, Kubernetes, Ansible, Terraform, and Jenkins are built to run best on Linux.In DevOps, you often work on cloud servers (like AWS, Azure, or Google Cloud), and most of
9 min read
lsmod command in Linux with Examples lsmod command is used to display the status of modules in the Linux kernel. It results in a list of loaded modules. lsmod is a trivial program which nicely formats the contents of the /proc/modules, showing what kernel modules are currently loaded. Syntax: lsmod Example: Run lsmod at the command lin
1 min read
uname command in Linux with Examples Linux, renowned for its open-source flexibility and powerful performance, offers a range of commands that reveal the inner workings of your system. Among these, the 'uname' command stands out as a versatile tool that provides key details about your Linux machine. Here, we will learn the basics of th
4 min read
whereis command in Linux with Examples 'whereis' command is used to find the location of source/binary file of a command and manuals sections for a specified file in Linux system. If we compare 'whereis' command with 'find' command they will appear similar to each other as both can be used for the same purposes but 'whereis' command prod
4 min read