Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 9Naam in het boek: Managing Software

Install, update and remove software

RHEL installs software as RPM packages from repositories. This chapter shows how to connect to repositories (also your own), find, install, update and remove packages with dnf, look inside packages with rpm, and install desktop apps with Flatpak.

  • 18 Lessen
  • 14 Commando's
  • 1 Labs

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

9.1

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 is redhat.repo, managed by subscription-manager.
dnf repolist
dnf repolist all
ls /etc/yum.repos.d/

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.

Commando's in deze les

9.2

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 unregister removes the system again (do it before you delete a VM).

9.3

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.

  1. 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
  2. Or let dnf write the file for you.
    dnf config-manager --add-repo http://repo.example.com/rhel10/BaseOS
  3. Check that dnf sees the repositories.
    dnf repolist
KeyMeaning
baseurlURL of the repo: http://, https://, ftp:// or file:///path
enabled1 = use it (default), 0 = do not use it
gpgcheck1 = check the package signatures
gpgkeyWhere 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.

9.4

Keep packages trusted

Packages are signed with a GPG key. dnf checks the signature, so nobody can give you a changed package.

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'
rpm -K package.rpm

Op het werk

In production keep gpgcheck=1 and repo_gpgcheck where the repository supports it. gpgcheck=0 is for labs and the exam only.

Commando's in deze les

9.5

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.

  1. Mount the ISO for good.
    mkdir /repo
    echo "/root/rhel-10.0-x86_64-dvd.iso /repo iso9660 defaults,loop 0 0" >> /etc/fstab
    systemctl daemon-reload; mount -a
  2. 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
  3. For your own RPM files, create the index with createrepo.
    dnf install -y createrepo_c
    createrepo /srv/myrepo

Controleer het

The local repositories are listed.

dnf repolist

9.6

Find software

Search by name or description, or find the package that gives a file or command.

dnf search nmap
dnf search all "web server"
dnf provides '*/semanage'
dnf provides /usr/bin/dig
dnf info httpd

Onthoud

"Which package has the command X?" → dnf provides */X.

Commando's in deze les

9.7

Install and remove packages

dnf install adds packages with all dependencies; dnf remove removes them (and dependencies that nothing else needs).

dnf install -y httpd
dnf install -y ./tool-1.2-1.el10.x86_64.rpm
dnf reinstall -y openssh-server
dnf remove -y httpd
dnf autoremove
  • -y answers yes to every question.
  • A local .rpm file with dnf install (not rpm -i) also installs the dependencies from the repositories.

9.8

List packages

dnf list shows installed and available packages; use patterns to narrow it down.

dnf list installed
dnf list available 'python3*'
dnf list --upgrades
dnf list 'selinux*'
rpm -qa | wc -l

9.9

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.

dnf check-update
dnf upgrade -y
dnf upgrade -y openssh-server
dnf upgrade --security -y
rpm -q kernel

Op het werk

Check dnf needs-restarting -r after updates: it tells you if a reboot is needed (kernel, glibc, systemd).

9.10

Install package groups

A group is a set of packages for one job, like "Development Tools" or "Server with GUI".

dnf group list
dnf group list --hidden
dnf group info "Development Tools"
dnf group install -y "Development Tools"
dnf group remove -y "Development Tools"

Commando's in deze les

9.11

Undo changes with dnf history

dnf remembers every transaction. You can see what changed and undo it.

dnf history
dnf history info 12
dnf history undo 12

Notitie

undo works only if the old package versions are still in a repository.

Commando's in deze les

9.12

Read RPM file names

The file name tells name, version, release, OS and architecture.

example
httpd-2.4.63-1.el10.x86_64.rpm
PartValue
Namehttpd
Version (upstream)2.4.63
Release (Red Hat build)1
OSel10 = RHEL 10
Architecturex86_64 (or noarch for any)

9.13

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.

rpm -qa | grep httpd
rpm -qi httpd
rpm -ql httpd
rpm -qc httpd
rpm -qd httpd
rpm -qf /etc/ssh/sshd_config
rpm -V openssh-server
OptionShows
-qaAll installed packages
-qiInformation
-qlAll files
-qcConfig files only
-qdDocumentation files
-qf FILEThe package of a file
-VChanged files (verify)

9.14

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.

rpm -qpi tool-1.2-1.el10.x86_64.rpm
rpm -qpl tool-1.2-1.el10.x86_64.rpm
rpm -qp --scripts tool-1.2-1.el10.x86_64.rpm
rpm -qpR tool-1.2-1.el10.x86_64.rpm

Let op

Package scripts run as root during the install. A bad script can do anything.

Commando's in deze les

9.15

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.

  1. Install Flatpak and add a remote (a Flatpak repository).
    dnf install -y flatpak
    flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    flatpak remotes
  2. Find and install an app.
    flatpak search gimp
    flatpak install -y flathub org.gimp.GIMP
    flatpak list --app
  3. Run, update and remove it.
    flatpak run org.gimp.GIMP
    flatpak update -y
    flatpak uninstall -y org.gimp.GIMP

9.16

Remember the main points

The most important facts of this chapter, in short.

  • dnf installs, updates and removes packages and solves dependencies; yum is the same command.
  • Repositories are set in .repo files in /etc/yum.repos.d/ with baseurl, enabled and gpgcheck.
  • GPG keys prove that packages are real; keep gpgcheck=1 when you can.
  • dnf search, dnf info, dnf provides, dnf list installed find packages; dnf history shows and undoes transactions.
  • Package groups install sets of software: dnf group list, dnf group install "NAME".
  • rpm -q asks the RPM database: -qa all, -qi info, -ql files, -qf FILE which package owns a file, -qc config files.
  • You can make your own repository from an ISO or folder of RPMs (createrepo for a folder).
  • Flatpak installs desktop apps from Flathub in their own sandbox.

9.17

Learn the key terms

The words of this chapter in simple English.

TermMeaning
PackageOne file with a program, its files and data about it (RPM).
DependencyAnother package that a package needs.
RepositoryA collection of packages with an index (metadata).
.repo fileThe settings of a repository for dnf.
GPG keyThe key that checks the signature of packages.
Package groupA set of packages for one job, like "Development Tools".
ModuleAn older way to offer more versions of software (AppStream).
RPM databaseThe list of installed packages and their files.
TransactionOne dnf action that installs, updates or removes packages.
FlatpakA way to install desktop apps with their own runtime.

9.18

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).

Oefenen

Alle commando's in dit hoofdstuk