Linux RPM Command with Examples

RPM (RedHat Package Manager) is a utility to facilitate for installing, querying, updating, removing packages in RPM-based Linux Operating System like RedHat, CentOS, Fedora, OpenSUSE, Oracle Linux, Scientific Linux etc. rpm command can only install the specific package, it will not installed the dependencies packages required by that package. 

In this post, we will see some of the useful rpm commands with examples which may be useful for day to day operations. 
Note: RPM tool won’t manage install packages if you have install it using source code.
RPM Command Syntax:
rpm [OPTION] [PACKAGENAME]
Following are the frequently used options with rpm command:
i – install a package
U – upgrade an existing package
q – query package
e – erase or uninstall a package
v – verbose (detail package information)
Also Read: 
. Linux Commands Every Linux System Administrator Should Know With Examples Part-1
. Linux Commands Every Linux System Administrator Should Know With Examples Part-2
. Linux Commands Every Linux System Administrator Should Know With Examples Part-3
. Linux Commands That Every Linux System Administrator Should Know With Examples Part-4
Following are the RPM packages Download Sources.
. From rpmfind website
. Mirror Sites for CentOS
. RedHat Official Website

1. Install RPM Package

You need to download the packages before installing into your system. Usually, rpm-based distributions we use YUM or DNF command to install packages to resolve dependencies. Download package with correct version which suits for your system architecture (Click on picture to enlarge it).
# rpm -ivh telnet-server-0.17-73.el8.x86_64.rpm

Options used with command.
i – Install a package
v – Verbose (progress messages will be displayed on screen)
h – Print 50 hash marks as the package archive is unpacked

2. List dependencies of packages before installing .rpm package.

Following command to check and display dependencies for telnet-server-0.17-73.el8.x86_64.rpm package (Click on picture to enlarge it).
# rpm -qpR telnet-server-0.17-73.el8.x86_64.rpm

Options used with command:
q – Query
p – Package File
R – List capabilities on which this package depends

3. Find or display package information before installing RPM package.

Following command to find and display package information for telnet-server-0.17-73.el8.x86_64.rpm (Click on picture to enlarge it).
# rpm -qip telnet-server-0.17-73.el8.x86_64.rpm
Options used with command:
q – Query
i – Display package information, including name, version, and description. 
– Package File

4. List Specific installed RPM package on your system

Below command to list rpm package if installed with -q option (Click on picture to enlarge it).
# rpm -q  telnet-server

5. all the files for specific installed RPM package.

Displays all the files for installed RPM package using the -ql (query list) with rpm command (Click on picture to enlarge it).
# rpm -ql  telnet-server

6. List recently installed RPM package

In the following command displays recently installed RPM package (Click on picture to enlarge it).
# rpm -qa –last

q – Query
a – All
–last options orders the package listing by install time such that the latest packages are at the top.

7. Update a RPM package

With the following command, you can update the RPM package with the latest RPM package (Click on picture to enlarge it).
Options used with command:
U – Update a package
v – Verbose (progress messages will be displayed on screen)
h – Print 50 hash marks as the package archive is unpacked
# rpm -Uvh telnet-server-0.17-73.el8.x86_64.rpm

8. Install RPM package without dependencies.

With the following command, you can install RPM package without dependencies. (Click on picture to enlarge it):
# rpm -ivh –nodeps telnet-server-0.17-73.el8.x86_64.rpm

Options used with command:
i – Install a package
v – Verbose (progress messages will be displayed on screen)
h – Print 50 hash marks as the package archive is unpacked
–nodeps – No dependencies check.

9. Command to query a file that belongs to which RPM package  

Following command displays by which RPM package is belong to that particular “/usr/sbin/in.telnetd” file (Click on picture to enlarge it).
# rpm -qf /usr/sbin/in.telnetd

10. Remove or Erase RPM package

You can use -ev (erase verbose) option with RPM command to remove or uninstall a particular package (Click on picture to enlarge it).
# rpm -ev telnet-server

Options used with command:
e – Erase or Uninstall a package
v – Verbose (progress messages will be displayed on screen)
Conclusion: In this post, we have learned how to manage packages with RPM command. We hope this may help you to perform day-to-day operations. Please share it with others and also follow us on tecluesdotcom facebook page.

Leave a Comment