RPM Command in Linux
RPM stands for Red Hat Package Manager. It is an open-source package manager (default) and the most famous utility of package management for Red Hat-based systems such as Fedora, CentOS, and RHEL. The tool permits system users and administrators for installing, updating, uninstalling, querying, verifying, and managing system software packages in Linux/UNIX operating systems.
Formerly, the RPM is called the .rpm file. It contains compiled software libraries and programs required by the packages. It only implements with those packages that were created in .rpm format.
A few facts about RPM
- RPM (Red Hat Package Manager) is free and published upon GPL (General Public License).
- RPM is a single way for installing packages upon Linux systems. If we have installed any package with source code, the RPM would not manage it.
- RPM keeps the details of every installed package in a database, i.e., /var/lib/rpm.
- RPM deals with all the .rpm files. It includes the actual details of the packages like what it is, version info, dependencies info, from where it comes, etc.
Modes of RPM Command
- Install: This mode is used for installing the RPM packages.
- Remove: It is used for erasing, removing, or uninstalling the RPM packages.
- Upgrade: It is used for updating the available RPM packages.
- Verify: This mode is used for verifying the RPM packages.
- Query: This mode is used for querying the RPM packages.
Where to Search RPM Package
The following is the rpm site’s list where we can search and download the RPM packages.
Note: In Linux, please remember we must be a super user at the time of installing the RPM packages. We can manage the rpm commands using appropriate actions with root privileges.
1. Install RPM in Linux
We can install the RPM package using the following command:
2. Check the RPM Signature Package
Before installing the packages on our Linux systems always check a PGP signature of them and ensure their origin and integrity are OK. We can use the below command using an option, i.e., -checksig (stands for check signature) for checking the package’s signature which is known as a apacheds-2.0.0.AM26-i386.rpm.
3. Check the RPM Package Dependency before installing
Let’s assume we wish to check the dependency of the RPM package before upgrading or installing a package. For example, we can use the below command for checking the dependency of a package, i.e., apacheds-2.0.0.AM26-i386.rpm. It will show the package dependencies list:
Where,
- -q: It is used for querying any package.
- -p: It is used for listing the capabilities that this package gives.
- -R: This option is used for listing the capabilities over which the package depends.
4. Install the RPM Package without the Dependencies
If we know that every needed package is already installed and the RPM is only being stupid, then we can avoid the dependencies with the help of the -nodeps option (means no dependency check) before installing any package.
The command is mentioned as follows:
Forcefully, the above command will install the RPM package by avoiding the errors of dependencies. However, when those files of dependency are missing, the program will not implement at all, until we install them.
5. Check the RPM Package (Installed)
Using an option -q along with the package name will display whether the RPM package is installed or not.
The command is as follows:
6. List each file of the installed RPM package
We can use the -ql option (query list) with the RPM command for viewing each file of the installed RPM package.
The command is as follows:
7. List RPM Packages (Recently Installed)
We can apply the below command of RPM with an option, i.e., -qa (query all). This option will list every RPM package that is recently installed.
The output will be as follows:
8. List Each RPM Package (Installed)
We can use the below command for printing each name of the package (installed) on our Linux system.
the output is as follows:
9. Remove the RPM Package
For uninstalling or removing the RPM package, for instance, we can use the name of the package apacheds-2.0.0.AM26-i386.rpm, not the real name of the package apacheds-2.0.0.AM26-i386.rpm. In the following command, we are using an option, i.e., -e (erase) for removing the package.
The output will be as follows:
10. Query the Details of RPM Package (Installed)
Let’s say we have installed any RPM package and we wish to know the details of the package. The below option, i.e., -qi (query info) will print the details of an installed package that are available.
The output is as follows:
11. Details of the RPM Package Before Installing
We have downloaded any package using the Internet and we wish to know the details of this package before installing. The below -qip (query info package) option will print the details about the package.
The output is as follows:
12. Verify the RPM Package
Verify any package will compare the installed file’s information of the package for the data of the RPM. The -Vp (verify package) option is used for verifying the packages.
The output will be as follows:
13. List Each imported GPG Key of RPM
We can use the below command for priting each imported GPG key in our system.
The output is as follows: