How to manage Packages on CentOS with YUM

YUM is a high-level package manager that uses the RPM package management tool in the background.

Every Linux distribution has a way to manage software packages. Besides installing software by compiling it from the source, CentOS uses two package management commands: a low-level RPM and a high-level YUM command.

If you ever wondered what YUM stands for, it is an abbreviation for Yellow Dog Updater, Modified. It is a high-level package manager that uses the RPM package management tool in the background. So, how it differs from RPM? I will show you in a minute.

Installing Packages using YUM on CentOS

For the sake of illustration, let’s install a package called httpd, which is an Apache web server. We will use yum install httpd as follows:

yum install httpd

Once you issue that command, a lot of text goes by and you are prompted to press ‘y’ to proceed.

accept-install
Accepting installation

Before you do, take a look at the above text: you can see the package name, it’s architecture, version, repository, and size. Also, you can see that it is installing five other packages as dependencies, totaling 6 installed packages.

RPM vs YUM: When you install a package via RPM, you may have to need some other packages. These are called dependencies. It can sometimes lead to dependency hell, because for example package_a have dependency called package_b, and package_b, in turn, have package_c as the dependency. Package_c can have, you guessed, package_d as dependency and so on.
So we need to download not only package_a but also package_b,package_c and so on. Some package may require as many as 100 dependencies. An additional problem is that we need to install the exact version of the dependency package, that matches the man package. YUM takes care of all of that.

Press y, and once again, and it is finished.

httpd-install-complete
Installation finished

A helpful tip: if you are sure what you are doing then you can automatically accept everything by using -y switch to yum command. For example:

yum -y install httpd

Repositories

Repositories are locations on the internet where all the packages are stored. These are obviously configured somewhere. In CentOS, repositories are stored as files in /etc/yum.repos.d folder. We can take a look at its contents.

/etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo

All there repositories(or “repos”), defined with files ending with .repo are already configured when we install minimal CentOS.

In CentOS 6, we don’t need to manage packages with yum to download an rpm package, because it is available in the default repositories. So let’s try to install it via yum. Example:

yum -y install epel-release

Now let’s see the contents of /etc/yum.repos.d/ again.

ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo epel.repo epel-testing.repo

We can see new files epel.repo and epel-testing.repo. They define repository with hundreds of additional packages for CentOS, RedHat, Scientific Linux and few other clones of RedHat. There is even a way to show all repos and a number of packages they contain with one yum command, yum repolist.

yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.t-2.net
* epel: mirrors.netix.net
* extras: centos.t-2.net
* updates: centos.t-2.net
repo id repo name status
base CentOS-6 - Base 6,713
epel Extra Packages for Enterprise Linux 6 - x86_64 12,506
extras CentOS-6 - Extras 43
updates CentOS-6 - Updates 319
repolist: 19,581

You can see here that epel repository contains amazing 12,514 packages.

Listing installed packages

I showed you in my RPM article how to list installed packages, with rpm -qa. You can also list these with yum, using list installed options.

yum list installed

list-installed
Listing installed packages

Its output is a bit different than the one obtained by the rpm command. It’s up to you to decide which one to use.

Removing Packages

Removing the package is easy, just use erase option when using yum, followed by a package name.

yum erase -y epel-release

Similar to RPM, you don’t have to specify the version of the package, just the name of the package.

Let’s install it again because we will need it again in the article.

yum -y install epel-release

Searching for Packages

You can search for packages from the installed repositories using search options, followed by a pattern. It will search only package name and summary, but if there isn’t a match, it will search in the description and URL. For example, to search for packages that have httpd in their name/summary/description/URL, you should type:

yum search httpd

A lot of packages show some of these don’t have httpd in the package name. Instead, you will see it in the description, for example, mod_auth_mellon.

httpd-search-results
Searching for httpd with yum

You may have noticed that the search is case insensitive, so you don’t have to worry whether you are looking for httpdHttpd or HTTPD.

Retrieve Package Information

Before installation, we can get more information about a certain package by using yum search followed by the package name. Let’s try it with httpd package.

yum info httpd

This shows about every information: its name, architecture, exact version and release, size, and also such things such as from which repo it was installed.

It will show only information about the package exactly called httpd. Since it can produce multiple results, and we want information about all packages that start with httpd, we can use a wild character as well.

yum info httpd*

Conclusion

After a long period where RPM was the prevailing way of installing software, yum is today the preferred way to install software on RedHat compatible Linux operating systems.

YUM was always available, but versions that could be installed out-of-the-box were mostly deprecated. Today, software producers often offer newer versions using yum by means of installing repository via .rpm file. Therefore, for example, if you want to install the newest PHP package, we install a repository that offers that specific version of PHP. Yum is today more powerful than ever, and by getting to know it better, you can make your Linux management much easier.

Kiran Kumar
Hi there! I'm Kiran Kumar, founder of FOSSLinux.com. I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities, especially during Winter ;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails. I hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,555FansLike
365FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

The 10 Best Linux Server Distros For Home And Businesses

By the year 2020, it is estimated that there are close to 600 Linux distributions in the market. It includes both servers and Desktop versions; therefore, if you are looking for lightweight Linux distribution for your old PC or a reliable desktop version for employees in your organization, you may be overwhelmed with the number of choices for finding one for your use.

How to list the installed Packages on Ubuntu

It is only natural to start installing more and more software on your Ubuntu PC once you start using it. Similarly, it is also natural to lose track of the different packages that you have installed on your system. Eventually, you may be overwhelmed with the number of packages in your system and with the ones you hardly used.

How to configure the Ubuntu Firewall (UFW)

A properly configured firewall is a crucial part of establishing preliminary system security. Keeping this in mind, here we will go over how to configure the firewall on your Ubuntu PC.

How to install and use Zoom on Ubuntu

If you work from home or hold meetings with other people remotely, then you have probably heard of Zoom. It is one of the popular video conferencing software app available today.

How to Restart Networking on Ubuntu

Sometimes resetting your Ubuntu network is required to apply some network configurations like changing your IP from Automatic DHCP to static one. Restarting the network is not a big deal, but should be done carefully.

How to install Chrome and Chromium Browser on Pop!_OS

By default, Pop!_OS comes with Mozilla Firefox Browser installed to help you browse the internet. It is a reliable web browser covering almost all the features and functionalities you need. However, working with Firefox is noticeably different compared to Google Chrome, especially from the speed point of view. Google Chrome is a tad quicker than Firefox.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

10 Best Video Editing Software for Linux

This article is for all the Linux users out there who are looking for video editors to create their own professional videos, which can range from short documentaries to even movies.

How to clone hard disk on Linux using Clonezilla

Disk cloning refers to the process of copying data from one disk to another, thus creating a one-to-one copy of the drive. Technically, this process is possible using the copy-and-paste method.

The 6 Best Download Managers for Fedora

It is a well-known fact that using download managers can help improve download speeds as compared to web browsers. Apart from the inbuilt download manager wget on Fedora, just as on any distribution that is based on GNU/Linux package, there are more options to explore.

Guide to watching Disney+ on Linux

Disney Plus or Disney+ is an on-demand entertainment streaming service in which you should see the content produced by Disney Studios, Star Wars, Marvel, Pixar, and National Geographic. The service was launched on the 12th of November 2019.