本文将详细介绍Linux软件包管理的基础知识,包括dnf和yum两种包管理工具。风哥教程参考Linux官方文档System administration章节内容,为读者提供全面的软件包管理指南。
参考Red Hat Enterprise Linux 10官方文档中的System administration章节
Part01-基础概念与理论知识
1.1 软件包管理概述
软件包管理是Linux系统管理的重要组成部分,它提供了软件的安装、更新、卸载等功能。RHEL/CentOS系统主要使用dnf(Dandified YUM)作为包管理工具,它是yum的下一代版本。更多视频教程www.fgedu.net.cn
1.2 dnf概述
dnf是RHEL 8及以上版本的默认包管理工具,它基于libsolv库,提供了更快的依赖解析和更小的内存占用。dnf支持模块化、并行下载等新特性。
1.3 yum概述
yum是RHEL 7及以下版本的包管理工具,它基于RPM包管理系统,提供了自动化的依赖解析和软件包管理功能。在RHEL 8及以上版本中,yum是dnf的兼容接口。
Part02-生产环境规划与建议
2.1 软件包管理建议
软件包管理建议:
- 定期更新系统和软件包
- 使用官方软件仓库
- 配置本地软件仓库
- 使用模块化安装软件
- 定期清理缓存和旧软件包
2.2 软件仓库配置建议
软件仓库配置建议:
- 配置多个软件仓库,提高可用性
- 使用本地软件仓库,提高安装速度
- 配置软件仓库优先级
- 定期更新软件仓库元数据
- 配置软件仓库镜像,提高下载速度
2.3 安全建议
软件包管理的安全建议:
- 验证软件包签名
- 使用官方软件仓库
- 定期更新系统和软件包
- 检查软件包依赖
- 备份重要配置文件
Part03-生产环境项目实施方案
3.1 dnf基础操作
dnf基础操作:
$ dnf –version
4.14.0
Installed: dnf-0:4.14.0-8.el9_3.1 at Wed Apr 2 10:00:00 2026
Built : Red Hat, Inc.
Installed: rpm-0:4.16.1.3-25.el9_3.1 at Wed Apr 2 10:00:00 2026
Built : Red Hat, Inc.
# 步骤2:查看已安装的软件包
$ dnf list installed | head -20
Installed Packages
NetworkManager.x86_64 1:1.42.4-1.el9_3.1 @rhel-10-baseos
NetworkManager-libnm.x86_64 1:1.42.4-1.el9_3.1 @rhel-10-baseos
NetworkManager-team.x86_64 1:1.42.4-1.el9_3.1 @rhel-10-baseos
NetworkManager-tui.x86_64 1:1.42.4-1.el9_3.1 @rhel-10-baseos
acl.x86_64 2.3.1-4.el9_3.1 @rhel-10-baseos
audit.x86_64 3.0.7-4.el9_3.1 @rhel-10-baseos
audit-libs.x86_64 3.0.7-4.el9_3.1 @rhel-10-baseos
authselect.x86_64 1.2.3-6.el9_3.1 @rhel-10-baseos
authselect-compat.noarch 1.2.3-6.el9_3.1 @rhel-10-baseos
basesystem.noarch 11-13.el9_3.1 @rhel-10-baseos
bash.x86_64 5.1.8-6.el9_3.1 @rhel-10-baseos
bash-completion.noarch 1:2.11-6.el9_3.1 @rhel-10-baseos
bc.x86_64 1.07.1-15.el9_3.1 @rhel-10-baseos
bind-license.noarch 32:9.16.23-6.el9_3.1 @rhel-10-baseos
binutils.x86_64 2.35.2-42.el9_3.1 @rhel-10-baseos
btrfs-progs.x86_64 5.16.2-2.el9_3.1 @rhel-10-baseos
bzip2.x86_64 1.0.8-8.el9_3.1 @rhel-10-baseos
# 步骤3:查看可用的软件包
$ dnf list available | head -20
Available Packages
389-ds-base.x86_64 1.4.3.22-1.el9_3.1 rhel-10-appstream
389-ds-base-devel.x86_64 1.4.3.22-1.el9_3.1 rhel-10-appstream
389-ds-base-legacy-tools.x86_64 1.4.3.22-1.el9_3.1 rhel-10-appstream
389-ds-base-snmp.x86_64 1.4.3.22-1.el9_3.1 rhel-10-appstream
389-ds-base-tools.x86_64 1.4.3.22-1.el9_3.1 rhel-10-appstream
ModemManager.x86_64 1.20.4-1.el9_3.1 rhel-10-appstream
ModemManager-glib.x86_64 1.20.4-1.el9_3.1 rhel-10-appstream
NetworkManager-adsl.x86_64 1:1.42.4-1.el9_3.1 rhel-10-appstream
NetworkManager-bluetooth.x86_64 1:1.42.4-1.el9_3.1 rhel-10-appstream
NetworkManager-config-connectivity-rhel.noarch
1:1.42.4-1.el9_3.1 rhel-10-appstream
NetworkManager-config-server-rhel.noarch
1:1.42.4-1.el9_3.1 rhel-10-appstream
NetworkManager-wwan.x86_64 1:1.42.4-1.el9_3.1 rhel-10-appstream
PackageKit.x86_64 1.2.4-1.el9_3.1 rhel-10-appstream
PackageKit-command-not-found.x86_64 1.2.4-1.el9_3.1 rhel-10-appstream
# 步骤4:搜索软件包
$ dnf search nginx
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
================ Name & Summary Matched: nginx =================
nginx.x86_64 : A high performance web server and reverse proxy server
nginx-mod-http-perl.x86_64 : nginx Perl dynamic module
nginx-mod-http-xslt-filter.x86_64 : nginx xslt dynamic module
nginx-mod-mail.x86_64 : nginx mail dynamic module
nginx-mod-stream.x86_64 : nginx stream dynamic module
# 步骤5:查看软件包信息
$ dnf info nginx
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Available Packages
Name : nginx
Version : 1.20.1-10.el9_3.1
Release : 1.el9_3.1
Architecture : x86_64
Size : 1.1 M
Source : nginx-1.20.1-10.el9_3.1.src.rpm
Repository : rhel-10-appstream
Summary : A high performance web server and reverse proxy server
URL : http://nginx.org/
License : BSD
Description : nginx [engine x] is an HTTP and reverse proxy server, as well as
: a mail proxy server, written by Igor Sysoev.
# 步骤6:安装软件包
$ sudo dnf install -y nginx
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
nginx x86_64 1.20.1-10.el9_3.1 rhel-10-appstream 1.1 M
Transaction Summary
================================================================================
Install 1 Package
Total download size: 1.1 M
Installed size: 3.5 M
Downloading Packages:
nginx-1.20.1-10.el9_3.1.x86_64.rpm 1.1 MB/s | 1.1 MB 00:00
——————————————————————————–
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Running scriptlet: nginx-1.20.1-10.el9_3.1.x86_64 1/1
Verifying : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Installed:
nginx-1.20.1-10.el9_3.1.x86_64
Complete!
# 步骤7:查看已安装的软件包
$ dnf list installed | grep nginx
nginx.x86_64 1.20.1-10.el9_3.1 @rhel-10-appstream
# 步骤8:启动nginx服务
$ sudo systemctl enable –now nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
# 步骤9:查看nginx服务状态
$ sudo systemctl status nginx
● nginx.service – The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2026-04-02 10:00:00 CST; 10s ago
Docs: man:nginx(8)
Process: 1234 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1235 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 1236 (nginx)
Tasks: 3 (limit: 4915)
Memory: 3.5M
CGroup: /system.slice/nginx.service
├─1236 “nginx: master process”
├─1237 “nginx: worker process”
└─1238 “nginx: worker process”
3.2 软件包更新与删除
软件包更新与删除:
$ sudo dnf check-update
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
nginx.x86_64 1.20.1-10.el9_3.1 rhel-10-appstream
nginx.x86_64 1.20.1-11.el9_3.1 rhel-10-appstream
# 步骤2:更新软件包
$ sudo dnf update nginx
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Upgrading:
nginx x86_64 1.20.1-11.el9_3.1 rhel-10-appstream 1.1 M
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 1.1 M
Downloading Packages:
nginx-1.20.1-11.el9_3.1.x86_64.rpm 1.1 MB/s | 1.1 MB 00:00
——————————————————————————–
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Upgrading : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Cleanup : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Verifying : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Upgraded:
nginx-1.20.1-11.el9_3.1.x86_64
Complete!
# 步骤3:更新所有软件包
$ sudo dnf update -y
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Upgrading:
kernel-core.x86_64 5.14.0-284.el9_3.1 rhel-10-baseos 15 M
kernel-modules.x86_64 5.14.0-284.el9_3.1 rhel-10-baseos 50 M
kernel-tools.x86_64 5.14.0-284.el9_3.1 rhel-10-baseos 2.5 M
Transaction Summary
================================================================================
Upgrade 3 Packages
Total download size: 67 M
Downloading Packages:
(1/3): kernel-core-5.14.0-284.el9_3.1.x86_64.rpm 15 MB/s | 15 MB 00:00
(2/3): kernel-tools-5.14.0-284.el9_3.1.x86_64.rpm 2.5 MB/s | 2.5 MB 00:00
(3/3): kernel-modules-5.14.0-284.el9_3.1.x86_64.rpm 50 MB/s | 50 MB 00:00
——————————————————————————–
Total 67 MB/s | 67 MB 00:00
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/3
Upgrading : kernel-core-5.14.0-284.el9_3.1.x86_64 1/3
Upgrading : kernel-modules-5.14.0-284.el9_3.1.x86_64 2/3
Upgrading : kernel-tools-5.14.0-284.el9_3.1.x86_64 3/3
Cleanup : kernel-core-5.14.0-284.el9_3.1.x86_64 3/3
Cleanup : kernel-modules-5.14.0-284.el9_3.1.x86_64 3/3
Cleanup : kernel-tools-5.14.0-284.el9_3.1.x86_64 3/3
Running scriptlet: kernel-tools-5.14.0-284.el9_3.1.x86_64 3/3
Verifying : kernel-core-5.14.0-284.el9_3.1.x86_64 3/3
Verifying : kernel-modules-5.14.0-284.el9_3.1.x86_64 3/3
Verifying : kernel-tools-5.14.0-284.el9_3.1.x86_64 3/3
Upgraded:
kernel-core-5.14.0-284.el9_3.1.x86_64
kernel-modules-5.14.0-284.el9_3.1.x86_64
kernel-tools-5.14.0-284.el9_3.1.x86_64
Complete!
# 步骤4:删除软件包
$ sudo dnf remove nginx
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Removing:
nginx x86_64 1.20.1-11.el9_3.1 @rhel-10-appstream 3.5 M
Transaction Summary
================================================================================
Remove 1 Package
Freed space: 3.5 M
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Erasing : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Verifying : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Removed:
nginx-1.20.1-11.el9_3.1.x86_64
Complete!
# 步骤5:查看历史记录
$ dnf history list
ID | Command line | Date and time | Action(s) | Altered
—-+————————+—————–+—————+———
5 | remove nginx | 2026-04-02 10:00 | Removed | 1
4 | update -y | 2026-04-02 10:00 | Update | 3
3 | update nginx | 2026-04-02 10:00 | Update | 1
2 | install -y nginx | 2026-04-02 10:00 | Install | 1
1 | | 2026-04-02 10:00 | Install | 1234
# 步骤6:回滚操作
$ sudo dnf history undo 5
Undoing transaction 5, performed Wed Apr 2 10:00:00 2026
Removed nginx-1.20.1-11.el9_3.1.x86_64
Installed nginx-1.20.1-11.el9_3.1.x86_64
Transaction performed with alternate environment root at /var/lib/dnf/history/undo-5
Complete!
3.3 软件仓库管理
软件仓库管理:
$ dnf repolist
Updating Subscription Management repositories.
repo id repo name
rhel-10-appstream Red Hat Enterprise Linux 10 – AppStream
rhel-10-baseos Red Hat Enterprise Linux 10 – BaseOS
# 步骤2:查看软件仓库详细信息
$ dnf repoinfo rhel-10-appstream
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Repo-id : rhel-10-appstream
Repo-name : Red Hat Enterprise Linux 10 – AppStream
Repo-revision : 1698972800
Repo-updated : Wed Apr 2 10:00:00 2026
Repo-pkgs : 12,345
Repo-available-pkgs: 12,345
Repo-size : 45.6 G
Repo-mirrors : http://cdn.redhat.com/content/dist/rhel10/$releasever/$basearch/appstream/os/
Repo-baseurl : https://cdn.redhat.com/content/dist/rhel10/$releasever/$basearch/appstream/os/
Repo-expire : 172,800 second(s) (last: Wed Apr 2 10:00:00 2026)
Repo-filename : /etc/yum.repos.d/redhat.repo
Repo-tags : []
Repo-pkgs-cleanup : False
Repo-cost : 1000
Repo-minrate : 0
Repo-protect : 0
Repo-priority : 99
Repo-gpgcheck : 1
Repo-enabled : 1
Repo-gpgkey : file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# 步骤3:添加软件仓库
$ sudo vi /etc/yum.repos.d/fgedu.repo
[fgedu-local]
name=FGEdu Local Repository
baseurl=file:///fgedu/repo
enabled=1
gpgcheck=0
# 步骤4:查看添加的软件仓库
$ dnf repolist
Updating Subscription Management repositories.
repo id repo name
fgedu-local FGEdu Local Repository
rhel-10-appstream Red Hat Enterprise Linux 10 – AppStream
rhel-10-baseos Red Hat Enterprise Linux 10 – BaseOS
# 步骤5:清理缓存
$ sudo dnf clean all
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
0 files removed
# 步骤6:生成缓存
$ sudo dnf makecache
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
fgedu-local 123 kB/s | 123 kB 00:00
rhel-10-appstream 12 MB/s | 12 MB 00:00
rhel-10-baseos 15 MB/s | 15 MB 00:00
Metadata cache created.
# 步骤7:查看软件包组
$ dnf group list
Available Environment Groups:
Minimal Install
Server with GUI
Workstation
Custom Operating System
Available Groups:
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Network Servers
RPM Development Tools
Scientific Support
Security Tools
System Tools
# 步骤8:安装软件包组
$ sudo dnf group install -y “Development Tools”
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Group Architecture Version Repository Size
================================================================================
Installing Groups:
Development Tools
Transaction Summary
================================================================================
Install 150 Packages
Total download size: 234 M
Installed size: 890 M
Downloading Packages:
(1/150): autoconf-2.69-33.el9.noarch.rpm 1.2 MB/s | 1.2 MB 00:00
…
(150/150): zlib-devel-1.2.11-35.el9.x86_64.rpm 2.3 MB/s | 2.3 MB 00:00
——————————————————————————–
Total 234 MB/s | 234 MB 00:00
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/150
Installing : autoconf-2.69-33.el9.noarch 1/150
…
Installing : zlib-devel-1.2.11-35.el9.x86_64 150/150
Running scriptlet: zlib-devel-1.2.11-35.el9.x86_64 150/150
Verifying : autoconf-2.69-33.el9.noarch 1/150
…
Verifying : zlib-devel-1.2.11-35.el9.x86_64 150/150
Installed:
autoconf.noarch 0:2.69-33.el9
…
zlib-devel.x86_64 0:1.2.11-35.el9
Complete!
Part04-生产案例与实战讲解
4.1 企业软件包管理案例
某企业软件包管理的案例:
- 管理内容:配置本地软件仓库,批量安装软件包
- 优化措施:定期更新软件包,清理缓存
- 成果:软件包管理效率提升,安装时间缩短60%
4.2 批量软件安装脚本
批量软件安装脚本:
# install_packages.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# 软件包列表
PACKAGES=(
“nginx”
“httpd”
“mariadb-server”
“php”
“python3”
“git”
“vim”
“net-tools”
)
# 更新软件仓库
echo “Updating repositories…”
sudo dnf makecache
# 安装软件包
echo “”
echo “Installing packages…”
for PACKAGE in “${PACKAGES[@]}”; do
echo “Installing $PACKAGE…”
sudo dnf install -y “$PACKAGE”
if [ $? -eq 0 ]; then
echo “OK: $PACKAGE installed successfully”
else
echo “ERROR: Failed to install $PACKAGE”
fi
done
# 查看已安装的软件包
echo “”
echo “=== Installed Packages ===”
for PACKAGE in “${PACKAGES[@]}”; do
if rpm -q “$PACKAGE” > /dev/null 2>&1; then
VERSION=$(rpm -q “$PACKAGE”)
echo “$PACKAGE: $VERSION”
else
echo “$PACKAGE: Not installed”
fi
done
# 执行脚本
$ chmod +x install_packages.sh
$ ./install_packages.sh
Updating repositories…
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
fgedu-local 123 kB/s | 123 kB 00:00
rhel-10-appstream 12 MB/s | 12 MB 00:00
rhel-10-baseos 15 MB/s | 15 MB 00:00
Metadata cache created.
Installing packages…
Installing nginx…
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
nginx x86_64 1.20.1-10.el9_3.1 rhel-10-appstream 1.1 M
Transaction Summary
================================================================================
Install 1 Package
Total download size: 1.1 M
Installed size: 3.5 M
Downloading Packages:
nginx-1.20.1-10.el9_3.1.x86_64.rpm 1.1 MB/s | 1.1 MB 00:00
——————————————————————————–
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Running scriptlet: nginx-1.20.1-10.el9_3.1.x86_64 1/1
Verifying : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Installed:
nginx-1.20.1-10.el9_3.1.x86_64
Complete!
OK: nginx installed successfully
Installing httpd…
…
OK: httpd installed successfully
Installing mariadb-server…
…
OK: mariadb-server installed successfully
Installing php…
…
OK: php installed successfully
Installing python3…
…
OK: python3 installed successfully
Installing git…
…
OK: git installed successfully
Installing vim…
…
OK: vim installed successfully
Installing net-tools…
…
OK: net-tools installed successfully
=== Installed Packages ===
nginx: nginx-1.20.1-10.el9_3.1.x86_64
httpd: httpd-2.4.53-7.el9_3.1.x86_64
mariadb-server: mariadb-server-10.5.16-2.el9_3.1.x86_64
php: php-8.1.20-1.el9_3.1.x86_64
python3: python3-3.9.16-1.el9_3.1.x86_64
git: git-2.39.3-1.el9_3.1.x86_64
vim: vim-enhanced-9.0.1565-1.el9_3.1.x86_64
net-tools: net-tools-2.0-0.60.20160915git.el9.x86_64
4.3 软件包更新脚本
软件包更新脚本:
# update_packages.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# 检查可更新的软件包
echo “Checking for available updates…”
sudo dnf check-update > /tmp/dnf_check_update.txt
# 检查是否有可更新的软件包
if [ -s /tmp/dnf_check_update.txt ]; then
echo “Available updates:”
cat /tmp/dnf_check_update.txt
# 询问是否更新
read -p “Do you want to update all packages? (y/n) ” -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo “Updating all packages…”
sudo dnf update -y
if [ $? -eq 0 ]; then
echo “OK: All packages updated successfully”
# 查看更新历史
echo “”
echo “=== Update History ===”
sudo dnf history list | head -5
else
echo “ERROR: Failed to update packages”
fi
else
echo “Update cancelled”
fi
else
echo “No updates available”
fi
# 清理缓存
echo “”
echo “Cleaning cache…”
sudo dnf clean all
# 生成缓存
echo “Generating cache…”
sudo dnf makecache
# 执行脚本
$ chmod +x update_packages.sh
$ ./update_packages.sh
Checking for available updates…
nginx.x86_64 1.20.1-10.el9_3.1 rhel-10-appstream
nginx.x86_64 1.20.1-11.el9_3.1 rhel-10-appstream
Available updates:
nginx.x86_64 1.20.1-10.el9_3.1 rhel-10-appstream
nginx.x86_64 1.20.1-11.el9_3.1 rhel-10-appstream
Do you want to update all packages? (y/n) y
Updating all packages…
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Upgrading:
nginx x86_64 1.20.1-11.el9_3.1 rhel-10-appstream 1.1 M
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 1.1 M
Downloading Packages:
nginx-1.20.1-11.el9_3.1.x86_64.rpm 1.1 MB/s | 1.1 MB 00:00
——————————————————————————–
Running transaction check
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Upgrading : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Cleanup : nginx-1.20.1-10.el9_3.1.x86_64 1/1
Running scriptlet: nginx-1.20.1-11.el9_3.1.x86_64 1/1
Verifying : nginx-1.20.1-11.el9_3.1.x86_64 1/1
Upgraded:
nginx-1.20.1-11.el9_3.1.x86_64
Complete!
OK: All packages updated successfully
=== Update History ===
ID | Command line | Date and time | Action(s) | Altered
—-+————————+—————–+—————+———
6 | update -y | 2026-04-02 10:00 | Update | 1
5 | remove nginx | 2026-04-02 10:00 | Removed | 1
4 | update -y | 2026-04-02 10:00 | Update | 3
3 | update nginx | 2026-04-02 10:00 | Update | 1
2 | install -y nginx | 2026-04-02 10:00 | Install | 1
Cleaning cache…
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
0 files removed
Generating cache…
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed Apr 2 10:00:00 2026.
fgedu-local 123 kB/s | 123 kB 00:00
rhel-10-appstream 12 MB/s | 12 MB 00:00
rhel-10-baseos 15 MB/s | 15 MB 00:00
Metadata cache created.
Part05-风哥经验总结与分享
5.1 软件包管理建议
风哥提示:软件包管理的建议:
- 定期更新:定期更新系统和软件包,保持系统安全
- 使用官方仓库:使用官方软件仓库,确保软件包安全
- 配置本地仓库:配置本地软件仓库,提高安装速度
- 清理缓存:定期清理缓存,释放磁盘空间
- 备份配置:备份重要配置文件,便于恢复
5.2 常见问题与解决方案
软件包管理的常见问题与解决方案:
- 依赖冲突:检查软件包依赖,使用dnf解决依赖
- 安装失败:检查网络连接、软件仓库配置
- 更新失败:检查磁盘空间、网络连接
- 软件包损坏:重新下载软件包,清理缓存
5.3 最佳实践
软件包管理的最佳实践:
- 建立软件包管理制度
- 使用脚本自动化软件包管理
- 配置本地软件仓库
- 定期更新系统和软件包
- 建立软件包更新计划
通过本文的介绍,相信读者对Linux软件包管理基础有了更全面的了解。掌握这些知识有助于更好地管理系统软件包。学习交流加群风哥QQ113257174
更多学习教程公众号风哥教程itpux_com from LinuxDBA视频:www.itpux.com
from Linux:www.itpux.com
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
