RPM Facts
Here are some facts about RPM (Red Hat Package Manager):
- RPM is freely available and released under the General Public License (GPL).
- RPM maintains a database of all installed packages, storing this information in the
/var/lib/rpmdirectory. - RPM serves as the primary method for installing packages on Linux systems. If packages have been installed using source code, RPM does not manage them.
- RPM operates with
.rpmfiles, containing vital package information such as its identity, source, dependencies, version details, and more.
Basic Modes for RPM Command
Here are the primary modes for the RPM command:
- Install – The
rpm -icommand installs a new package on the system. - Upgrade – The
rpm -Ucommand upgrades an existing package to a newer version. - Remove – The
rpm -ecommand uninstalls or removes a package from the system. - Query – The
rpm -qcommand queries the RPM database for information about installed packages. - Verify – The
rpm -Vcommand verifies the integrity of installed package files. - Freshen – The
rpm -Fcommand upgrades or installs a package only if it is already installed. - Rebuild Database – The
rpm --rebuilddbcommand rebuilds the RPM database, resolving database corruption issues. - Import GPG Key – The
rpm --importcommand imports a GPG key used for package signature verification. - Query All – The
rpm -qacommand lists all installed packages on the system. - Query Files – The
rpm -qlcommand lists all files installed by a specific package. - Query Documentation – The
rpm -qdcommand lists documentation files provided by a package. - Query Dependencies – The
rpm -qRcommand lists runtime dependencies for a package. - Query Provides – The
rpm -q --providescommand lists capabilities provided by a package. - Query Requires – The
rpm -q --requirescommand lists dependencies required by a package.
Where to Find RPM Packages
You can find RPM packages in several places, depending on your Linux distribution. Here are common locations where you can find and download all RPM packages.
- http://rpmfind.net
- http://www.redhat.com
- https://pkgs.org/
- http://rpm.pbone.net/
Please remember you must be a root user when installing packages in Linux, with the root privileges you can manage rpm commands with their appropriate options.
1. How to Check RPM Package Signature
Always check the PGP signature of packages before installing them on your Linux systems and make sure their integrity and origin are OK.
Use the following command with --checksig (check signature) option to check the signature of a package called hardinfo.
2. How to Install RPM Package
To install an RPM software package, use the following command with -ivh option, which will install the rpm package called hardinfo-2.0.11-FedoraLinux-39.x86_64.rpm on a Linux system.
Let’s break down the components of the above command:
-i: install a package-v: verbose for a nicer display-h: print hash marks (#) to show the progress of the installation.
3. How to Check Dependencies of RPM Package Before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of hardinfo-2.0.11-FedoraLinux-39.x86_64.rpm package.
The command queries and displays the runtime dependencies required by the “hardinfo” package, which helps to identify and ensure that all necessary dependencies are met before installing the package.
Let’s break down the components of the above command:
-q: Query a package.-p: List capabilities this package provides.-R: List capabilities on which this package depends.
4. How to Install RPM Package Without Dependencies
To install an rpm package without dependencies, you can use --nodeps option, which will forcefully install an RPM package without checking or resolving dependencies.
The above command forcefully installs the rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all until you install them.
5. How to Check Installed RPM Package
To check an installed rpm package, you can use -q option, which will query and display information about the installed version of the package.
6. How to Find Where RPM Files are Installed
To view all the files of an installed rpm package, use the -ql (query list) with rpm command.
7. How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.
8. How to List All Installed RPM Packages
Type the following command to print all the names of installed packages on your Linux system.
9. How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.
10. How to Remove a RPM Package
To un-install an RPM package, for example, we use the package name hardinfo, not the original package name hardinfo-2.0.11-FedoraLinux-39.x86_64.rpm. The -e (erase) option is used to remove the package.
11. How to Remove an RPM Package Without Dependencies
The --nodeps (do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing a particular package may break other working applications.
12. How to Find RPM Package of a Specific File
Let’s say, you have a list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd that is owned by package httpd-tools-2.4.58-1.fc39.x86_64.
13. How to Query Information of Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.
14. Get the Information of RPM Package Before Installing
You have downloaded a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.
15. How to Query Documentation of Installed RPM Package
To get the list of available documentation of an installed package, use the following command with the option -qdf (query document file) will display the manual pages related to the vmstat package.
16. How to Verify a RPM Package
Verifying a package compares the information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.
17. How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.
18. How to Import an RPM GPG Key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import the CentOS 8 GPG key.
19. How to List all Imported RPM GPG Keys
To print all the imported GPG keys in your system, use the following command.
20. How To Rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at this time we need to rebuild the rpm database and restore it with the help of the following command.
In conclusion, the presented rpm commands provide a comprehensive guide for efficiently managing software packages on RHEL-based Linux distributions.
No comments:
Post a Comment