在 Red Hat Enterprise Linux 中安装软件

LinuxBeginner
立即练习

介绍

在本实验中,你将通过实践学习使用 DNF 在 Red Hat Enterprise Linux (RHEL) 系统上管理软件包。首先,你将了解用于 Red Hat 支持注册的 subscription-manager 命令(即使在模拟环境中)。随后,你将探索如何检索和解释 RPM 软件包信息,并掌握使用 DNF 安装和卸载软件包的方法。

此外,本实验将引导你管理 DNF 软件源(Repositories),包括添加、启用和禁用软件源。最后,你将学习如何查看和理解 DNF 的事务历史记录,从而全面掌握软件包管理操作。

注意:本实验需要网络连接来下载软件包和访问软件源。它仅对 LabEx Pro 用户开放。

注册你的系统以获取 Red Hat 支持

在本步骤中,你将学习如何使用 subscription-manager 命令将系统注册到 Red Hat 支持。虽然在此模拟环境中无法使用完整的 Red Hat 订阅,但理解 subscription-manager 命令对于管理 Red Hat Enterprise Linux 系统上的软件至关重要。该命令允许你将系统注册到 Red Hat、附加订阅,并访问 Red Hat 的内容分发网络以获取软件包和更新。

首先,让我们尝试使用一个占位符用户名注册系统。这将演示该命令的用法,尽管实际注册需要有效的 Red Hat 凭据。

sudo subscription-manager register --username labex --password labex 2>&1 | tee ~/project/subscription-register.txt

本实验使用占位符凭据以便该命令可以非交互式运行。在此环境中,该命令将无法通过身份验证(这是预期的),并且输出将保存到 ~/project/subscription-register.txt 中供查阅。

Registering to: subscription.rhsm.redhat.com:443/subscription
Password:
Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html (HTTP error code 401: Unauthorized)

最后,让我们看看在注册系统上可以通过 Red Hat 订阅使用哪些软件源。

sudo subscription-manager repos --list 2>&1 | tee ~/project/subscription-repos.txt

由于系统未注册,你将看到一条消息,指示没有可用的订阅支持的软件源。

This system has no repositories available through subscriptions.

接下来,让我们检查该系统的当前订阅状态。这是在处理 Red Hat 订阅内容之前确认系统仍处于未注册状态的一种实用方法。

sudo subscription-manager status 2>&1 | tee ~/project/subscription-status.txt

由于系统未注册,该命令将根据 subscription-manager 的版本报告 Not registered(未注册)或 Unknown(未知)。在此模拟环境中,注册尝试失败后,Unknown 仍然表示系统没有活动的订阅状态。

+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Unknown
System Purpose Status: Unknown

本练习演示了 subscription-manager 用于注册和状态检查的基本用法。虽然在此模拟环境中完整功能受到限制,但这些命令对于理解 RHEL 系统上的软件访问至关重要。

探索 RPM 软件包信息

在本步骤中,你将学习如何使用 rpm 命令来调查软件包。RPM (Red Hat Package Manager) 是 Red Hat Enterprise Linux 使用的核心软件包管理系统。虽然 dnf(你稍后会探索)是用于从软件源管理软件包的高级工具,但 rpm 允许你查询、验证、安装和卸载单个 .rpm 文件。

首先,让我们列出系统上所有已安装的 RPM 软件包。这可能会生成非常长的列表,因此我们将输出通过管道传递给 head 以仅查看开头部分。

rpm -qa | head > ~/project/rpm-installed.txt
cat ~/project/rpm-installed.txt

你将看到软件包名称、版本和体系结构的列表。例如:

libgcc-11.4.1-3.el9.x86_64
crypto-policies-20240202-1.git283706d.el9.noarch
tzdata-2024a-1.el9.noarch
subscription-manager-rhsm-certificates-20220623-1.el9.noarch
redhat-release-9.4-0.4.el9.x86_64
setup-2.13.7-10.el9.noarch
filesystem-3.16-2.el9.noarch
basesystem-11-13.el9.noarch
pcre2-syntax-10.40-5.el9.noarch
ncurses-base-6.2-10.20210508.el9.noarch

接下来,让我们找出哪个软件包提供了特定的文件。我们将以 /etc/yum.repos.d 为例,这是一个包含 DNF 软件源配置文件的主目录。

rpm -qf /etc/yum.repos.d

输出将显示拥有该目录的软件包。

redhat-release-9.4-0.4.el9.x86_64

现在,让我们获取有关提供 dnf 命令的软件包的详细信息。

DNF_PACKAGE=$(rpm -qf /usr/bin/dnf)
rpm -qi "$DNF_PACKAGE" > ~/project/dnf-package-info.txt
cat ~/project/dnf-package-info.txt

这些命令首先确定哪个 RPM 拥有 /usr/bin/dnf,然后显示详细的软件包元数据,包括版本、发布号、体系结构、许可证和摘要。

Name        : dnf
Version     : 4.14.0
Release     : 9.el9
Architecture: noarch
Install Date: Thu Jul 18 15:50:10 2024
Group       : Unspecified
Size        : 2425281
License     : GPLv2+
Signature   : RSA/SHA256, Fri Nov 10 10:14:09 2023, Key ID 199e2f91fd431d51
Source RPM  : dnf-4.14.0-9.el9.src.rpm
Build Date  : Thu Oct 26 05:20:14 2023
Build Host  : x86-64-01.build.eng.rdu2.redhat.com
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : https://github.com/rpm-software-management/dnf
Summary     : Package manager
Description :
Utility that allows users to manage packages on their systems.
It supports RPMs, modules and comps groups & environments.

你还可以列出由某个软件包安装的所有文件。这对于了解软件包在系统上放置了哪些内容非常有用。

rpm -ql dnf | head -n 10

这将显示由 dnf 软件包安装的前 10 个文件。

/usr/bin/dnf
/usr/lib/systemd/system/dnf-makecache.service
/usr/lib/systemd/system/dnf-makecache.timer
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/dnf
/usr/share/locale/ar/LC_MESSAGES/dnf.mo
/usr/share/locale/bg/LC_MESSAGES/dnf.mo
/usr/share/locale/bn/LC_MESSAGES/dnf.mo
/usr/share/locale/bn_IN/LC_MESSAGES/dnf.mo

要仅查看由软件包安装的配置文件,请使用 -qc 选项。让我们检查 openssh-clients 软件包。

rpm -qc openssh-clients

这将列出与 SSH 客户端相关的配置文件。

/etc/ssh/ssh_config
/etc/ssh/ssh_config.d/50-redhat.conf

最后,要查看软件包的更改日志(changelog)信息,请使用 --changelog。这可以深入了解软件包的更新和修复历史记录。让我们查看 audit 软件包。

rpm -q --changelog audit | head -n 5

如果未安装该软件包,你将看到一条错误消息:

package audit is not installed

你可以改用已安装的软件包进行尝试。例如,使用 setup 软件包:

rpm -q --changelog setup | head -n 5

这些 rpm 命令是了解系统上安装的软件包及其包含的文件的强大工具。

使用 DNF 安装和卸载软件包

在本步骤中,你将学习如何使用 dnf (Dandified YUM) 来管理软件包。dnf 是 Red Hat Enterprise Linux 9 中的默认软件包管理器,用于安装、更新和卸载软件包以及管理软件源。它会自动处理依赖关系,使软件管理比单独使用 rpm 容易得多。

首先,让我们列出名称中包含 "http" 的所有可用和已安装的软件包。这将让你了解哪些软件包与 HTTP 服务相关。

sudo dnf list 'http*'

你将看到一个软件包列表,指示它们是已安装还是可供安装。

Last metadata expiration check: 0:00:00 ago on Mon Apr 22 08:00:00 2024.
Available Packages
http-parser.i686               2.9.4-6.el9    rhel-9-for-x86_64-appstream-rpms
http-parser.x86_64             2.9.4-6.el9    rhel-9-for-x86_64-appstream-rpms
httpcomponents-client.noarch   4.5.13-2.el9   rhel-9-for-x86_64-appstream-rpms
httpcomponents-core.noarch     4.4.13-6.el9   rhel-9-for-x86_64-appstream-rpms
httpd.x86_64                   2.4.51-5.el9   rhel-9-for-x86_64-appstream-rpms
httpd-devel.x86_64             2.4.51-5.el9   rhel-9-for-x86_64-appstream-rpms
httpd-filesystem.noarch        2.4.51-5.el9   rhel-9-for-x86_64-appstream-rpms
httpd-manual.noarch            2.4.51-5.el9   rhel-9-for-x86_64-appstream-rpms
httpd-tools.x86_64             2.4.51-5.el9   rhel-9-for-x86_64-appstream-rpms

现在,让我们搜索名称、摘要或描述中包含 "web server" 的软件包。search all 选项适用于更广泛的搜索。

sudo dnf search all 'web server'

此命令将返回与搜索词匹配的软件包列表。

Last metadata expiration check: 0:00:00 ago on Mon Apr 22 08:00:00 2024.
================== Summary & Description Matched: web server ===================
nginx.x86_64 : A high performance web server and reverse proxy server
pcp-pmda-weblog.x86_64 : Performance Co-Pilot (PCP) metrics from web server logs
========================= Summary Matched: web server ==========================
libcurl.x86_64 : A library for getting files from web servers
libcurl.i686 : A library for getting files from web servers
======================= Description Matched: web server ========================
freeradius.x86_64 : High-performance and highly configurable free RADIUS server
git-instaweb.noarch : Repository browser in gitweb
http-parser.i686 : HTTP request/response parser for C
http-parser.x86_64 : HTTP request/response parser for C
httpd.x86_64 : Apache HTTP Server
mod_auth_openidc.x86_64 : OpenID Connect auth module for Apache HTTP Server
mod_jk.x86_64 : Tomcat mod_jk connector for Apache
mod_security.x86_64 : Security module for the Apache HTTP Server
varnish.i686 : High-performance HTTP accelerator
varnish.x86_64 : High-performance HTTP accelerator

让我们获取有关 httpd 软件包的详细信息,它是 Apache HTTP 服务器。

sudo dnf info httpd

这将显示有关该软件包的全面详细信息,包括其大小、许可证和描述。

Last metadata expiration check: 0:00:00 ago on Mon Apr 22 08:00:00 2024.
Available Packages
Name         : httpd
Version      : 2.4.51
Release      : 5.el9
Architecture : x86_64
Size         : 1.5 M
Source       : httpd-2.4.51-5.el9.src.rpm
Repository   : rhel-9-for-x86_64-appstream-rpms
Summary      : Apache HTTP Server
URL          : https://httpd.apache.org/
License      : ASL 2.0
Description  : The Apache HTTP Server is a powerful, efficient, and extensible
             : web server.

现在,让我们安装 httpd 软件包。此操作需要 sudo 权限。

sudo dnf install httpd -y | tee ~/project/httpd-install.txt

-y 参数会自动对任何提示回答“yes”,这对于脚本编写很有用,但在生产环境中应谨慎使用。

Last metadata expiration check: 0:00:00 ago on Mon Apr 22 08:00:00 2024.
Dependencies resolved.
================================================================================
 Package                Architecture  Version           Repository         Size
================================================================================
Installing:
 httpd                  x86_64        2.4.51-5.el9      rhel-9-for-x86_64-appstream-rpms
                                                                          1.5 M
Installing dependencies:
 apr                    x86_64        1.7.0-11.el9      rhel-9-for-x86_64-appstream-rpms
                                                                          126 k
 apr-util               x86_64        1.6.1-20.el9      rhel-9-for-x86_64-appstream-rpms
                                                                          106 k
 apr-util-bdb           x86_64        1.6.1-20.el9      rhel-9-for-x86_64-appstream-rpms
                                                                           13 k
 apr-util-openssl       x86_64        1.6.1-20.el9      rhel-9-for-x86_64-appstream-rpms
                                                                           15 k
 httpd-filesystem       noarch        2.4.51-5.el9      rhel-9-for-x86_64-appstream-rpms
                                                                           14 k
 httpd-tools            x86_64        2.4.51-5.el9      rhel-9-for-x86_64-appstream-rpms
                                                                          100 k
 mailcap                noarch        2.1.49-5.el9      rhel-9-for-x86_64-baseos-rpms
                                                                           36 k
 mod_http2              x86_64        1.15.7-5.el9      rhel-9-for-x86_64-appstream-rpms
                                                                          150 k
 redhat-logos-httpd     noarch        90.4-1.el9        rhel-9-for-x86_64-appstream-rpms
                                                                           20 k

Transaction Summary
================================================================================
Install  10 Packages

Total download size: 2.1 M
Installed size: 6.9 M
Downloading Packages:
... (downloading package details omitted) ...
Running transaction
... (installation progress omitted) ...

Installed:
  apr-1.7.0-11.el9.x86_64
  apr-util-1.6.1-20.el9.x86_64
  apr-util-bdb-1.6.1-20.el9.x86_64
  apr-util-openssl-1.6.1-20.el9.x86_64
  httpd-2.4.51-5.el9.x86_64
  httpd-filesystem-2.4.51-5.el9.noarch
  httpd-tools-2.4.51-5.el9.x86_64
  mailcap-2.1.49-5.el9.noarch
  mod_http2-1.15.7-5.el9.x86_64
  redhat-logos-httpd-90.4-1.el9.noarch

Complete!

你可以通过查询 rpm 来验证 httpd 是否已安装:

rpm -q httpd
httpd-2.4.51-5.el9.x86_64

现在,让我们卸载 httpd 软件包。

sudo dnf remove httpd -y | tee ~/project/httpd-remove.txt

这将卸载 httpd 软件包以及其他已安装软件包不再需要的任何依赖项。

Dependencies resolved.
================================================================================
 Package                Architecture  Version           Repository         Size
================================================================================
Removing:
 httpd                  x86_64        2.4.51-5.el9      @appstream        4.7 M
Removing dependent packages:
 apr-util-bdb           x86_64        1.6.1-20.el9      @appstream         13 k
 apr-util-openssl       x86_64        1.6.1-20.el9      @appstream         15 k
 httpd-filesystem       noarch        2.4.51-5.el9      @appstream         14 k
 mod_http2              x86_64        1.15.7-5.el9      @appstream        150 k
 redhat-logos-httpd     noarch        90.4-1.el9        @appstream         20 k

Transaction Summary
================================================================================
Remove  6 Packages

Freed space: 4.9 M
... (transaction progress omitted) ...

Removed:
  apr-util-bdb-1.6.1-20.el9.x86_64
  apr-util-openssl-1.6.1-20.el9.x86_64
  httpd-2.4.51-5.el9.x86_64
  httpd-filesystem-2.4.51-5.el9.noarch
  mod_http2-1.15.7-5.el9.x86_64
  redhat-logos-httpd-90.4-1.el9.noarch

Complete!

你可以确认它已被卸载:

rpm -q httpd
package httpd is not installed

这演示了用于安装和卸载软件包的基本 dnf 命令。

管理 DNF 软件源

在本步骤中,你将学习如何管理 DNF 软件源(Repositories)。软件源是存储软件包的位置,dnf 从中检索软件包。了解如何列出、启用、禁用和添加软件源对于控制系统上可用的软件至关重要。

首先,让我们列出所有配置的 DNF 软件源及其状态(已启用或已禁用)。

sudo dnf repolist all > ~/project/dnf-repolist.txt
cat ~/project/dnf-repolist.txt

你将看到软件源 ID、名称及其当前状态的列表。确切的软件源名称取决于实验中使用的镜像。

repo id                                             repo name           status
rhui-rhel-10-for-x86_64-appstream-rhui-rpms         Red Hat Enterprise  enabled
rhui-rhel-10-for-x86_64-baseos-rhui-rpms            Red Hat Enterprise  enabled
rhui-rhel-10-for-x86_64-appstream-rhui-debug-rpms   Red Hat Enterprise  disabled

dnf config-manager 命令是管理软件源配置的强大工具。你可以使用它来启用或禁用软件源。例如,让我们尝试启用一个假设的调试(debug)软件源。虽然此特定软件源在此实验环境中可能不存在或不可访问,但该命令演示了语法。

sudo dnf config-manager --enable rhel-9-server-debug-rpms 2>&1 | tee ~/project/dnf-enable-debug.txt

你将看到有关订阅管理的系统消息以及指示未找到软件源的错误,这在此环境中是预期的。

Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching repo to modify: rhel-9-server-debug-rpms.

现在,让我们尝试禁用一个软件源。我们将以 rhel-9-for-x86_64-appstream-rpms 为例。注意:此特定软件源名称在当前的实验镜像中不存在,但该命令演示了语法。

sudo dnf config-manager --disable rhel-9-for-x86_64-appstream-rpms 2>&1 | tee ~/project/dnf-disable-appstream.txt

你将看到订阅管理消息以及指示软件源在此环境中不存在的错误。

Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching repo to modify: rhel-9-for-x86_64-appstream-rpms.

让我们验证当前系统中是否存在此软件源名称:

sudo dnf repolist all | grep rhel-9-for-x86_64-appstream-rpms

不出所料,由于此软件源在当前的实验镜像中不存在,因此不会有任何输出。

(no output)

让我们尝试相同的启用命令以确认该软件源不存在:

sudo dnf config-manager --enable rhel-9-for-x86_64-appstream-rpms 2>&1 | tee ~/project/dnf-enable-appstream.txt

同样,你将看到相同的错误消息:

Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching repo to modify: rhel-9-for-x86_64-appstream-rpms.

dnf config-manager --add-repo 命令还可以通过指定 URL 来添加新的软件源。为了进行演示,我们将尝试添加一个常用的 EPEL (Extra Packages for Enterprise Linux) 软件源 URL。虽然这可能无法完全配置该软件源(因为它通常需要 GPG 密钥和特定的 .repo 文件),但它展示了该命令的功能。

sudo dnf config-manager --add-repo="https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/" 2>&1 | tee ~/project/dnf-add-repo.txt

你将看到指示已创建新 .repo 文件的输出。

Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Adding repo from: https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/

你可以在 /etc/yum.repos.d/ 中检查新创建的 .repo 文件。文件名将根据 URL 派生。

ls /etc/yum.repos.d/

你应该会看到类似于 dl.fedoraproject.org_pub_epel_9_Everything_x86_64_.repo 的文件以及现有的软件源文件。

dl.fedoraproject.org_pub_epel_9_Everything_x86_64_.repo  redhat.repo  ubi.repo

最后,让我们删除刚刚添加的软件源配置文件以进行清理。

sudo rm /etc/yum.repos.d/dl.fedoraproject.org_pub_epel_9_Everything_x86_64_.repo

此步骤向你展示了如何列出、启用、禁用和添加 DNF 软件源,这些是在 RHEL 上管理软件源的基本技能。

查看 DNF 事务历史记录

在本步骤中,你将学习如何查看 DNF 操作的事务历史记录。dnf 保留了所有软件包安装、卸载和更新的详细日志。此历史记录对于故障排除、审计甚至在必要时还原更改非常宝贵。

首先,让我们查看系统上发生的所有 DNF 事务的摘要。

sudo dnf history | tee ~/project/dnf-history.txt

你将看到一个表格,其中列出了每个事务的 ID、使用的命令行、日期和时间、执行的操作以及更改的软件包数量。

ID     | Command line              | Date and time    | Action(s)      | Altered
--------------------------------------------------------------------------------
     3 | install httpd             | 2024-04-22 08:00 | Install        |   10
     2 | remove httpd              | 2024-04-22 08:01 | Remove         |    6
     1 |                           | 2024-04-22 07:50 | Install        |  767 EE

ID 列特别重要,因为它允许你引用特定的事务。在本实验中,你可以从历史记录输出中捕获 httpd 卸载事务 ID,并在接下来的命令中重用它。

HTTPD_REMOVE_ID=$(sudo dnf history | awk '/remove httpd/ && $1 ~ /^[0-9]+$/ {print $1; exit}')
echo "$HTTPD_REMOVE_ID"
sudo dnf history info "$HTTPD_REMOVE_ID" | tee ~/project/dnf-history-info.txt

此命令提供所选事务的全面明细,包括被卸载的软件包、它们的版本以及操作原因。

Transaction ID : 2
Begin time     : Mon Apr 22 08:01:00 2024
Begin rpmdb    : 777:a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f3
End time       : Mon Apr 22 08:01:05 2024 (5 seconds)
End rpmdb      : 771:a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f3
User           : labex <labex>
Return Code    : Success
Command Line   : dnf remove httpd -y
Packages Altered:
    Removed apr-util-bdb-1.6.1-20.el9.x86_64
    Removed apr-util-openssl-1.6.1-20.el9.x86_64
    Removed httpd-2.4.51-5.el9.x86_64
    Removed httpd-filesystem-2.4.51-5.el9.noarch
    Removed mod_http2-1.15.7-5.el9.x86_64
    Removed redhat-logos-httpd-90.4-1.el9.noarch

DNF 历史记录最强大的功能之一是撤销(undo)或重做(redo)事务的能力。让我们通过重用刚刚捕获的 HTTPD_REMOVE_ID 值来撤销 httpd 卸载事务。

sudo dnf history undo "$HTTPD_REMOVE_ID" -y | tee ~/project/dnf-history-undo.txt

此命令将重新安装在特定事务中被卸载的 httpd 软件包及其依赖项。

Last metadata expiration check: 0:00:00 ago on Mon Apr 22 08:00:00 2024.
Undoing transaction 2, from Mon Apr 22 08:01:00 2024
    Removed apr-util-bdb-1.6.1-20.el9.x86_64
    Removed apr-util-openssl-1.6.1-20.el9.x86_64
    Removed httpd-2.4.51-5.el9.x86_64
    Removed httpd-filesystem-2.4.51-5.el9.noarch
    Removed mod_http2-1.15.7-5.el9.x86_64
    Removed redhat-logos-httpd-90.4-1.el9.noarch
Dependencies resolved.
================================================================================
 Package                Architecture  Version           Repository         Size
================================================================================
Installing:
 httpd                  x86_64        2.4.51-5.el9      ubi-9-appstream-rpms  1.5 M
Installing dependencies:
 apr                    x86_64        1.7.0-11.el9      ubi-9-appstream-rpms  126 k
 apr-util               x86_64        1.6.1-20.el9      ubi-9-appstream-rpms  106 k
 apr-util-bdb           x86_64        1.6.1-20.el9      ubi-9-appstream-rpms   13 k
 apr-util-openssl       x86_64        1.6.1-20.el9      ubi-9-appstream-rpms   15 k
 httpd-filesystem       noarch        2.4.51-5.el9      ubi-9-appstream-rpms   14 k
 httpd-tools            x86_64        2.4.51-5.el9      ubi-9-appstream-rpms  100 k
 mailcap                noarch        2.1.49-5.el9      ubi-9-baseos-rpms      36 k
 mod_http2              x86_64        1.15.7-5.el9      ubi-9-appstream-rpms  150 k
 redhat-logos-httpd     noarch        90.4-1.el9        ubi-9-appstream-rpms   20 k

Transaction Summary
================================================================================
Install  10 Packages

Total download size: 2.1 M
Installed size: 6.9 M
... (installation progress omitted) ...
Complete!

你可以验证 httpd 现在是否已重新安装:

rpm -q httpd
httpd-2.4.51-5.el9.x86_64

最后,让我们再次卸载 httpd,以便为后续实验保持系统处于干净的状态。

sudo dnf remove httpd -y | tee ~/project/dnf-history-final-remove.txt
... (output omitted) ...
Complete!

此步骤演示了如何使用 dnf history 来查看、检查甚至还原 DNF 事务,从而为系统管理提供强大功能。

总结

在本实验中,我们学习了使用 DNF 在 Red Hat Enterprise Linux 上管理软件包的基本技能。我们首先了解了 subscription-manager 命令,这对于将系统注册到 Red Hat 并访问其内容分发网络至关重要(即使在模拟环境中无法进行完整注册)。

随后,我们探索了如何查询 RPM 软件包信息、使用 DNF 安装和卸载软件、管理 DNF 软件源以及查看 DNF 事务历史记录。这些步骤全面概述了 DNF 在高效软件管理方面的强大功能。