1. Overview

Red Hat Enterprise Linux is an enterprise-grade Operating System.

RHEL uses Red Hat Package Manager (RPM) to install, upgrade, and remove software packages. In order to achieve this, we need default YUM repositories setup on the system. Default YUM repositories are the software repositories that are provided by Red Hat with its Linux distribution.

In this article, we’ll familiarize ourselves with the process of setting up default YUM repositories.

2. Importance of YUM Default Repositories

Let’s understand why we need default YUM repositories.

In general, a repository is a storage of software packages. YUM is a Linux utility that works with RPM and helps us download any software package to our local disk from a remote.

For instance, an administrator usually works with various third-party software packages like Datadog or rsyslog. RHEL facilitates this using RPM and YUM default repositories.

If configured correctly, the installation process can automatically download, upgrade, and install software packages when necessary.

Let’s see the basic requirements for setting up default YUM repositories.

3. Ensuring That We Have an Active Subscription

First, we need to install RHEL from an authorized Red Hat source, which comes with default repositories.

For instance, RHEL 9 has two central repositories and is available with all RHEL subscriptions:

  • BaseOS – Supports installations with underlying OS requirements
  • AppStream – Supports installations with varied use cases and workloads

The RHEL installation configures YUM with /etc/yum.conf. As a result, default repositories will be located at /etc/yum.repos.d.

Second, we should check if our system is subscribed to RHEL. The default repositories don’t work unless our system is subscribed to RHEL.
Let’s check the status of the subscription:

$ rhn_check -v echoes

The above command may return a subscription status error:

ERROR: unable to read system id.

If we get this error, we should activate the subscription.

Before subscribing to RHEL, we should’ve set up one of the following repositories in our system:

If our organization has an internal repository, we can register our RHEL servers to that repository.

An offline repository would need to use the built-in repository in the RHEL ISO image. After that, we’d be setting up a base package repository.

On account of our goal here, it’s advisable to use an active repository with Red Hat Subscription Manager. The subscription manager keeps track of our system and the required product subscriptions our organization needs.

4. Setting up Default YUM Repositories

In this section, we’ll learn how YUM repositories are configured and how to activate RHEL subscriptions.

4.1. RPM and YUM Configuration

RPM provides a standard way to package software for distribution. All software packages provided by Red Hat are RPM packages.

Additional software packages are installed and updated from remote package repositories. RPM achieves this through Red Hat subscription management. However, it doesn’t resolve dependencies.

The YUM tool helps manage the software and system dependencies. In other words, when yum installs software A, it checks for system dependency for software A. To install software A, if software B or Software C is required, then Yum installs those first and then installs software A.

The YUM repository configuration files are located in /etc/yum.repos.d/, which mainly includes a repo ID, a name, and the URL of the package repository.

We use yum-config-manager to add repositories and enable them. For instance, suppose we have a default repository called redhat.repo located at /etc/yum.repos.d/redhat.repo.

Let’s have a glance at the commands we will utilize:

$ yum-config-manager --add-repo http://www.example.com/example.repo
$ yum-config-manager --enable repository

To illustrate, let’s look at an example repository:

# yum-config-manager --enable example\*
Loaded plugins: product-id, refresh-packagekit, subscription-manager
============================== repo: example ==============================
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6Server
baseurl = http://www.example.com/repo/6Server/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/6Server/example

When the enable option is set, YUM repositories can download, install, and upgrade packages. The URL mentioned in the repo file will be the source of these packages. On the other hand, if the disable option is set, it won’t allow downloading the package.

Usually, we use the disable option if we want to block a software package from upgrading.

In the next section, we’ll see how to use the subscription manager and register with RHEL.

4.2. Registering and Enabling a Subscription With RHEL

After we’ve completed the RHEL installation, we can use the Red Hat Labs Registration Assistant and follow the instructions on the page to register our system.

Another way is to register and attach any active subscription automatically with the subscription-manager command:

$ subscription-manager register --username <username> --password <password> --auto-attach

If there’s no active subscription, we’ll register using the command:

$ subscription-manager register

Further, on the customer portal, we’ll buy the subscription using the user id and password.

The next step would be to refresh and attach the subscription to our system:

$ subscription-manager refresh
$ subscription-manager attach --auto

Once the system is subscribed, we’ll see the message below:

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64
Status: Subscribed

Now, we’ve registered our systems with RHEL. Going forward, we’ll be able to use default YUM repositories to install or upgrade software packages that are part of the Red Hat subscription.

5. Using EPEL as a Default YUM Repository for Extra Packages

RHEL distribution contains only a subset of packages from Fedora Linux. Many users work with software packages that are part of Fedora but generally don’t ship with RHEL. Those can be downloaded and used via EPEL (Extra Packages for Enterprise Linux) repo.

Fedora’s collection of packages consists mostly of open-source software packages. Furthermore, we can find a list of packages available for different architectures on the Fedora Wiki.

With this in mind to start using EPEL, we need to enable the codeready builder RHEL RPM. Let’s see how to achieve that:

$ ARCH=$( /bin/arch )
$ subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms"

At this point, we’ll install the EPEL RPM:

$ yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Now, we can list available packages and install the required ones:

$ yum --disablerepo="*" --enablerepo="epel" list available 
$ yum install -y example.package

Although EPEL isn’t an official offering from RHEL subscription, it’s handy for developers and admins who work with RHEL often.

6. Conclusion

In this article, we learned why we need default YUM repositories and how to set them up.

First, we saw how we configure YUM repositories. Then we understood the essence of the Red Hat subscription followed by the process of activating the same.

Finally, we looked at the occasional use of the EPEL repository to facilitate software packages.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.