Configure access to RPM repositories

2. Manage Software

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


In Red Hat-based Linux systems (like RHEL), software is installed using RPM packages. These packages are stored in repositories, which are servers containing software and updates. To manage software efficiently, you must configure access to these repositories.


1. What is a repository?

A repository is:

  • A location (usually on the internet or local network) that stores software packages.
  • Used by yum or dnf (package managers) to install, update, and remove software.

Why it matters:
Without a repository, you’d have to manually download and install RPM files, which is slow and error-prone. Repositories allow automatic installation and updates.


2. Repository Configuration Files

  • Repositories are configured in files inside:
/etc/yum.repos.d/
  • Each repository has a file ending with .repo, e.g., rhel-9-base.repo.
  • File structure:
[repo-id]
name=Repository Name
baseurl=http://server/path/to/repo
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Explanation of key fields

FieldMeaning
[repo-id]Unique ID for the repo (used internally by yum/dnf)
nameFriendly name for the repository
baseurlURL of the repository (can be HTTP, FTP, or local file path)
enabled1 = active repo, 0 = inactive
gpgcheck1 = verify package signature, 0 = skip verification
gpgkeyPath to the GPG key used to sign packages

3. Types of Repositories

  1. Official Red Hat repositories – provided by Red Hat Subscription.
    • Examples: BaseOS, AppStream
  2. Custom/internal repositories – maintained by your organization
    • Useful for internal packages or offline systems
  3. Third-party repositories – like EPEL (Extra Packages for Enterprise Linux)
    • Adds extra software not included in Red Hat base

4. Enabling and Disabling Repositories

  • List all configured repositories:
dnf repolist all
  • Enable a repository:
dnf config-manager --set-enabled <repo-id>
  • Disable a repository:
dnf config-manager --set-disabled <repo-id>
  • Temporary usage without enabling permanently:
dnf --enablerepo=<repo-id> install package_name

Exam Tip: Knowing how to enable, disable, and temporarily use repos is crucial.


5. Adding a New Repository

There are two ways:

A. Using a .repo file

  1. Create a file in /etc/yum.repos.d/:
sudo nano /etc/yum.repos.d/custom.repo
  1. Add content:
[customrepo]
name=My Custom Repository
baseurl=http://server/path/to/repo
enabled=1
gpgcheck=0
  1. Save and verify:
dnf repolist

B. Using dnf config-manager

sudo dnf config-manager --add-repo=http://server/path/to/repo
  • This automatically creates a .repo file.
  • Verify with dnf repolist.

6. Repository Security – GPG Keys

  • Packages are often signed using GPG keys to verify authenticity.
  • Fields used:
    • gpgcheck=1 β†’ enable verification
    • gpgkey=file:///path/to/key β†’ location of the key
  • Importing a GPG key:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Always check gpgcheck=1 for production systems to avoid installing tampered packages.


7. Local Repositories

Sometimes, your server does not have internet access. You can create a local repo from ISO or downloaded packages:

  1. Mount the ISO:
sudo mount -o loop rhel9.iso /mnt
  1. Create .repo file:
[localrepo]
name=Local RHEL 9 Repo
baseurl=file:///mnt
enabled=1
gpgcheck=0
  1. Verify:
dnf repolist

Local repos are often used in data centers or isolated environments.


8. Exam Tips for RHCSA

  1. Know the repo file location: /etc/yum.repos.d/
  2. Be able to add a new repo using .repo file or dnf config-manager
  3. Enable/disable repos with dnf config-manager
  4. Understand GPG keys for package verification
  5. Verify repos using:
dnf repolist
dnf repolist all
  1. Temporary repo usage:
dnf --enablerepo=<repo-id> install <package>
  1. Local repository setup from ISO or local files

βœ… Summary

  • Repositories are software sources.
  • Configured in .repo files under /etc/yum.repos.d/.
  • Can be enabled, disabled, or temporarily used.
  • Use GPG keys to verify package authenticity.
  • Local repos are useful for offline or internal networks.
  • You don’t need to memorize URLs, but know how to configure and use them.
Buy Me a Coffee