- What is the RPM Command
- RPM Command Syntax
- RPM Command Options
- Install RPM Packages
- Upgrade RPM Packages
- Remove RPM Packages
- List Installed RPM Packages
- Display Package Information Before Installing
- Display Package Information After Installing
- Check Package Dependencies Before Installing
- List All Files of an Installed Package
- RPM Command in Different Linux Distros
1: What is the RPM Command
The RPM command is a software management tool for Linux operating systems. It is used to manage the installation, removal, verification, and upgrading of software packages. RPM is designed to work with packages that are in the RPM format, which is a binary format that contains all the files necessary for installing and running the software.
2: RPM Command Syntax
The basic syntax of the RPM command is as follows:
Here, [OPTIONS] refers to the command options that you can pass to the RPM command, and [PACKAGE] refers to the package that you want to manage.
3: RPM Command Options
To check the complete list of command options, run:
Here are some commonly used options for the RPM command:
-i: install a package
-U: upgrade a package
-e: erase/remove a package
-q: query a package
-V: verify a package
-F: freshen an installed package
-h: display help for a specified RPM command
-v: verbose mode (displays more detailed output)
–test: test mode (simulate the specified command without performing it)
–nodeps: skip dependency checks when installing, upgrading, or removing a package
Note that there are many more options available for the RPM command, and you can find a complete list in the RPM manual page by running man rpm in your terminal.
4: Install RPM Packages
To install an RPM package using the rpm command, follow this syntax:
This command includes the options
- -i for install
- -v for verbose output
- -h to print hash marks to indicate the progress of the installation process
Before installing, ensure that you have downloaded the appropriate package file compatible with your system architecture.
For example, to install the vim-enhanced rpm package, use the following command:
We can also install an RPM package with download link using the following command:
5: Upgrade RPM Packages
During an RPM upgrade, the current version of the package is uninstalled, and the latest version is installed.
The following command can be used to upgrade packages:
This command includes the options
- -U (upgrade)
- -v (verbose mode)
- -h (print hash marks to show upgrading process)
To upgrade vim-enhanced, use:
Manually installing additional dependencies may be required if the new version requires them. In the output after running the command, RPM shows the required dependencies that are missing.
Add the –nodeps option to the command to ignore the message and update without dependencies:
6: Remove RPM Packages
To remove RPM packages, run:
For example, to remove the vim-enhanced RPM, run:
Using yum is another option for uninstalling RPM packages.
For example, to remove vim using yum command run:
7: List Installed RPM Packages
Run the following command to list all installed RPM packages:
The command includes the -qa option, which instructs RPM to query all.
8: Display Package Information Before Installing
Before installing a package, the following command displays information about the RPM package:
To obtain information about a package and confirm its validity, use the options:
- -qi (query information)
- -p (query/verify a package)
For example, to display the information related to vim-enhanced RPM package run:
9: Display Package Information After Installing
An RPM package’s available information can be viewed by using the -qi option, which instructs the program to query the package details:
The output gives us information such as package details.
For example, the following command will give us info related to vim-enhanced:
10: Check RPM Package Dependencies Before Installing
The RPM commands also allow us to check the dependencies of packages before we can install them. Make sure the RPM package is already downloaded for which you want to see the list of dependencies.
The command syntax we use is:
Following is the list of options this command includes:
- -q (query format)
- -p (query/verify a package)
- -R (list package dependencies)
For example, to list all required dependencies by vim-enhanced package you can run:
11: List All Files of an Installed Package
We can also list all the files associated with a package using -ql option, this will instruct RPM to query the list:
For example, we can list vim-enhanced rpm package files using:
12: RPM Command in Different Linux Distros
While the RPM command works similarly across different Linux distributions, there may be some differences in usage and syntax. Here’s a brief overview of RPM commands in different Linux distros:
RPM Package Management in Red Hat-Based Systems
In Red Hat-based systems, RPM is the default package manager. The RPM package management system is used to manage software packages in these systems. To install a package in a Red Hat-based system, you can use the following command:
To remove a package, you can use the following command:
RPM Package Management in Debian-Based Systems
In Debian-based systems, the default package manager is apt. However, you can still use RPM to manage packages in these systems.
RPM is a package manager for the Red Hat system so by default it is not installed on Debian. To install the RPM package manager in a Debian-based Linux system, run:
To install a package in a Debian-based system using RPM, you can use the following command:
Note: The alien utility will convert the RPM package to deb, which you can install using the following command:
RPM Package Management in Arch-Based Systems
In Arch-based systems, the default package manager is pacman. However, you can still use RPM to manage packages in these systems. To install a package in an Arch-based system using RPM, you can use the following command:
Conclusion
The RPM command is a powerful tool for managing software packages in Linux. Whether you’re installing new packages, upgrading existing ones, or removing old ones, RPM makes it easy to keep your system up-to-date and running smoothly. By following the tips and tricks mentioned in this article, you can become proficient in using the RPM command for managing software packages.