Intermediate · Software and networking · topic 20 of 57 · 30 min
Repositories, BaseOS, AppStream and module streams
Explanation
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.
$ 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| Repository | What is in it |
|---|---|
| BaseOS | The core OS: kernel, systemd, shell, basic tools. Supported for the whole life of the major version. |
| AppStream | Applications and tools: web servers, databases, languages like Python and Node.js, desktop. Some have shorter life cycles. |
| CodeReady Linux Builder | Extra 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.
# /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.
# 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 repolistA 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.
# 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/AppStreamModule 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.
$ 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 streamsCommon 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
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.
# 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-releasePractice (0/4 done)
Where do .repo files go?
Which line has the bug? 1: [web] 2: name=Web repo 3: baseurl=http:/repo.example.com/web 4: enabled=1 5: gpgcheck=1
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.
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Network basics: IP addresses, routes, DNS and the ip commandSoftware and networking · same module
- NetworkManager with nmcli, the hostname and name resolutionSoftware and networking · same module
- StreamsFlutter and Dart · Async Dart and packages
- Streams: filter, map and collectJava Programming (Core to Spring Boot) · Lambdas, streams and files
- RHEL System Roles and Ansible VaultAnsible in depth
- The Linux filesystem and everyday commandsDevOps: Git, Docker, Kubernetes and CI/CD · Linux for DevOps
Questions people ask about this
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
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.
Which stream type supports several listeners?Related
What happens if you call two terminal operations on the same stream?Related
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
- 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.
- Module 4 exam: Software and networking · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Storage: partitions, file systems and LVM. 57 topics left in the course before the final exam.