Red Hat Package Manager, also known as RPM, is a program for installing, uninstalling, and managing software packages in RPM-based Linux distributions. There are various utilities that make use of the rpm utility in the backend, such as yum and dnf, to name two. This is similar in nature to its counterpart, the dpkg utility. Whenever there are dependency requirements, you must go out and manually find the necessary files to install them. The packages that rpm manages all end with an rpm extension.
To install a package, the -i option is used. It is generally clubbed with the -v and -h options for verbosity and displays the installation’s progress using hash symbols. The disadvantage of using this method is that RPM cannot resolve the dependency automatically, and hence it will exit installation in-between if it encounters any unmet dependencies while installing the package.
We can use RPM to install a package forcefully by disabling the dependency check during the installation process using the –nodeps option. This method is not recommended as a program may fail to work after, that is, if it is installed without resolving its dependencies.
If you get an error as shown below while running the rpm command:
rpm: command not found
you may try installing the rpm package using the below command as per your choice of distribution.
|OS X||brew install rpm|
|Debian||apt-get install rpm|
|Ubuntu||apt-get install rpm|
|Alpine||apk add rpm|
|Kali Linux||apt-get install rpm|
|CentOS||yum install rpm|
|Fedora||dnf install rpm|
|Raspbian||apt-get install rpm|
rpm Command Examples
1. List all the packages installed in the system:
$ rpm -qa
2. Find a specific package installed in the system by piping the output of the previous command to the grep command, as shown here:
$ rpm -qa | grep kernel
3. Identify the package that installed a file on the system, as shown here:
# rpm -qf /etc/httpd/conf/httpd.conf
4. Display the list of files installed by an RPM package, as shown here:
# rpm -ql httpd
5. Display the recently installed RPM package, as shown here:
# rpm -qa --last
6. Display information on the installed package, as shown here:
# rpm -qi vsftpd
7. Display the documentation of the file installed by a package, as shown here:
# rpm -qdf /usr/bin/wget
8. Display the documentation installed by package, name as shown here:
# rpm -qd yum
9. Display the configuration file installed by the package, as shown here:
# rpm -qc vsftpd
10. Display the list of change information of a specific package, as shown here:
# rpm -q --changelog httpd
11. List versions of all matching packages:
# rpm --query --all 'mariadb*'
12. Forcibly install a package regardless of currently installed versions:
# rpm --upgrade package_name.rpm --force
13. Show scriptlets from an RPM file:
# rpm --query --package --scripts package_name.rpm
14. Show changed, missing and/or incorrectly installed files of matching packages:
# rpm --verify --all 'php-*'