RPM package is a free command-line utility to operate Linux-based operating systems. It works under GPL General Public License and with the .rpm files containing all the RPM packages’ information. RPM package contains the archive of files having other information about dependencies and installation of the .rpm files.
RPM package manager is used for installing, uninstalling, updating, and managing software packages. It installs packages for Linux-based operating systems. The RPM package has libraries and programs necessary for installing the .rpm software. Let’s understand the RPM command with the help of the following topics:
- How to Install RPM Packages in Linux?
- General Syntax of RPM Command
- Options for RPM Command
- What are the Modes for the RPM Command?
- How to Install Packages & Dependencies Using RPM?
- How to Upgrade Packages Using RPM?
- How to Verify Packages Using RPM?
- How to Query Packages Using RPM?
- How to Remove Packages in RPM?
How to Install RPM Packages in Linux?
RPM package builder adds required builder packages to the system. This package builder comes by default in some distros if you want to install it in different Linux distributions, use the below-mentioned commands:
$ sudo apt install rpm #Install rpm package manager. $ sudo rpm -i <package_name> #Install rppm package.
$ sudo rpm -i <PackageName.rpm> #For installing rpm package.
General Syntax of RPM Command:
$ sudo rpm [options] [package_name]
- rpm: Rpm represents that the “rpm” package is used.
- options: Add the available options in the “rpm” command to perform the function according to the option/flag.
- package_name: Replace the package-name with the desired package rpm file.
Options for RPM Command
The RPM package has various options to install, remove, upgrade, and remove the files. Below are the most-used options in the RPM command:
Note: To get detailed information about all the options of the RPM command, use the “man rpm” command to get its manual guide.
|a||To get the list of all packages|
|e||Remove/Delete the package|
|–force||Performs the task forcefully|
|F||This command upgrades the existing packages.|
|-h||Shows real-time progress of the process.|
|U||Upgrades and installs the package if it is not installed in the system.|
|v||Shows the complete details of the ongoing tasks.|
|–nodeps||This command is used for not checking the dependencies.|
|q||To query or check the file/package.|
|i||To install the package|
|p||For checking the package file.|
|l||This command lists the files in a package.|
What are the Modes for the RPM Command?
The RPM package manager has five primary modes of operation for managing the Linux operating systems. These modes are the tasks performed by the rpm command. The rpm modes are as follows:
- Install: This mode helps the RPM package to install the software.
- Upgrade: The upgrade mode updates the software for the RPM package manager.
- Verify: The mode verifies the installation of the installed packages.
- Query: The query mode is utilized to check the RPM packages.
- Remove: The remove package helps to delete, remove or uninstall the RPM packages.
Let’s get detailed information about the mode of operations for RPM packages.
How to Install Packages & Dependencies Using RPM?
The RPM package manager contains the required files for installing the packages. The packages can be installed in RPM with and without dependencies.
To get the details about the package and its dependencies before installation, the “rpm” command is used. To check the information about the package before installing it, run the below rpm command in the terminal:
$ sudo rpm -qip <package_name>
q: Query the package
i: Install the package
Before installing the package, we can check the dependencies of the package with the help of the rpm command. To check the list of dependencies, use the following command:
$ rpm -qpR <package-name>
q: Shows the query
R: Shows the list of files within the package.
How to Install a Package in RPM?
The general syntax of the install command for the rpm packages and dependencies is shown below:
$ sudo rpm -i <package_name>
i: The “i” option of the rpm command is used to install a package.
To install a package showing its details like: What is the package version? Details about the dependencies list? Installation Source? And others.
To install a package and get its installation details, use the below command:
$ sudo rpm -ivh <package_name>
i: Install the package
v: verbose/ show details
h: Display real-time installation progress
How to Check the Installation of a Package in RPM?
Do you want to check if the specific package is installed or not? To verify the installation of the package, use the below command utility:
$ sudo rpm -qi <package_name>
How to Upgrade Packages Using RPM?
We need to update & upgrade the packages to the newer versions to benefit from the newer updates. The general syntax for the upgrading of the rpm packages, the below command, is utilized:
$ sudo rpm -U <package-name>
U: Upgrade the package
How to Upgrade Specific Packages in RPM?
To upgrade a specific package by displaying the real-time details, run the below command in the terminal:
$ sudo rpm -Uvh <package_name>
Note: The “U” option of the rpm command upgrades the package and installs the new package if the package does not exist in the system.
How to Upgrade Existing Packages in RPM?
If you want to upgrade the existing packages only, run the below command in the terminal:
$ sudo rpm F <package_name>
How to Upgrade a Package Without Dependencies in RPM?
Are you running low on memory? and want to install the package without dependencies? You can use the rpm option “–nodeps” for that. To install the package without dependencies, utilize the below-written command:
$ sudo rpm -Uvh --nodeps <package_name>
How to Verify Packages Using RPM?
Another helpful mode of the RPM command is its ability to verify packages within the system. We can verify the changes made in other RPM-installed files using the RPM verify mode represented by the “V”. The syntax for verifying the installed package in the RPM is written below:
$ sudo rpm -V <package-name>
- RPM: Shows the RPM command utility.
- V: It represents the verified mode of RPM.
- Package-name: Replace this with your desired RPM installed package.
How to Check/Verify All the Installed Packages?
The RPM command allows you to verify several packages at once. The -Va (Verify All) options enable us to check the list of all the installed packages in RPM:
$ sudo rpm -Va
How to Check or Verify a Single-Installed Package?
If you have installed many packages using the RPM command utility, it will give you a long list of packages in verify mode. To verify a single installed package, run the below command:
$ sudo rpm -Vp <package-name>
How to Query Packages Using RPM?
The query mode will display the desired information about the RPM-installed packages. We can use the query mode from thousands of packages to get the required details. The RPM query mode general syntax is shown below:
$ sudo rpm -q <package-name>
How to List All Files Using Query Mode?
To get a list of all the files included in an RPM-installed package, the “q” query option is concatenated with the “l” list option. The syntax for querying a single package file is:
$ sudo rpm -ql package_name.
How to Query All the Installed Packages?
To query all the packages in the RPM package manager, the below command is utilized:
$ sudo rpm -qa
How to Query the Latest Installed Packages?
The most used option of the query mode is “last”, which provides us with the latest installed RPM packages. To query the recently installed packages in the system, run the following command:
$ sudo rpm -qa --last
How to Remove Packages in RPM?
Removing an unnecessary package from the RPM build package manager is mandatory. Extra packages slow down the system and decrease the system speed, which can be improved by removing those packages. The remove mode of RPM is widely used in Linux, whose syntax is given below:
$ sudo rpm -e <package-name>
- e: Asks to erase the packages.
The “–erase” and “-e” options are utilized for deleting the RPM-installed packages.
$ sudo rpm --erase <package_name>
How to List the Deleted Packages in RPM?
We may need to delete several packages simultaneously from the RPM package manager to check a detailed list of every uninstalled package the “v” option is used. To delete and display the output for every line of code, execute this command:
$ sudo rpm -ev <package_name>
How to Deleted Packages Without Dependencies in RPM?
A package contains multiple dependencies, adding functions to the original packages. We can remove the packages without deleting their dependencies by this command:
$ sudo rpm -ev --nodeps <package_name>
- Nodeps: Used to skip the dependencies.
RPM command allows managing the install, upgrade, verify, query, and remove modes of RPM package builder in Linux. We can install the packages with their dependencies, upgrades the files in the packages, verifies the version of the packages, query the information from the RPM packages, and remove the packages with and without dependencies with the RPM package. Moreover, this guide shows a detailed use of these five modes of RPM command.