Skip to main content
In this guide, we explain how to install and update software packages on a RHEL system using YUM. While many RHEL installations still rely on YUM, newer systems may use DNF; in most cases, simply replace “yum” with “dnf” in the commands below. RHEL systems use the Red Hat Subscription Manager (subscription-manager) to manage subscriptions and access updates. When you first set up your RHEL system, you must register it with a valid Red Hat subscription to receive the latest packages and security updates. Otherwise, you might encounter an error message from YUM indicating that the system isn’t registered to Red Hat Subscription Management.
If you are using DNF instead of YUM, almost all commands described here will work similarly by replacing yum with dnf.

Registering with Red Hat Subscription Management

Before accessing software repositories, register your system using your Red Hat Developer account credentials:
After successful registration, attach your system to an available subscription automatically:

Software Repositories

Software repositories contain packages, configuration files, and libraries. These repositories are usually hosted on the internet, though enterprises can host private repositories on a local network.

Viewing Enabled Repositories

To list the repositories currently enabled on your system, run:
The command output will appear similar to:
For more detailed information, including the repository URL addresses, use the verbose flag:
Expected output excerpt:
Here, Repo-baseurl indicates the repository URL, and Repo-filename shows the path to the configuration file on your system.

Enabling Optional Repositories

If the default repositories do not include the package you need, you can enable optional repositories such as the CodeReady Builder RPMs. First, list all available repositories:
The output may include entries like:
To enable an optional repository, use its repo ID:
To disable the repository, replace --enable with --disable:
Alternatively, use yum-utils with the yum-config-manager tool:
Verify changes by listing all repositories again:

Adding Custom Repositories

There are times when you need to add external repositories from a specific URL or a local network. First, ensure that the yum-utils package is installed to access the yum-config-manager:
Next, add a repository. For example, to add an internet-based repository:
For a repository hosted on a local network:
After adding, verify the repository configuration:
You should see an excerpt like the following in the output:

Examining a Custom Repository File

Let’s review the Docker repository file that you added. Open the file using an editor such as Vim:
The initial lines of the file might look like this:
Each element of the repository file serves a purpose:
  1. Repository ID (e.g., [docker-ce-stable])
    A unique identifier required for the repository.
  2. Name (name=Docker CE Stable - $basearch)
    A descriptive label displayed in repository lists.
  3. Base URL (baseurl=https://download.docker.com/linux/rhel/$releasever/$basearch/stable)
    The URL location for the repository.
  4. Enabled Flag (enabled=1)
    Indicates active status. Changing to 0 disables the repository.
  5. GPG Check (gpgcheck=1)
    Enables verification of package integrity using GPG signatures.
  6. GPG Key Location (gpgkey=https://download.docker.com/linux/rhel/gpg)
    Specifies the URL for the GPG key used in verification.
This format provides a blueprint for creating or modifying repository files for troubleshooting and custom configurations. To remove a custom repository, simply delete its configuration file from /etc/yum.repos.d/.

Managing Packages with YUM

YUM is a powerful tool for installing, updating, reinstalling, and removing packages from both repositories and local RPM files.

Searching for Packages

If you are unsure of a package name, use the search feature. For instance, to search for packages related to web servers:
This command searches for any package containing either “web” or “server” in its description:
For exact phrase matching, enclose the search term in single quotes:
This refined search might return:
Once you identify the package (e.g., Nginx), obtain more details by running:
You should see output similar to:

Installing, Reinstalling, and Removing Packages

To install a package like Nginx:
If you need to reinstall a package (for example, if a configuration file was accidentally deleted), use:
To remove a package:
Sometimes, removing a package leaves behind dependencies. You can clean up these unnecessary dependencies with:

Installing Software from an RPM File

YUM can also install packages directly from local RPM files. For example, to install the NoMachine package:
  1. Download the package:
  2. Install the downloaded RPM file:
To uninstall software installed via an RPM file, remove it by package name:
Then, clean up any remaining dependencies:

Managing Package Groups

YUM supports package groups, which allow you to manage related collections of packages together.

Listing Available Groups

List all available package groups with:
To view a comprehensive list, including hidden groups, run:
For example, you might see a group labeled “Server with GUI.”

Installing and Removing Group Packages

To install the “Server with GUI” package group:
To remove the group:

Updating and Upgrading Packages

Keeping your system up to date is crucial. Begin by checking for available package upgrades:
To update all installed packages to their latest versions, run:
After upgrading critical components such as the kernel, it is advisable to reboot your system to ensure all changes take effect properly.

By following the steps in this guide, you can effectively manage software packages and repositories on your RHEL system using YUM. For more detailed information, consider visiting Red Hat’s official documentation. Happy managing!

Watch Video