CentOS is a popular Linux distribution that uses the YUM, DNF, and RPM package managers. RPM packages are archives containing software and metadata that can be installed, removed, queried, and updated using the YUM package manager.
This guide will illustrate how to install, remove, query, and update RPM packages in CentOS.
How to Install RPM Packages?
To install an RPM package, utilize the “yum” command with the “install” utility by specifying the package name. The basic syntax to install any rpm package is below:
Syntax:
$ sudo yum install package
In the above syntax, the “package” is the name of the RPM package that users want to install. The “install” option indicates to install the package.
Example:
To install the Apache web server RPM package, use the “yum” command with the “install” option by mentioning the package named “apacheds-2.0.0.AM26-x86_64.rpm”:
$ sudo yum install apacheds-2.0.0.AM26-x86_64.rpm
It installs the Apache web server and all its dependencies.
How to Remove RPM Packages?
To remove an RPM package, use the “yum” command with the “remove” option by specifying the package name. The basic syntax to remove any package is given below:
Syntax:
$ sudo yum remove package
In the above syntax, “package” is the name of the RPM package that the user wants to remove. The “remove” option indicates to erase the package.
Example:
For instance, to remove the Apache web server package, use the “yum” command with the package name “apacheds-2.0.0.AM26-1.x86_64”:
$ sudo yum remove apacheds-2.0.0.AM26-1.x86_64
It removes the Apache web server package and dependencies.
How to Query RPM Packages?
To query information about an RPM package, use the “rpm” command with the “q” option by specifying the package name:
Syntax:
$ sudo yum list package
In the above script, the “package” is the name of the RPM package. The “list” option refers to query information about the package.
Example:
An example is considered to query the “bash” package by the combination of the “yum” and “egrep” commands:
$ sudo yum list installed | egrep -i bash
It displays the information about the bash package including package name, version, release, architecture, vendor, and other information.
How to Update RPM Package?
To update an RPM package to the latest version, use the “yum” command with the “update” option by mentioning the package name:
Syntax:
$ sudo yum update package
In the above syntax, the “package” is the name of the RPM package. The “update” option indicates upgrading the package to the latest version.
Example:
To update the bash package, execute the “yum” command with the “bash.x86_64” package name:
$ sudo yum update bash.x86_64
It downloads and installs the updated bash package and its dependencies.
Conclusion
To install, remove, query, and update RPM packages, use the “yum” command by specifying the package name. This command works with the “install” option to install, the “remove” option to remove, the “list” option to query, and the “update” option to update RPM packages.
This article has illustrated how to install, remove, query, and update RPM packages in Linux.