[email protected]Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedMarch 14, 2023

How use RPM command.

How Use RPM Command.

In this tutorial, we will talk about how to use the rpm command to install, update, remove, verify, query, and otherwise manage RPM packages.

The RPM Package Manager (RPM) is a powerful package management system used by Red Hat Linux and its derivatives such as CentOS and Fedora. RPM also refers to the rpm command and .rpm file format. An RPM Package consists of an archive of files and metadata including information such as dependencies and install location.

 

Installing, Updating and Removing RPM Packages

Usually, to install a new package on Red Hat based distributions, you’ll use either yum or dnf commands, which can resolve and install all package dependencies.

You should always prefer using yum or dnf over rpm when installing, updating, and removing packages.

Before installing an RPM package, you must first download the package on your system using a browser or command-line tools like curl or wget .

When installing RPM packages , make sure they are built for your system architecture and your CentOS version . Be extra careful when replacing or updating important system packages, like glibc, systemd, or other services and libraries that are essential for the proper functioning of your system.

Only root or users with sudo privileges can install or remove RPM packages.

To install an RPM package with the rpm, use the -i option, followed by the package name:

sudo rpm -ivh package.rpm

The -v option tells rpm to show verbose output and the -h option to show the hash marked progress bar.

You can skip the downloading part and provide the URL to the RPM package to the rpm command:

sudo rpm -ivh https://example.com/package.rpm

To upgrade an RPM package, use the -U option. If the package is not installed it will be installed:

sudo rpm -Uvh package.rpm

If the package you are installing or updating depends on other packages that are not currently installed, rpm will display a list of all missing dependencies. You will have to download and install all dependencies manually.

To install an RPM package without having all the required dependencies installed on the system, use the –nodeps option:

sudo rpm -Uvh --nodeps package.rpm

To remove (erase) an RPM package, use the -e option:

sudo rpm -e package.rpm

The –nodeps option is also useful when you want to remove a package without removing its dependencies:

sudo rpm -evh --nodeps package.rpm

The –test option tells rpm to run of instal­lation or removal command without actually doing anything. It only shows whether the command would work or not:

sudo rpm -Uvh --test package.rpm

 

Querying RPM Packages

The -q option tells the rpm command to run a query.

To query (search) whether a certain package is installed, pass the package name to the rpm -q command. The following command will show you whether the OpenJDK 11 package is installed on the system:

sudo rpm -q java-11-openjdk-devel

If the package is installed you will see something like this:

java-11-openjdk-devel-11.0.18.0.10-1.el7_9.x86_64

Pass -i to get more information about the queried package:

sudo rpm -qi java-11-openjdk-devel

To get a list of all the files in an installed RPM package:

sudo rpm -ql package

If you want to find out which installed package a particular file belongs, type:

sudo rpm -qf /path/to/file

To get a list of all installed packages on your system use the -a option:

sudo rpm -qa

 

Verifying RPM Packages

When verifying a package, the rpm command checks whether each file installed by a package exists on the system, the file’s digest, ownership, permissions, etc.

To verify an installed package, use the -V option. For example, to verify the openldap package you would run:

sudo rpm -V openldap-2.4.46-9.el8.x86_64

If the verification pass the command will not print any output. Otherwise, if some of the checks fail, it will show a character indicates the failed test.

For example, the following output shows that the file’s mTime has been changed (“T”):

.......T.  c /etc/openldap/ldap.conf

Refer to the RMP man page about what each character means.

To verify all the installed rpm packages run the following command:

sudo rpm -Va

 

Conclusion

rpm is a low-level command-line tool for installing, querying, verifying, updating, and removing RMP packages. When installing RPM packages should prefer using the yum or dnf as they automatically resolve all dependencies for you.

Keep reading
How to Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Mon – Fri 9:00AM – 5:00PM