In this tutorial, we want to teach you How To Use 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.
How To Use RPM Command in Linux
This tutorial provides some useful RPM command examples that might be helpful to you. With the help of these rpm commands, you can manage to install, update, and remove packages in your Linux systems.
General Syntax of RPM Command
The basic syntax for the rpm command is like this:
sudo rpm [option] [package_name]
To get a full list of options, you can run the command below:
sudo rpm --help
You will get the following output:
Here we list the most popular command options used with the rpm command in Linux:
|Remove (uninstall) package(s).|
|Print hash marks as the package are installed.|
|List files in a package.|
|Display the state of the listed files.|
|Provide more detailed output.|
Now let’s see how to use the rpm command with examples.
Install RPM Packages in Linux
The syntax of installing RPM packages in Linux is like this:
sudo rpm -ivh package_name
Note: Before installing your RPM package, you must download your file. The package has to be compatible with the system architecture of the machine.
For example, to install the MySQL package, you can run the command below:
sudo rpm -ivh mysql80-community-release-el7-5.noarch.rpm
If you want to install an RPM package without previously downloading it, you can use the following syntax:
sudo rpm -ivh package_URL
sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
This will download and install your MySQL package.
Upgrade RPM Packages in Linux
You can easily upgrade your RPM package in Linux by using the syntax below:
sudo rpm -Uvh package_name
RPM upgrades a package by uninstalling the current version and installing the latest one.
sudo rpm -Uvh mysql80-community-release-el7-5.noarch.rpm
Note: If the new version requires additional dependencies, you must install them manually. RPM lists the missing dependencies in the output after running the command.
To ignore the message and update without the dependencies, add the –nodeps option to the command:
sudo rpm -Uvh --nodeps package_name
Delete RPM Packages in Linux
At this point, you can use the following syntax to remove your RPM package:
sudo rpm -e package_name
To see the verbose output, add the -v option to the command:
sudo rpm -ev package_name
To delete an RPM package without removing dependencies, add –nodeps:
sudo rpm -ev --nodeps package_name
For example, to remove MySQL without removing its dependencies, you can run:
sudo rpm -ev --nodeps mysql80-community-release-el7-5.noarch
List Package Information with RPM Command
You can display your available information about your installed RPM package by using the following syntax:
sudo rpm -qi package_name
The output displays the installed information, package version, and a short description.
Note: If you don’t install your RPM package, you can use the command below to get information about your RPM package before installing it:
sudo rpm -qip package_name
Check RPM Package Dependencies
RPM allows you to check the dependencies of packages prior to installing them on the system. Remember that you must have downloaded your file to see your package dependencies. The syntax is like this:
rpm -qpR package_name
Display Installed RPM Packages
At this point, you can easily list all of your RPM installed packages by running the following command:
sudo rpm -qa
Also, you can display a list of all the recently installed packages, using the -qa (query all) option along with the –last attribute:
sudo rpm -qa --last
For more information, you can visit the RPM Documentation page.
At this point, you learn to Use RPM Command in Linux.
Hope you enjoy it.
You may be interested in these articles:
Introducing 5 Linux Mail Servers
How To Install and Configure Chrony in Linux