Install and update software packages from Red Hat Network a remote repository or from the local file system
This guide explains how to install and update software packages on a RHEL system using YUM and DNF.
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.
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.
To list the repositories currently enabled on your system, run:
Copy
Ask AI
sudo yum repolist
The command output will appear similar to:
Copy
Ask AI
repo id repo namerhel-8-for-x86_64-appstream-rpms Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)rhel-8-for-x86_64-baseos-rpms Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)
For more detailed information, including the repository URL addresses, use the verbose flag:
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:
Copy
Ask AI
sudo yum repolist --all
The output may include entries like:
Copy
Ask AI
repo idcodeready-builder-for-rhel-8-x86_64-debug-rpmscodeready-builder-for-rhel-8-x86_64-eus-debug-rpmscodeready-builder-for-rhel-8-x86_64-eus-rpmscodeready-builder-for-rhel-8-x86_64-source-rpmscodeready-builder-for-rhel-8-x86_64-rpmsrepo nameRed Hat CodeReady Linux Builder for RHEL 8 x86_64 (Debug RPMs)Red Hat CodeReady Linux Builder for RHEL 8 x86_64 - Extended Update Support (Debug RPMs)Red Hat CodeReady Linux Builder for RHEL 8 x86_64 - Extended Update Support (RPMs)Red Hat CodeReady Linux Builder for RHEL 8 x86_64 - Extended Update Support (Source RPMs)Red Hat CodeReady Linux Builder for RHEL 8 x86_64 (RPMs)statusdisableddisableddisableddisableddisabled
To enable an optional repository, use its repo ID:
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:
Copy
Ask AI
sudo yum install yum-utils
Next, add a repository. For example, to add an internet-based repository:
Let’s review the Docker repository file that you added. Open the file using an editor such as Vim:
Copy
Ask AI
sudo vi /etc/yum.repos.d/docker-ce.repo
The initial lines of the file might look like this:
Copy
Ask AI
[docker-ce-stable]name=Docker CE Stable - $basearchbaseurl=https://download.docker.com/linux/rhel/$releasever/$basearch/stableenabled=1gpgcheck=1gpgkey=https://download.docker.com/linux/rhel/gpg
Each element of the repository file serves a purpose:
Repository ID (e.g., [docker-ce-stable])
A unique identifier required for the repository.
Name (name=Docker CE Stable - $basearch)
A descriptive label displayed in repository lists.
Base URL (baseurl=https://download.docker.com/linux/rhel/$releasever/$basearch/stable)
The URL location for the repository.
Enabled Flag (enabled=1)
Indicates active status. Changing to 0 disables the repository.
GPG Check (gpgcheck=1)
Enables verification of package integrity using GPG signatures.
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/.
If you are unsure of a package name, use the search feature. For instance, to search for packages related to web servers:
Copy
Ask AI
sudo yum search web server
This command searches for any package containing either “web” or “server” in its description:
Copy
Ask AI
cockpit.x86_64 : Web Console for Linux servers
For exact phrase matching, enclose the search term in single quotes:
Copy
Ask AI
sudo yum search 'web server'
This refined search might return:
Copy
Ask AI
nginx.x86_64 : A high performance web server and reverse proxy server
Once you identify the package (e.g., Nginx), obtain more details by running:
Copy
Ask AI
sudo yum info nginx
You should see output similar to:
Copy
Ask AI
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3, and IMAP protocols, with a strong focus on high concurrency, performance, and low memory usage.
Keeping your system up to date is crucial. Begin by checking for available package upgrades:
Copy
Ask AI
sudo yum check-upgrade
To update all installed packages to their latest versions, run:
Copy
Ask AI
sudo yum update
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!