Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Examendoelen in dit hoofdstuk
- Software installeren en bijwerken vanaf het Red Hat-netwerk, een externe repository of het lokale bestandssysteem
Understand repositories
A repository is a place (web server, folder, ISO) with packages and an index. dnf reads the index, solves the dependencies and installs everything that is needed.
- A RHEL system gets the Red Hat repositories only after it is registered (subscription).
- The two main repositories are BaseOS (the core OS) and AppStream (applications, languages, databases).
- Repositories are described in files
/etc/yum.repos.d/*.repo. Red Hat's own file isredhat.repo, managed by subscription-manager.
Examentip
On the exam the system is normally not registered. You must create a .repo file for the repository URL they give you before you can install anything.
Register the system with Red Hat
Registration connects the system to your Red Hat account and enables the Red Hat repositories.
subscription-manager register --username your_rh_user
subscription-manager status
subscription-manager repos --list-enabled
subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpms- A free Red Hat Developer subscription allows up to 16 systems for learning.
subscription-manager unregisterremoves the system again (do it before you delete a VM).
Connect to a repository
A .repo file needs only three things: a label in [ ], a name and a baseurl. Add GPG settings to check the packages.
- Create the file for each repository.
vim /etc/yum.repos.d/exam.repo/etc/yum.repos.d/exam.repo[BaseOS] name=BaseOS baseurl=http://repo.example.com/rhel10/BaseOS gpgcheck=0 [AppStream] name=AppStream baseurl=http://repo.example.com/rhel10/AppStream gpgcheck=0 - Or let dnf write the file for you.
dnf config-manager --add-repo http://repo.example.com/rhel10/BaseOS - Check that dnf sees the repositories.
dnf repolist
| Key | Meaning |
|---|---|
baseurl | URL of the repo: http://, https://, ftp:// or file:///path |
enabled | 1 = use it (default), 0 = do not use it |
gpgcheck | 1 = check the package signatures |
gpgkey | Where the public key is, like file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release |
Let op
dnf config-manager --add-repo does not add a gpgcheck line. With the default gpgcheck=1 from /etc/dnf/dnf.conf, install fails if the key is unknown. Add gpgcheck=0 (lab only) or the right gpgkey.
Keep packages trusted
Packages are signed with a GPG key. dnf checks the signature, so nobody can give you a changed package.
Make a repository from the installation ISO
The RHEL installation ISO contains BaseOS and AppStream with their indexes. Mount it and point a .repo file to it — a full repository without internet.
- Mount the ISO for good.
- Point dnf to both folders on the ISO./etc/yum.repos.d/local.repo
[local-BaseOS] name=Local BaseOS baseurl=file:///repo/BaseOS gpgcheck=0 [local-AppStream] name=Local AppStream baseurl=file:///repo/AppStream gpgcheck=0 - For your own RPM files, create the index with createrepo.
dnf install -y createrepo_c createrepo /srv/myrepo
Find software
Search by name or description, or find the package that gives a file or command.
Install and remove packages
dnf install adds packages with all dependencies; dnf remove removes them (and dependencies that nothing else needs).
List packages
dnf list shows installed and available packages; use patterns to narrow it down.
Update the system
dnf upgrade (or dnf update) installs newer versions. A new kernel is added next to the old one, so you can boot the old one if the new one fails.
Install package groups
A group is a set of packages for one job, like "Development Tools" or "Server with GUI".
Undo changes with dnf history
dnf remembers every transaction. You can see what changed and undo it.
Read RPM file names
The file name tells name, version, release, OS and architecture.
httpd-2.4.63-1.el10.x86_64.rpm| Part | Value |
|---|---|
| Name | httpd |
| Version (upstream) | 2.4.63 |
| Release (Red Hat build) | 1 |
| OS | el10 = RHEL 10 |
| Architecture | x86_64 (or noarch for any) |
Query installed packages with rpm
rpm -q asks the database of installed packages: which files, configs and docs a package has, and which package a file belongs to.
Look inside a package file before installing
Add -p to query an .rpm file instead of the database. Always check the scripts of a package from the internet.
Install desktop apps with Flatpak
Flatpak installs mostly graphical apps in a sandbox, with their own runtime, independent from the RPM packages. It is not meant for server software.
- Install Flatpak and add a remote (a Flatpak repository).
- Find and install an app.
- Run, update and remove it.
- Installed as root = for all users (system). With
--user= only for that user. - Red Hat has its own remote with RHEL apps:
flatpak remote-add rhel https://flatpaks.redhat.io/rhel.flatpakrepo(needs a Red Hat login).
Remember the main points
The most important facts of this chapter, in short.
- dnf installs, updates and removes packages and solves dependencies;
yumis the same command. - Repositories are set in
.repofiles in/etc/yum.repos.d/withbaseurl,enabledandgpgcheck. - GPG keys prove that packages are real; keep
gpgcheck=1when you can. dnf search,dnf info,dnf provides,dnf list installedfind packages;dnf historyshows and undoes transactions.- Package groups install sets of software:
dnf group list,dnf group install "NAME". rpm -qasks the RPM database:-qaall,-qiinfo,-qlfiles,-qf FILEwhich package owns a file,-qcconfig files.- You can make your own repository from an ISO or folder of RPMs (
createrepofor a folder). - Flatpak installs desktop apps from Flathub in their own sandbox.
Learn the key terms
The words of this chapter in simple English.
| Term | Meaning |
|---|---|
| Package | One file with a program, its files and data about it (RPM). |
| Dependency | Another package that a package needs. |
| Repository | A collection of packages with an index (metadata). |
| .repo file | The settings of a repository for dnf. |
| GPG key | The key that checks the signature of packages. |
| Package group | A set of packages for one job, like "Development Tools". |
| Module | An older way to offer more versions of software (AppStream). |
| RPM database | The list of installed packages and their files. |
| Transaction | One dnf action that installs, updates or removes packages. |
| Flatpak | A way to install desktop apps with their own runtime. |
Check what you learned
Think about the answer first, then open it.
1Which three lines does a minimal .repo file need besides the [id] line?
name=, baseurl= and enabled=1 (and gpgcheck=0 or a gpgkey= line).
2How do you find which package gives the file /usr/bin/semanage?
3How do you see which package an installed file belongs to?
4How do you list the configuration files of the package openssh-server?
5How do you undo the last dnf transaction?
dnf history to find its number, then dnf history undo NUMBER.
6How do you install a package group?
7How do you see all updates that are available?
8How do you use a mounted RHEL ISO as a repository?
Write .repo files with baseurl=file:///repo/BaseOS and baseurl=file:///repo/AppStream (the folders on the ISO).