Skip to content

Intermediate · Software and networking · topic 20 of 57 · 30 min

Repositories, BaseOS, AppStream and module streams

Explanation

A repository is a server folder of packages with an index. RHEL 9 has two main repositories: BaseOS (the core OS) and AppStream (applications, languages and databases). Repositories are defined in .repo files in /etc/yum.repos.d/ with a name, baseurl, enabled and gpgcheck. AppStream can offer several versions of some software as module streams.

Where packages come from

dnf does not invent packages; it downloads them from repositories (repos). A repo is a folder on a web server, an FTP server or a local disk, holding .rpm files and metadata: an index of what is there. dnf reads the metadata to know what can be installed. On a registered RHEL system the Red Hat repos are set up for you by subscription-manager; on Rocky or Alma they come preconfigured.

bash
$ dnf repolist
repo id                                   repo name
rhel-9-for-x86_64-appstream-rpms          Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)
rhel-9-for-x86_64-baseos-rpms             Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)
$ dnf repolist all          # also disabled repos
RepositoryWhat is in it
BaseOSThe core OS: kernel, systemd, shell, basic tools. Supported for the whole life of the major version.
AppStreamApplications and tools: web servers, databases, languages like Python and Node.js, desktop. Some have shorter life cycles.
CodeReady Linux BuilderExtra developer libraries (disabled by default on RHEL).
EPEL (third party)Extra Packages for Enterprise Linux, built by the Fedora community. Not supported by Red Hat.

Writing a .repo file

A .repo file is a small text file in INI format: a [section] with an ID, then key=value lines. Every file in /etc/yum.repos.d/ ending in .repo is read.

ini
# /etc/yum.repos.d/local.repo
[local-baseos]
name=Local BaseOS
baseurl=http://repo.example.com/rhel9/BaseOS
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[local-appstream]
name=Local AppStream
baseurl=http://repo.example.com/rhel9/AppStream
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  • [local-baseos]: the repo ID. Must be unique and have no spaces.
  • baseurl: where the repo is: http://, https://, ftp:// or file:// for a local folder.
  • enabled=1: use it (0 = ignore).
  • gpgcheck=1: check every package's digital signature against gpgkey, so nobody can slip in a fake package. Keep it on.
bash
# dnf config-manager --add-repo http://repo.example.com/rhel9/BaseOS   # writes a .repo file for you
# dnf config-manager --set-disabled local-appstream
# dnf clean all          # forget cached metadata after changing repos
# dnf repolist
dnf config-manager comes from the dnf-plugins-core package. It does not add gpgcheck lines; check the file it writes.

A repository from the installation ISO

In a lab without internet or a subscription, the RHEL ISO image contains a full BaseOS and AppStream repo. Mount it and point two repos at it with file:// URLs.

bash
# mkdir -p /mnt/iso
# mount -o ro /dev/sr0 /mnt/iso          # or: mount -o loop rhel-9.4-x86_64-dvd.iso /mnt/iso
# ls /mnt/iso
AppStream  BaseOS  EFI  images  isolinux  ...
# then in a .repo file: baseurl=file:///mnt/iso/BaseOS  and  baseurl=file:///mnt/iso/AppStream

Module streams (RHEL 8 and 9)

Some AppStream software is offered in several versions at once, called module streams. For example, nodejs may have streams 18 and 20. You enable one stream, and dnf installs that version. Only one stream of a module can be enabled at a time. Not everything is a module; most packages are normal. RHEL 10 no longer uses modules, so treat this as a RHEL 8/9 skill.

bash
$ dnf module list nodejs
Name     Stream   Profiles                         Summary
nodejs   18       common [d], development, minimal  Javascript runtime
nodejs   20       common [d], development, minimal  Javascript runtime
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
# dnf module enable -y nodejs:20
# dnf module install -y nodejs:20/common
# dnf module reset nodejs        # go back before switching streams

Common mistakes

  • A typo in baseurl (http:/ instead of http://, or the wrong folder). dnf repolist then shows errors like "Cannot download repomd.xml". Open the URL in curl to check: curl -I URL/repodata/repomd.xml.
  • Setting gpgcheck=0 to "make it work". You lose the protection against tampered packages. Import or point to the right key instead.
  • A .repo file without the .repo ending. dnf ignores it.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Repositories, BaseOS, AppStream and module streams · 1/7

repo = packages + metadata

A repository is a folder of packages plus an index that dnf reads.

Prefer a video by a teacher? Find free videos on “rhel 9 configure yum repository repo file baseurl appstream baseos” on YouTube ↗

In real life: An offline data centre for a government department

A state government data centre in Bhubaneswar has no internet access for security reasons. The team runs one internal mirror server that syncs approved Red Hat repos through a controlled link. Every other server has a single /etc/yum.repos.d/internal.repo pointing at that mirror with gpgcheck=1. Installing software works the same as anywhere else, just from an internal URL.

bash
# cat /etc/yum.repos.d/internal.repo
[internal-baseos]
name=Internal BaseOS mirror
baseurl=http://mirror.dc.example.gov.in/rhel9/baseos
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Practice (0/4 done)

Task 1 · Question

Where do .repo files go?

Task 2 · Question

Which line has the bug? 1: [web] 2: name=Web repo 3: baseurl=http:/repo.example.com/web 4: enabled=1 5: gpgcheck=1

Task 3 · Code · Python

Write enabled_repos(text) that reads the text of a .repo file and returns a sorted list of repo IDs that are enabled. A repo is enabled when enabled=1, or when the enabled line is missing (dnf's default is enabled). Use the configparser module.

Task 4 · Practice

Set up the two repositories from the RHEL (or Rocky/Alma) ISO in your VM: attach the ISO, mount it, write /etc/yum.repos.d/iso.repo with both repos and gpgcheck, disable any other repos for this test, and install a package from it.

Quick quiz

Question 1

1.Which RHEL 9 repository holds the kernel and core tools?

Question 2

2.What does gpgcheck=1 protect against?

Question 3

3.What should you run after changing repo files if dnf shows old data?

Question 4

4.How many streams of one module can be enabled at the same time?

Question 5

5.Which baseurl points at a folder on the local disk?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which RHEL 9 repository holds the kernel and core tools?

Answer: BaseOS

BaseOS has the core OS.

What does gpgcheck=1 protect against?

Answer: Installing packages that were tampered with or not signed by a trusted key

dnf verifies each package's signature.

What should you run after changing repo files if dnf shows old data?

Answer: dnf clean all

dnf clean all removes cached metadata.

How many streams of one module can be enabled at the same time?

Answer: One

Only one stream per module.

Which baseurl points at a folder on the local disk?

Answer: file:///mnt/iso/BaseOS

file:// followed by an absolute path (hence three slashes).

Which command lists every file installed by a package?Related

Answer: rpm -ql

-ql = query list.

From Installing software with dnf and rpm

Which command shows the RHEL release?Related

Answer: cat /etc/redhat-release

/etc/redhat-release holds the release line. uname -r shows the kernel version instead.

From What Linux and Red Hat Enterprise Linux are

Which stream type supports several listeners?Related

Answer: Broadcast

Broadcast streams allow multiple listeners.

From Streams

What happens if you call two terminal operations on the same stream?Related

Answer: IllegalStateException

Streams are single-use.

From Streams: filter, map and collect

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “Software and networking” before its exam: Network basics: IP addresses, routes, DNS and the ip command, NetworkManager with nmcli, the hostname and name resolution, firewalld: zones, services and ports.
  2. Module 4 exam: Software and networking · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Storage: partitions, file systems and LVM. 57 topics left in the course before the final exam.

← Previous: Installing software with dnf and rpm