How to install and manage packages on CentOS using RPM

RPM is the abbreviation for Red Hat Package Manager. Applications can be managed on CentOS using RPM as well as YUM. This article focuses on RPM use.

Every Linux distribution has its own way to manage software packages. CentOS uses two package management commands: a low-level RPM and a high-level YUM command.

RPM is the abbreviation for Red Hat Package Manager. Yes, it is used by Red Hat Enterprise Linux, Fedora, Oracle Linux, and Scientific Linux as well. It is used to manage packages, and in this article, I will show you some basic operations with RPM.

Package installation with RPM on CentOS

We use RPM to install a package from a .rpm file. We need to have a file, so in order to demonstrate it to you, we will download a .rpm file for a package called epel-release, which is a set of additional repositories (you can think of these as software stores) for Fedora and CentOS. It can be found at the following address:

https://dl.fedoraproject.org/pub/epel/6/x86_64/

download-epel
Epel download

Right-click on the epel-release-6.8.noarch.rpm and choose Copy link address. Now go to your Linux command line and download the file using curl.

curl-download
Downloading .rpm with curl

Once downloaded, we can install the .rpm file by using -i option to rpm command.

rpm-install
Installing .rpm package

Listing installed packages

Now we expect the package to be installed and available but how can we make sure it really is? Rpm command has an option to list all installed rpm packages, using the -qa option.

This will list all installed packages but we use can use grep to filter the results to only show our package. So let’s do it.

list-packages
Filter installed packages

On clean CentOS 6 minimal installation, there are a lot of installed packages, and you can see their exact number by counting the lines.

packages-number
Showing the number of installed packages

Removing packages

If we decide that we don’t need a package anymore, we can uninstall it. It can be done using the same rpm command, only with a different option, -e, followed by a package name. Note that this is NOT the file name.

package-removal
Removing installed package

After removal, we listed installed packages, and see that there isn’t epel-release any more. Did you notice that I did not specify the full package name with the version number? Well, you don’t have to specify the version number, basic package name will suffice.

Offline Installation

Although the usual way of installing a .rpm file is to install it from a local file system, you can also install it from a remote location. Let’s use the download link we obtained before, and just use it as if it is a physical file:

remote-install
Installing package remotely

Listing package files

There is one useful option to rpm command, and that is -ql option. It lists all the files that are installed with the package. epel-release is not very interesting, so we might try to list files that belong to one installed package called openssh-server.

openssh-server-files
Contents of openssh-server package

Package “ownership” of a file

You may ask the question: which package installed a specific file, or rather, to which package a file belongs to. Option -qf followed by a file name(full path) shows a package that installed a file.

ls-package
Ls command belongs to a coreutils package

Package information

We can get more information about the installed package like its version and release numbers, description when it was installed and so on. It is used with -qi option to rpm, followed by an installed package name.

package-information
Information about installed package

Even more, with -qip option to rpm, we can get information about the package from the package file, before it was even installed. It is quite useful sometimes when we need to know some additional information.

package-file-information
Information about the package from the package file

The outputs look almost the same. Can you spot the difference? I’ll leave this one to you.

Conclusion

Not so long time ago, rpm and source installs were the main methods to install Linux software packages. Source install (compiling source files) is by default complicated and time-consuming (it can take even hours), and .rpm packages can leave you in a so-called rpm dependency hell.

Luckily, in the last few years, most of the software package producers allow you to configure your system to use the yum installer, even for latest versions of the software. This method is easier and takes care of dependencies automatically.

However, some features of rpm command are still essential to know as a Linux administrator, so getting to know more advance rpm features makes you feel more comfortable while working with Linux in the command line. Therefore rpm is definitely old but not depreciated!

Jasenko Krejic
Hello, My name is Jasenko Krejić, I live in the beautiful town of Banjaluka, Bosnia, and Herzegovina. After wrapping up my master in telecommunications, I have been working with computer systems. A decade ago, I had my first encounter with Linux and immediately fell in love with it because of it being an open-source! I work in an enterprise-level company, but I always try to stay ahead and do various other projects, and learn new technologies. Part of learning is sharing knowledge. I consider it a part of my learning path. I hope that in my articles, I have aggregated my knowledge, explained the material as simple as possible and that I have sparked your curiosity to learn Linux.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,269FansLike
192FollowersFollow

LATEST ARTICLES

essential linux commands
Last week, we shared with you several "cool and fun" commands to get comfortable and confident with the Linux command-line. In our quest to further aid Linux users with mastery of the command line, or CLI, we present you with a variety of command-line utilities essential for all Linux users, regardless of proficiency level.
Test drive linux online
Enter DistroTest.net, a website that allows Linux users to test various distros online, without downloading the ISO or installing the distro. With DistroTest.net, you can check a distro with no muss, no fuss.
screen capture apps linux
Do you want to make a video tutorial for YouTube or show-off your epic victory royale to your friends? Look no further — as we have compiled the 10 Best Screen Capturing Software for Linux. Whether you need to record your desktop screen or take a simple screenshot, FOSSLinux has got your back.