28.第八章 软件包管理(二)
作者:互联网
4.yum和dnf
CentOS 使用 yum, dnf 解决rpm的包依赖关系
YUM: Yellowdog Update Modifier,rpm的前端程序,可解决软件包相关依赖性,可在多个库之间定位软件包,up2date的替代工具,CentOS 8 用dnf 代替了yum ,不过保留了和 yum的兼容性,配置也是通用的
4.1 yum/dnf 工作原理
yum/dnf 是基于C/S 模式
-
yum 服务器存放rpm包和相关包的元数据库
-
yum 客户端访问yum服务器进行安装或查询等
yum 实现过程
先在yum服务器上创建 yum repository(仓库),在仓库中事先存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录repodata下),当yum客户端利用yum/dnf工具进行安装时包时,会自动下载repodata中的元数据,查询远数据是否存在相关的包及依赖关系,自动从仓库中找到相关包下载并安装。
yum服务器的仓库可以多种形式存在:
- file:// 本地路径
- http://
- https://
- ftp://
注意:yum仓库指向的路径一定必须是repodata目录所在目录
范例:
[root@rocky8 ~]# which yum
/usr/bin/yum
[root@rocky8 ~]# ll /usr/bin/yum
lrwxrwxrwx. 1 root root 5 May 26 03:59 /usr/bin/yum -> dnf-3
[root@rocky8 ~]# which dnf-3
/usr/bin/dnf-3
[root@rocky8 ~]# ll /usr/bin/dnf-3
-rwxr-xr-x. 1 root root 1954 May 26 03:59 /usr/bin/dnf-3
[root@rocky8 ~]# file /usr/bin/dnf-3
/usr/bin/dnf-3: Python script, ASCII text executable
范例:
[root@rocky8 ~]# cd /etc/yum.repos.d/
[root@rocky8 yum.repos.d]# vim test.repo
[epel]
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0
[root@rocky8 yum.repos.d]# yum makecache
Repository 'epel' is missing name in configuration, using id. #提示没有名字
BaseOS 2.4 MB/s | 7.5 MB 00:03
AppStream 1.6 MB/s | 9.1 MB 00:05
extras 22 kB/s | 11 kB 00:00
plus 20 kB/s | 10 kB 00:00
PowerTools 1.8 MB/s | 2.3 MB 00:01
epel 3.6 MB/s | 10 MB 00:02
Metadata cache created.
[root@rocky8 yum.repos.d]# vim test.repo
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0
[root@rocky8 yum.repos.d]# yum makecache
BaseOS 18 kB/s | 4.3 kB 00:00
AppStream 19 kB/s | 4.8 kB 00:00
extras 13 kB/s | 3.5 kB 00:00
plus 11 kB/s | 3.5 kB 00:00
PowerTools 18 kB/s | 4.8 kB 00:00
epel 22 kB/s | 4.7 kB 00:00
Metadata cache created.
#加了name ,就好了没有提示
[root@rocky8 yum.repos.d]# rpm -q sl
package sl is not installed
[root@rocky8 yum.repos.d]# yum info sl
Last metadata expiration check: 0:00:36 ago on Wed 13 Oct 2021 10:04:14 PM CST.
Available Packages
Name : sl
Version : 5.02
Release : 1.el8
Architecture : x86_64
Size : 16 k
Source : sl-5.02-1.el8.src.rpm
Repository : epel #这里显示包在epel源
Summary : Joke command for when you type 'sl' instead of 'ls'
URL : https://github.com/mtoyoda/sl
License : Copyright only
Description : The sl (Steam Locomotive) command is a joke which displays a train on your
: terminal when you accidentally type 'sl' instead of 'ls'.
[root@rocky8 yum.repos.d]# yum -y install sl
[root@rocky8 yum.repos.d]# rpm -q sl
sl-5.02-1.el8.x86_64
[root@rocky8 yum.repos.d]# rpm -ql sl
/usr/bin/sl
/usr/lib/.build-id
/usr/lib/.build-id/cb
/usr/lib/.build-id/cb/664a85114a0cb25cf0460ada9ed86a7b128658
/usr/share/doc/sl
/usr/share/doc/sl/LICENSE
/usr/share/doc/sl/README.ja.md
/usr/share/doc/sl/README.md
/usr/share/man/ja/man1/sl.1.ja.gz
/usr/share/man/man1/sl.1.gz
[root@rocky8 yum.repos.d]# sl #显示小火车
[root@rocky8 yum.repos.d]# sl -a #里边显示司机
[root@rocky8 yum.repos.d]# mkdir backup
[root@rocky8 yum.repos.d]# mv *.repo backup/
#把系统默认带的源备份
[root@rocky8 yum.repos.d]# vim base.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=AppStream
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[extras]
name=extras
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled=1
[plus]
name=plus
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/plus/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[PowerTools]
name=PowerTools
baseurl=https://mirrors.nju.edu.cn/rocky/8/PowerTools/x86_64/os/
gpgcheck=1
etpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[root@rocky8 yum.repos.d]# ls
backup base.repo
#配置南京大学yum源
enabled=0 禁用 1启用
gpgcheck=1 启用验证key 0 禁用
$releasever 系统版本
$basearch CPU架构
[root@rocky8 yum.repos.d]# vim base.repo
[root@rocky8 yum.repos.d]# cat base.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=AppStream
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled=0 #禁用
[extras]
name=extras
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled=1
[plus]
name=plus
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/plus/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[PowerTools]
name=PowerTools
baseurl=https://mirrors.nju.edu.cn/rocky/8/PowerTools/x86_64/os/
gpgcheck=1
etpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[root@rocky8 yum.repos.d]# yum repolist --all
repo id repo name status
AppStream AppStream disabled
BaseOS BaseOS enabled
PowerTools PowerTools enabled
extras extras enabled
plus plus enabled
#--all 把禁用的也显示
[root@rocky8 yum.repos.d]# yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.4.2
cachedir: /var/cache/dnf
BaseOS 18 kB/s | 4.3 kB 00:00
extras 13 kB/s | 3.5 kB 00:00
plus 13 kB/s | 3.5 kB 00:00
PowerTools 18 kB/s | 4.8 kB 00:00
Repo-id : BaseOS
Repo-name : BaseOS
Repo-revision : 8.4
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:40 AM CST
Repo-pkgs : 2,160
Repo-available-pkgs: 2,160
Repo-size : 3.0 G
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/BaseOS/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:04:13 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : PowerTools
Repo-name : PowerTools
Repo-revision : 8.4
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 2,277
Repo-available-pkgs: 1,635
Repo-size : 3.0 G
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/PowerTools/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:04:14 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : extras
Repo-name : extras
Repo-revision : 1633997297
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 45
Repo-available-pkgs: 45
Repo-size : 608 k
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/extras/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:04:14 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : plus
Repo-name : plus
Repo-revision : 1633997348
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 4
Repo-available-pkgs: 4
Repo-size : 192 M
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/plus/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:04:14 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Total packages: 4,486
#-v 显示更加详细的信息
[root@rocky8 yum.repos.d]# vim base.repo
[root@rocky8 yum.repos.d]# cat base.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=AppStream
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled=1
[extras]
name=extras
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled=1
[plus]
name=plus
baseurl=https://mirrors.nju.edu.cn/rocky/$releasever/plus/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[PowerTools]
name=PowerTools
baseurl=https://mirrors.nju.edu.cn/rocky/8/PowerTools/x86_64/os/
gpgcheck=1
etpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[root@rocky8 yum.repos.d]# yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.4.2
cachedir: /var/cache/dnf
BaseOS 17 kB/s | 4.3 kB 00:00
AppStream 19 kB/s | 4.8 kB 00:00
extras 15 kB/s | 3.5 kB 00:00
plus 15 kB/s | 3.5 kB 00:00
PowerTools 19 kB/s | 4.8 kB 00:00
Repo-id : AppStream
Repo-name : AppStream
Repo-revision : 8.4
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:36 AM CST
Repo-pkgs : 6,997 #显示appstream里有6,997个包
Repo-available-pkgs: 5,991 #可用5,991个
Repo-size : 11 G #11G
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/AppStream/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:04:13 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : BaseOS
Repo-name : BaseOS
Repo-revision : 8.4
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:40 AM CST
Repo-pkgs : 2,160 #显示baseos里有2,160个包
Repo-available-pkgs: 2,158 #可用2,158个
Repo-size : 3.0 G #3G
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/BaseOS/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:18:15 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : PowerTools
Repo-name : PowerTools
Repo-revision : 8.4
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 2,277
Repo-available-pkgs: 1,635
Repo-size : 3.0 G
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/PowerTools/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:18:16 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : extras
Repo-name : extras
Repo-revision : 1633997297
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 45
Repo-available-pkgs: 45
Repo-size : 608 k
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/extras/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:18:15 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Repo-id : plus
Repo-name : plus
Repo-revision : 1633997348
Repo-distro-tags : [cpe:/o:rocky:rocky:8]: , , 8, L, R, c, i, k, n, o, u, x, y
Repo-updated : Tue 12 Oct 2021 10:32:38 AM CST
Repo-pkgs : 4
Repo-available-pkgs: 4
Repo-size : 192 M
Repo-baseurl : https://mirrors.nju.edu.cn/rocky/8/plus/x86_64/os/
Repo-expire : 172,800 second(s) (last: Wed 13 Oct 2021 10:18:16 PM CST)
Repo-filename : /etc/yum.repos.d/base.repo
Total packages: 11,483
[root@rocky8 yum.repos.d]# yum -y install epel-release
Last metadata expiration check: 0:03:40 ago on Wed 13 Oct 2021 10:19:44 PM CST.
Dependencies resolved.
===============================================================================================================================================
Package Architecture Version Repository Size
===============================================================================================================================================
Installing:
epel-release noarch 8-13.el8 extras 23 k
#epel-relese 在extras仓库
Transaction Summary
===============================================================================================================================================
Install 1 Package
Total download size: 23 k
Installed size: 35 k
Downloading Packages:
epel-release-8-13.el8.noarch.rpm 73 kB/s | 23 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------
Total 72 kB/s | 23 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : epel-release-8-13.el8.noarch 1/1
Running scriptlet: epel-release-8-13.el8.noarch 1/1
Verifying : epel-release-8-13.el8.noarch 1/1
Installed:
epel-release-8-13.el8.noarch
Complete!
[root@rocky8 yum.repos.d]# yum list cow*
Extra Packages for Enterprise Linux Modular 8 - x86_64 358 kB/s | 955 kB 00:02
Extra Packages for Enterprise Linux 8 - x86_64 969 kB/s | 10 MB 00:11
Available Packages
cowsay.noarch 3.04-16.el8 epel
[root@rocky8 yum.repos.d]# yum -y install cowsay
[root@rocky8 yum.repos.d]# cowsay hello
_______
< hello >
-------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
[root@rocky8 yum.repos.d]# yum --help
usage: yum [options] COMMAND
List of Main Commands:
alias List or create command aliases
autoremove remove all unneeded packages that were originally installed as dependencies
check check for problems in the packagedb
check-update check for available package upgrades
clean remove cached data
deplist List package's dependencies and what packages provide them
distro-sync synchronize installed packages to the latest available versions
downgrade Downgrade a package
group display, or use, the groups information
help display a helpful usage message
history display, or use, the transaction history
info display details about a package or group of packages
install install a package or packages on your system
list list a package or groups of packages
makecache generate the metadata cache
mark mark or unmark installed packages as installed by user.
module Interact with Modules.
provides find what package provides the given value
reinstall reinstall a package
remove remove a package or packages from your system
repolist display the configured software repositories
repoquery search for packages matching keyword
repository-packages run commands on top of all packages in given repository
search search package details for the given string
shell run an interactive YUM shell
swap run an interactive YUM mod for remove and install one spec
updateinfo display advisories about packages
upgrade upgrade a package or packages on your system
upgrade-minimal upgrade, but only 'newest' package match which fixes a problem that affects your system
List of Plugin Commands:
builddep Install build dependencies for package or spec file
changelog Show changelog data of packages
config-manager manage yum configuration options and repositories
copr Interact with Copr repositories.
debug-dump dump information about installed rpm packages to file
debug-restore restore packages recorded in debug-dump file
debuginfo-install install debuginfo packages
download Download package to current directory
groups-manager create and edit groups metadata file
needs-restarting determine updated binaries that need restarting
playground Interact with Playground repository.
repoclosure Display a list of unresolved dependencies for repositories
repodiff List differences between two sets of repositories
repograph Output a full package dependency graph in dot format
repomanage Manage a directory of rpm packages
reposync download all packages from remote repo
General YUM options:
-c [config file], --config [config file]
config file location
-q, --quiet quiet operation
-v, --verbose verbose operation
--version show YUM version and exit
--installroot [path] set install root
--nodocs do not install documentations
--noplugins disable all plugins
--enableplugin [plugin]
enable plugins by name
--disableplugin [plugin]
disable plugins by name
--releasever RELEASEVER
override the value of $releasever in config and repo
files
--setopt SETOPTS set arbitrary config and repo options
--skip-broken resolve depsolve problems by skipping packages
-h, --help, --help-cmd
show command help
--allowerasing allow erasing of installed packages to resolve
dependencies
-b, --best try the best available package versions in
transactions.
--nobest do not limit the transaction to the best candidate
-C, --cacheonly run entirely from system cache, don't update cache
-R [minutes], --randomwait [minutes]
maximum command wait time
-d [debug level], --debuglevel [debug level]
debugging output level
--debugsolver dumps detailed solving results into files
--showduplicates show duplicates, in repos, in list/search commands
-e ERRORLEVEL, --errorlevel ERRORLEVEL
error output level
--obsoletes enables yum's obsoletes processing logic for upgrade
or display capabilities that the package obsoletes for
info, list and repoquery
--rpmverbosity [debug level name]
debugging output level for rpm
-y, --assumeyes automatically answer yes for all questions
--assumeno automatically answer no for all questions
--enablerepo [repo] Enable additional repositories. List option. Supports
globs, can be specified multiple times.
--disablerepo [repo] Disable repositories. List option. Supports globs, can
be specified multiple times.
--repo [repo], --repoid [repo]
enable just specific repositories by an id or a glob,
can be specified multiple times
--enable enable repos with config-manager command
(automatically saves)
--disable disable repos with config-manager command
(automatically saves)
-x [package], --exclude [package], --excludepkgs [package]
exclude packages by name or glob
--disableexcludes [repo], --disableexcludepkgs [repo]
disable excludepkgs
--repofrompath [repo,path]
label and path to an additional repository to use
(same path as in a baseurl), can be specified multiple
times.
--noautoremove disable removal of dependencies that are no longer
used
--nogpgcheck disable gpg signature checking (if RPM policy allows)
--color COLOR control whether color is used
--refresh set metadata as expired before running the command
-4 resolve to IPv4 addresses only
-6 resolve to IPv6 addresses only
--destdir DESTDIR, --downloaddir DESTDIR
set directory to copy packages to
--downloadonly only download packages
--comment COMMENT add a comment to transaction
--bugfix Include bugfix relevant packages, in updates
--enhancement Include enhancement relevant packages, in updates
--newpackage Include newpackage relevant packages, in updates
--security Include security relevant packages, in updates
--advisory ADVISORY, --advisories ADVISORY
Include packages needed to fix the given advisory, in
updates
--bz BUGZILLA, --bzs BUGZILLA
Include packages needed to fix the given BZ, in
updates
--cve CVES, --cves CVES
Include packages needed to fix the given CVE, in
updates
--sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
Include security relevant packages matching the
severity, in updates
--forcearch ARCH Force the use of an architecture
[root@rocky8 yum.repos.d]# yum list nginx
Last metadata expiration check: 0:02:01 ago on Wed 13 Oct 2021 10:25:26 PM CST.
Available Packages
nginx.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStrea
#list 查看包名称
[root@rocky8 yum.repos.d]# yum list nginx --showduplicates
Last metadata expiration check: 0:02:30 ago on Wed 13 Oct 2021 10:25:26 PM CST.
Available Packages
nginx.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
#--showduplicates 列出包的所有版本
[root@rocky8 yum.repos.d]# yum -y install nginx-1:1.14.1-9.module+el8.4.0+542+81547229
#可以指定版本安装
[root@rocky8 yum.repos.d]# yum -y remove nginx
#remove 卸载
[root@rocky8 yum.repos.d]# yum list nginx
Last metadata expiration check: 0:04:46 ago on Wed 13 Oct 2021 10:25:26 PM CST.
Available Packages
nginx.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
#list 列出包名
[root@rocky8 yum.repos.d]# yum list nginx*
Last metadata expiration check: 0:04:50 ago on Wed 13 Oct 2021 10:25:26 PM CST.
Available Packages
nginx.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-all-modules.noarch 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-filesystem.noarch 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-mod-http-image-filter.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-mod-http-perl.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-mod-http-xslt-filter.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-mod-mail.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
nginx-mod-stream.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 AppStream
#支持通配符 ,列出包含名字的所有包
[root@rocky8 yum.repos.d]# yum provides /etc/mime.types
Last metadata expiration check: 0:05:40 ago on Wed 13 Oct 2021 10:25:26 PM CST.
mailcap-2.1.48-3.el8.noarch : Helper application and MIME type associations for file types
Repo : BaseOS
Matched from:
Filename : /etc/mime.types
#provides 查看某个文件依赖于哪个包
[root@rocky8 yum.repos.d]# cd /var/lib/yum
-bash: cd: /var/lib/yum: No such file or directory
[root@rocky8 yum.repos.d]# cd /var/lib/dnf
[root@rocky8 dnf]# ls
history.sqlite history.sqlite-shm history.sqlite-wal modulefailsafe repos
[root@rocky8 dnf]# du -sh /var/lib/dnf/
4.2M /var/lib/dnf/
#缓存文件位置
[root@rocky8 dnf]# yum clean all
66 files removed
#清理缓存
[root@rocky8 dnf]# yum makecache
BaseOS 3.7 MB/s | 7.5 MB 00:02
AppStream 4.1 MB/s | 9.1 MB 00:02
extras 21 kB/s | 11 kB 00:00
plus 19 kB/s | 10 kB 00:00
PowerTools 2.2 MB/s | 2.3 MB 00:01
Extra Packages for Enterprise Linux Modular 8 - x86_64 362 kB/s | 955 kB 00:02
Extra Packages for Enterprise Linux 8 - x86_64 1.7 MB/s | 10 MB 00:06
Metadata cache created.
#创建缓存,也可以等下次安装时,自动创建缓存
[root@rocky8 dnf]# yum history
ID | Command line | Date and time | Action(s) | Altered
-----------------------------------------------------------------------------------------------------------------------------------------------
10 | remove nginx | 2021-10-13 22:29 | Removed | 22
9 | -y install nginx-1:1.14.1-9.module+el8.4.0+542+81547229 | 2021-10-13 22:29 | Install | 22
8 | -y install cowsay | 2021-10-13 22:26 | Install | 42
7 | -y install epel-release | 2021-10-13 22:23 | Install | 1
6 | -y install sl | 2021-10-13 22:05 | Install | 1
5 | -y install vim | 2021-10-13 21:57 | Install | 4 <
4 | -y install rpm | 2021-10-13 20:04 | Upgrade | 6 ><
3 | -y install autofs | 2021-10-13 19:55 | Install | 1 >
2 | -y install redhat-lsb-core | 2021-10-06 19:22 | Install | 26
1 | | 2021-10-06 19:16 | Install | 373 EE
#查看历史
[root@rocky8 dnf]# yum history undo 8
#undo 撤销已经安装过的包,也就是卸载
[root@rocky8 dnf]# yum history
ID | Command line | Date and time | Action(s) | Altered
-----------------------------------------------------------------------------------------------------------------------------------------------
11 | history undo 8 | 2021-10-13 22:35 | Removed | 42
10 | remove nginx | 2021-10-13 22:29 | Removed | 22
9 | -y install nginx-1:1.14.1-9.module+el8.4.0+542+81547229 | 2021-10-13 22:29 | Install | 22
8 | -y install cowsay | 2021-10-13 22:26 | Install | 42
7 | -y install epel-release | 2021-10-13 22:23 | Install | 1
6 | -y install sl | 2021-10-13 22:05 | Install | 1
5 | -y install vim | 2021-10-13 21:57 | Install | 4 <
4 | -y install rpm | 2021-10-13 20:04 | Upgrade | 6 ><
3 | -y install autofs | 2021-10-13 19:55 | Install | 1 >
2 | -y install redhat-lsb-core | 2021-10-06 19:22 | Install | 26
1 | | 2021-10-06 19:16 | Install | 373 EE
[root@rocky8 dnf]# yum history redo 8
#redo 重做,也就是安装
[root@rocky8 dnf]# yum grouplist
Last metadata expiration check: 0:03:50 ago on Wed 13 Oct 2021 10:33:09 PM CST.
Available Environment Groups:
Server with GUI
Server
Workstation
KDE Plasma Workspaces
Custom Operating System
Virtualization Host
Installed Environment Groups:
Minimal Install
Available Groups:
Legacy UNIX Compatibility
Container Management
Development Tools
.NET Core Development
Graphical Administration Tools
Headless Management
Network Servers
RPM Development Tools
Scientific Support
Security Tools
Smart Card Support
System Tools
Fedora Packager
Xfce
#grouplist 查看包组
[root@rocky8 dnf]# yum groupinstall "Virtualization Host"
#安装包组,包组是空格隔开,用双引号引起来
[root@rocky8 dnf]# yum groupremove "Virtualization Host"
#卸载包组
4.2 yum客户端配置
yum客户端配置文件
/etc/yum.conf #为所有仓库提供公共配置
/etc/yum.repos.d/*.repo: #为每个仓库的提供配置文件
帮助参考: man 5 yum.conf
相关变量
yum的repo配置文件中可用的变量:
$releasever: 当前OS的发行版的主版本号,如:8,7,6
$arch: CPU架构,如:aarch64, i586, i686,x86_64等
$basearch:系统基础平台;i386, x86_64
$contentdir:表示目录,比如:centos-8,centos-7
$YUM0-$YUM9:自定义变量
范例:
http://server/centos/$releasever/$basearch/
http://server/centos/7/x86_64
http://server/centos/6/i386
范例:CentOS 8 配置文件
[root@rocky8 ~]# ll /etc/yum.conf
lrwxrwxrwx. 1 root root 12 May 26 03:59 /etc/yum.conf -> dnf/dnf.conf
[root@rocky8 ~]# cat /etc/yum.conf
[main]
gpgcheck=1 #安装包前要做包的合法和完整性校验
installonly_limit=3 #同时可以安装3个包,最小值为2,如设为0或1,为不限制
clean_requirements_on_remove=True #删除包时,是否将不再使用的包删除
best=True #升级时,自动选择安装最新版,即使缺少包的依赖
skip_if_unavailable=False
范例:CentOS 7的配置文件
[root@centos7 ~]# ll /etc/yum.conf
-rw-r--r--. 1 root root 970 Oct 2 2020 /etc/yum.conf
[root@centos7 ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
repo仓库配置文件指向的定义:
[repositoryID]
name=Some name for this repository
baseurl=url://path/to/repository/
enabled={1|0}
gpgcheck={1|0}
gpgkey=URL
enablegroups={1|0}
failovermethod={roundrobin|priority}
roundrobin:意为随机挑选,默认值
priority:按顺序访问
cost= 默认为1000
baseurl指向的路径
阿里云提供了写好的CentOS和ubuntu的仓库文件下载链接
http://mirrors.aliyun.com/repo/
CentOS系统的yum源
#阿里云
https://mirrors.aliyun.com/centos/$releasever/
#腾讯云
https://mirrors.cloud.tencent.com/centos/$releasever/
#华为云
https://repo.huaweicloud.com/centos/$releasever/
#清华大学
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/
Rocky系统的yum源
#南京大学镜像源
https://mirrors.nju.edu.cn/rocky/$releasever/
#163镜像源
https://mirrors.163.com/rocky/$releasever/
EPEL的yum源
#阿里云
https://mirrors.aliyun.com/epel/$releasever/x86_64
#腾讯云
https://mirrors.cloud.tencent.com/epel/$releasever/x86_64
#华为云
https://mirrors.huaweicloud.com/epel/$releasever/x86_64
#清华大学
https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/x86_64
阿里巴巴开源软件
https://opsx.alibaba.com/
范例:为CentOS7用系统安装光盘作的本地yum仓库
#挂载光盘至某目录,如/mnt/cdrom
mount /dev/cdrom /mnt/cdrom
#创建配置文件
[root@centos7 ~]# vim /etc/yum.repos.d/centos7.repo
[CentOS7]
name=CentOS 7
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
范例:为CentOS 8 配置 yum 的系统和EPEL源仓库
[root@centos8 ~]# cat /etc/yum.repos.d/base.repo
[BaseOS]
name=BaseOS
baseurl=file:///misc/cd/BaseOS
gpgcheck=1
gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=AppStream
baseurl=file:///misc/cd/AppStream
gpgcheck=0
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/Everything/$basearch
gpgcheck=0
enabled=1
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os
gpgcheck=0
注意:与之前的版本不同,CentOS 8 系统有两个yum 源:BaseOS和AppStream ,需要分别设置两个仓库
范例:用脚本实现创建yum仓库配置文件
[root@centos7 ~]# cat yum.sh
#!/bin/bash
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch
gpgcheck=0
EOF
yum-config-manager命令
可以生成yum仓库的配置文件及启用或禁用仓库,来自于yum-utils包
格式:
#增加仓库
yum-config-manager --add-repo URL或file
#禁用仓库
yum-config-manager --disable “仓库名"
#启用仓库
yum-config-manager --enable “仓库名”
范例:创建仓库配置
[root@rocky8 ~]# yum provides yum-config-manager
BaseOS 3.7 MB/s | 7.5 MB 00:02
AppStream 3.7 MB/s | 9.1 MB 00:02
extras 24 kB/s | 11 kB 00:00
plus 20 kB/s | 10 kB 00:00
PowerTools 1.8 MB/s | 2.3 MB 00:01
EPEL 4.2 MB/s | 10 MB 00:02
yum-utils-4.0.18-4.el8.noarch : Yum-utils CLI compatibility layer
Repo : BaseOS
Matched from:
Filename : /usr/bin/yum-config-manager
[root@rocky8 ~]# yum -y install yum-utils
[root@rocky8 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@rocky8 ~]# ls /etc/yum.repos.d
backup base.repo docker-ce.repo epel.repo
范例:启用和禁用仓库
[root@rocky8 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
EPEL EPEL
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
extras extras
plus plus
[root@rocky8 ~]# yum-config-manager --disable EPEL
[root@rocky8 ~]# cat /etc/yum.repos.d/epel.repo
[EPEL]
name=EPEL
baseurl=https://mirrors.nju.edu.cn/epel/$releasever/Everything/$basearch/
gpgcheck=1
gpgkey=https://mirrors.nju.edu.cn/epel/RPM-GPG-KEY-EPEL-$releasever
enabled=0
[root@rocky8 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
extras extras
plus plus
[root@rocky8 ~]# yum-config-manager --disable extras
[root@rocky8 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
plus plus
[root@rocky8 ~]# yum-config-manager --enable extras
[root@rocky8 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
extras extras
plus plus
4.3 yum命令
yum命令的用法:
yum [options] [command] [package ...]
yum的命令行选项:
-y #自动回答为“yes”
-q #静默模式
--nogpgcheck #禁止进行gpg check
--enablerepo=repoidglob #临时启用此处指定的repo,支持通配符,如:”*“
--disablerepo=repoidglob #临时禁用此处指定的repo,和上面语句同时使用,放在后面的生效
4.3.1 显示仓库列表
yum repolist [all|enabled|disabled]
范例:
[root@rocky8 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
extras extras
plus
[root@rocky8 ~]# yum --enablerepo=EP* --disablerepo=A* repolist
repo id repo name
BaseOS BaseOS
EPEL EPEL
PowerTools PowerTools
docker-ce-stable Docker CE Stable - x86_64
extras extras
plus plus
4.3.2 显示程序包
yum list
yum list [all | glob_exp1] [glob_exp2] [...]
yum list {available|installed|updates} [glob_exp1] [...]
范例:
[root@rocky8 ~]# dnf list mariadb-server
BaseOS 20 kB/s | 4.3 kB 00:00
AppStream 19 kB/s | 4.8 kB 00:00
extras 14 kB/s | 3.5 kB 00:00
plus 15 kB/s | 3.5 kB 00:00
PowerTools 19 kB/s | 4.8 kB 00:00
Docker CE Stable - x86_64 36 kB/s | 16 kB 00:00
Available Packages
mariadb-server.x86_64 3:10.3.28-1.module+el8.4.0+427+adf35707 AppStream
[root@rocky8 ~]# dnf list mariadb-server --showduplicates
Last metadata expiration check: 0:00:09 ago on Wed 13 Oct 2021 11:03:39 PM CST.
Available Packages
mariadb-server.x86_64 3:10.3.28-1.module+el8.4.0+427+adf35707 AppStream
4.3.3 安装程序包
yum install package1 [package2] [...]
yum reinstall package1 [package2] [...] #重新安装
yum installpackage1 [package2] [...] --downloadonly --downloaddir=/data #只下載不安裝
4.3.3.1 安装epel源包
范例:安装epel源
[root@rocky8 ~]# yum -y install epel-release
[root@rocky8 ~]# yum -y install sl
[root@rocky8 ~]# rpm -ql sl
/usr/bin/sl
/usr/lib/.build-id
/usr/lib/.build-id/cb
/usr/lib/.build-id/cb/664a85114a0cb25cf0460ada9ed86a7b128658
/usr/share/doc/sl
/usr/share/doc/sl/LICENSE
/usr/share/doc/sl/README.ja.md
/usr/share/doc/sl/README.md
/usr/share/man/ja/man1/sl.1.ja.gz
/usr/share/man/man1/sl.1.gz
#运行安装sl程序,可以看到下面火车,这标志着我们可以当老司机了
[root@rocky8 ~]# sl -a
4.3.3.2 升级最新内核
范例:利用elrepo源在CentOS 7 安装新版内核
说明: The difference is that kernel-lt is based on a long term support branch and kernel-ml is based on the mainline stable branch.
http://elrepo.org/tiki/HomePage
[root@centos7 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org #导入key
[root@centos7 ~]# yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm #下载elrepo源
[root@centos7 ~]# ls /etc/yum.repos.d/
backup base.repo elrepo.repo epel.repo
[root@centos7 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
elrepo | 3.0 kB 00:00:00
elrepo/primary_db | 431 kB 00:00:00
repo id repo name status
base/7/x86_64 base 10,072
centosplus/7/x86_64 centosplus 154
elrepo ELRepo.org Community Enterprise Linux Repository - el7 134
epel/7/x86_64 epel 13,676
extras/7/x86_64 extras 500
updates/7/x86_64 updates 2,751
repolist: 27,287
[root@centos7 ~]# yum list --disablerepo=* --enablerepo=elrepo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
Installed Packages
NetworkManager.x86_64 1:1.18.8-1.el7 @anaconda
NetworkManager-libnm.x86_64 1:1.18.8-1.el7 @anaconda
NetworkManager-team.x86_64 1:1.18.8-1.el7 @anaconda
NetworkManager-tui.x86_64 1:1.18.8-1.el7 @anaconda
acl.x86_64 2.2.51-15.el7 @anaconda
aic94xx-firmware.noarch 30-6.el7 @anaconda
alsa-firmware.noarch 1.0.28-2.el7 @anaconda
alsa-lib.x86_64 1.1.8-1.el7 @anaconda
alsa-tools-firmware.x86_64 1.1.0-1.el7 @anaconda
...
#--disablerepo=* 禁用所有仓库 --enablerepo=elrepo 只启用elrepo 仓库
[root@centos7 ~]# cat /etc/yum.repos.d/elrepo.repo
### Name: ELRepo.org Community Enterprise Linux Repository for el7
### URL: https://elrepo.org/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el7
baseurl=http://elrepo.org/linux/elrepo/el7/$basearch/
http://mirrors.coreix.net/elrepo/elrepo/el7/$basearch/
http://mirror.rackspace.com/elrepo/elrepo/el7/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el7
baseurl=http://elrepo.org/linux/testing/el7/$basearch/
http://mirrors.coreix.net/elrepo/testing/el7/$basearch/
http://mirror.rackspace.com/elrepo/testing/el7/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/testing/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=0 #这个库被禁用
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el7
baseurl=http://elrepo.org/linux/extras/el7/$basearch/
http://mirrors.coreix.net/elrepo/extras/el7/$basearch/
http://mirror.rackspace.com/elrepo/extras/el7/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/extras/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[root@rocky8 ~]# sed -i.bak 's@elrepo.org/linux@mirrors.tuna.tsinghua.edu.cn/elrepo@' /etc/yum.repos.d/elrepo.repo
[root@rocky8 ~]# cat /etc/yum.repos.d/elrepo.repo
### Name: ELRepo.org Community Enterprise Linux Repository for el8
### URL: https://elrepo.org/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el8
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el8/$basearch/
http://mirrors.coreix.net/elrepo/elrepo/el8/$basearch/
http://mirror.rackspace.com/elrepo/elrepo/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el8
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/testing/el8/$basearch/
http://mirrors.coreix.net/elrepo/testing/el8/$basearch/
http://mirror.rackspace.com/elrepo/testing/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/testing/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el8
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/kernel/el8/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el8/$basearch/
http://mirror.rackspace.com/elrepo/kernel/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el8
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/extras/el8/$basearch/
http://mirrors.coreix.net/elrepo/extras/el8/$basearch/
http://mirror.rackspace.com/elrepo/extras/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/extras/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[root@centos7 ~]# yum list --disablerepo=* --enablerepo=elrepo-kernel
#只启用elrepo-kernel仓库
...
Available Packages
kernel-lt.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.153-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
perf.x86_64 5.14.12-1.el7.elrepo elrepo-kernel
python-perf.x86_64
#内核有两个版本 kernel-lt.x86_64,lt 是稳定版 ,kernel-ml.x86_64 是最新版,不建议直接装最新版
[root@centos7 ~]# yum -y install kernel-lt.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
No package kernel-lt.x86_64 available.
Error: Nothing to do
#默认是装不上的,因为elrepo-kernel仓库被禁用
[root@centos7 ~]# yum -y install kernel-lt.x86_64 --enablerepo=elrepo-kernel
#启用--enablerepo=elrepo-kernel 仓库安装
[root@centos7 ~]# uname -r
3.10.0-1160.el7.x86_64
[root@centos7 ~]# ls /boot
config-3.10.0-1160.el7.x86_64 initramfs-0-rescue-76c8670cc9ad4289a1dea85c2c5ae9da.img System.map-3.10.0-1160.el7.x86_64
config-5.4.153-1.el7.elrepo.x86_64 initramfs-3.10.0-1160.el7.x86_64.img System.map-5.4.153-1.el7.elrepo.x86_64
efi initramfs-5.4.153-1.el7.elrepo.x86_64.img vmlinuz-0-rescue-76c8670cc9ad4289a1dea85c2c5ae9da
grub symvers-3.10.0-1160.el7.x86_64.gz vmlinuz-3.10.0-1160.el7.x86_64
grub2 symvers-5.4.153-1.el7.elrepo.x86_64.gz vmlinuz-5.4.153-1.el7.elrepo.x86_64
[root@centos7 ~]# reboot
#重启后选择内核版本
[root@centos7 ~]# uname -r
5.4.153-1.el7.elrepo.x86_64
#现在内核就升级成功了
[root@centos7 ~]# yum -y remove kernel-lt.x86_64
Loaded plugins: fastestmirror
Skipping the running kernel: kernel-lt-5.4.153-1.el7.elrepo.x86_64
No Packages marked for removal
#正在使用时卸载不了的,Skipping the running kernel 提示内核正在使用
[root@centos7 ~]# reboot
[root@centos7 ~]# uname -r
3.10.0-1127.el7.x86_64
#用旧内核启动
[root@centos7 ~]# yum -y remove kernel-lt.x86_64
#现在就可以卸载了
[root@centos7 ~]# ls /boot
config-3.10.0-1160.el7.x86_64 initramfs-0-rescue-76c8670cc9ad4289a1dea85c2c5ae9da.img vmlinuz-0-rescue-76c8670cc9ad4289a1dea85c2c5ae9da
efi initramfs-3.10.0-1160.el7.x86_64.img vmlinuz-3.10.0-1160.el7.x86_64
grub symvers-3.10.0-1160.el7.x86_64.gz
grub2 System.map-3.10.0-1160.el7.x86_64
4.3.4 卸载程序包
yum remove | erase package1 [package2] [...]
4.3.5 升级和降级
升级和降级
yum update [package1] [package2] [...]
yum downgrade package1 [package2] [...] (降级)
范例:
[root@centos7 ~]# cat /etc/yum.repos.d/base.repo
[base]
name=aliyum base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/RPM-GPG-KEYCentOS-$releasever
enabled=1
[update]
name=aliyun update
baseurl=https://mirrors.aliyun.com/centos/7/updates/x86_64/
gpgcheck=0
[root@centos7 ~]# yum --disablerepo=* --enablerep=updates list available
[root@centos7 ~]# yum info samba
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
Available Packages
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 15.el7_9
Size : 719 k
Repo : updates/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
[root@centos7 ~]# yum info samba --showduplicates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
Available Packages
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 5.el7
Size : 717 k
Repo : base/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 7.el7_9
Size : 718 k
Repo : updates/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 9.el7_9
Size : 718 k
Repo : updates/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 13.el7_9
Size : 719 k
Repo : updates/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
Name : samba
Arch : x86_64
Version : 4.10.16
Release : 15.el7_9
Size : 719 k
Repo : updates/7/x86_64
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs for Linux and
: Unix.
[root@centos7 ~]# yum install samba --disablerepo=updates
[root@centos7 ~]# yum update samba
[root@centos7 ~]# yum update
检查可用升级:
yum check-update
4.3.6 查询
查看程序包information:
yum info [...]
查看指定的特性(可以是某文件)是由哪个程序包所提供:
yum provides | whatprovides feature1 [feature2] [...]
注意:文件要写全路径,而不只是文件名,否则可能无法查询到
范例:
[root@rocky8 ~]# ll /etc/vsftpd/vsftpd.conf
ls: cannot access '/etc/vsftpd/vsftpd.conf': No such file or directory
#注意要写文件全路径才能查询到
[root@rocky8 ~]# yum provides vsftpd.conf
Last metadata expiration check: 0:09:57 ago on Thu 14 Oct 2021 12:05:44 AM CST.
Error: No Matches found
[root@rocky8 ~]# yum provides /etc/vsftpd/vsftpd.conf
Last metadata expiration check: 0:10:06 ago on Thu 14 Oct 2021 12:05:44 AM CST.
vsftpd-3.0.3-33.el8.x86_64 : Very Secure Ftp Daemon
Repo : AppStream
Matched from:
Filename : /etc/vsftpd/vsftpd.conf
#使用通配符
[root@rocky8 ~]# yum provides */vsftpd.conf
Last metadata expiration check: 0:10:16 ago on Thu 14 Oct 2021 12:05:44 AM CST.
fail2ban-server-0.11.2-1.el8.noarch : Core server component for Fail2Ban
Repo : EPEL
Matched from:
Filename : /etc/fail2ban/filter.d/vsftpd.conf
logwatch-7.4.3-9.el8.noarch : A log file analysis program
Repo : BaseOS
Matched from:
Filename : /usr/share/logwatch/default.conf/logfiles/vsftpd.conf
Filename : /usr/share/logwatch/default.conf/services/vsftpd.conf
python3-pycurl-7.43.0.2-4.el8.x86_64 : Python interface to libcurl for Python 3
Repo : AppStream
Matched from:
Filename : /usr/share/doc/python3-pycurl/tests/vsftpd.conf
vsftpd-3.0.3-33.el8.x86_64 : Very Secure Ftp Daemon
Repo : AppStream
Matched from:
Filename : /etc/vsftpd/vsftpd.conf
Filename : /usr/share/doc/vsftpd/EXAMPLE/INTERNET_SITE/vsftpd.conf
Filename : /usr/share/doc/vsftpd/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
Filename : /usr/share/doc/vsftpd/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
[root@rocky8 ~]# yum provides */updatedb*
Last metadata expiration check: 0:10:28 ago on Thu 14 Oct 2021 12:05:44 AM CST.
augeas-libs-1.12.0-6.el8.i686 : Libraries for augeas
Repo : BaseOS
Matched from:
Filename : /usr/share/augeas/lenses/dist/updatedb.aug
augeas-libs-1.12.0-6.el8.x86_64 : Libraries for augeas
Repo : BaseOS
Matched from:
Filename : /usr/share/augeas/lenses/dist/updatedb.aug
bacula-director-9.0.6-6.el8.1.x86_64 : Bacula Director files
Repo : AppStream
Matched from:
Filename : /usr/share/doc/bacula-director/updatedb
Filename : /usr/share/doc/bacula-director/updatedb/README
Filename : /usr/share/doc/bacula-director/updatedb/update_bacula_tables.in
Filename : /usr/share/doc/bacula-director/updatedb/update_bacula_tables_8_to_9
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables.in
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_10_to_11
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_10_to_11.in
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_11_to_12
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_11_to_12.in
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_4_to_5
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_5_to_6
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_6_to_7
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_7_to_8
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_8_to_9
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_9_to_10
Filename : /usr/share/doc/bacula-director/updatedb/update_mysql_tables_9_to_10.in
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables.in
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_10_to_11
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_10_to_11.in
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_11_to_12
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_11_to_12.in
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_7_to_8
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_8_to_9
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_9_to_10
Filename : /usr/share/doc/bacula-director/updatedb/update_postgresql_tables_9_to_10.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_10_to_11
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_10_to_11.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_11_to_12
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_11_to_12.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_8_to_9
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_9_to_10
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite3_tables_9_to_10.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_10_to_11.in
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_4_to_5
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_5_to_6
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_6_to_7
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_7_to_8
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_8_to_9
Filename : /usr/share/doc/bacula-director/updatedb/update_sqlite_tables_9_to_10.in
mlocate-0.26-20.el8.x86_64 : An utility for finding files by name
Repo : BaseOS
Matched from:
Filename : /etc/updatedb.conf
Filename : /usr/bin/updatedb
Filename : /usr/share/man/man5/updatedb.conf.5.gz
Filename : /usr/share/man/man8/updatedb.8.gz
neovim-0.3.8-1.el8.1.x86_64 : Vim-fork focused on extensibility and agility
Repo : EPEL
Matched from:
Filename : /usr/share/nvim/runtime/ftplugin/updatedb.vim
Filename : /usr/share/nvim/runtime/syntax/updatedb.vim
vim-common-2:8.0.1763-15.el8.x86_64 : The common files needed by any version of the VIM editor
Repo : AppStream
Matched from:
Filename : /usr/share/vim/vim80/ftplugin/updatedb.vim
Filename : /usr/share/vim/vim80/syntax/updatedb.vim
以指定的关键字搜索程序包名及summary信息
yum search string1 [string2] [...]
查看指定包所依赖的capabilities:
yum deplist package1 [package2] [...]
范例:
[root@rocky8 ~]# dnf info bash
Last metadata expiration check: 0:11:40 ago on Thu 14 Oct 2021 12:05:44 AM CST.
Installed Packages
Name : bash
Version : 4.4.20
Release : 1.el8_4
Architecture : x86_64
Size : 6.5 M
Source : bash-4.4.20-1.el8_4.src.rpm
Repository : @System
From repo : anaconda
Summary : The GNU Bourne Again shell
URL : https://www.gnu.org/software/bash
License : GPLv3+
Description : The GNU Bourne Again shell (Bash) is a shell or command language
: interpreter that is compatible with the Bourne shell (sh). Bash
: incorporates useful features from the Korn shell (ksh) and the C shell
: (csh). Most sh scripts can be run by bash without modification.
范例:
[root@rocky8 ~]# dnf list bash*
Last metadata expiration check: 0:11:57 ago on Thu 14 Oct 2021 12:05:44 AM CST.
Installed Packages
bash.x86_64 4.4.20-1.el8_4 @anaconda
Available Packages
bash-completion.noarch 1:2.7-5.el8 BaseOS
bash-doc.x86_64 4.4.20-1.el8_4 BaseOS
bashmount.noarch 4.3.2-1.el8 EPEL
范例:
[root@rocky8 ~]# dnf provides /bin/ls
Last metadata expiration check: 0:12:16 ago on Thu 14 Oct 2021 12:05:44 AM CST.
coreutils-8.30-8.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : @System
Matched from:
Provide : /bin/ls
coreutils-8.30-8.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : BaseOS
Matched from:
Provide : /bin/ls
coreutils-single-8.30-8.el8.x86_64 : coreutils multicall binary
Repo : BaseOS
Matched from:
Provide : /bin/ls
范例:
[root@rocky8 ~]# rpm -ivh /misc/cd/AppStream/Packages/httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64.rpm
error: Failed dependencies:
/etc/mime.types is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
httpd-filesystem is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
httpd-filesystem = 2.4.37-39.module+el8.4.0+571+fd70afb1 is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
httpd-tools = 2.4.37-39.module+el8.4.0+571+fd70afb1 is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
libapr-1.so.0()(64bit) is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
libaprutil-1.so.0()(64bit) is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
mod_http2 is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
system-logos-httpd >= 82.0 is needed by httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
[root@rocky8 ~]# yum provides /etc/mime.types
Last metadata expiration check: 0:14:09 ago on Thu 14 Oct 2021 12:05:44 AM CST.
mailcap-2.1.48-3.el8.noarch : Helper application and MIME type associations for file types
Repo : BaseOS
Matched from:
Filename : /etc/mime.types
[root@rocky8 ~]# yum deplist httpd
Last metadata expiration check: 0:14:27 ago on Thu 14 Oct 2021 12:05:44 AM CST.
package: httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
dependency: /bin/sh
provider: bash-4.4.20-1.el8_4.x86_64
dependency: /etc/mime.types
provider: mailcap-2.1.48-3.el8.noarch
dependency: httpd-filesystem
provider: httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch
dependency: httpd-filesystem = 2.4.37-39.module+el8.4.0+571+fd70afb1
provider: httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch
dependency: httpd-tools = 2.4.37-39.module+el8.4.0+571+fd70afb1
provider: httpd-tools-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64
dependency: libapr-1.so.0()(64bit)
provider: apr-1.6.3-11.el8.1.x86_64
dependency: libaprutil-1.so.0()(64bit)
provider: apr-util-1.6.1-6.el8.1.x86_64
dependency: libbrotlienc.so.1()(64bit)
provider: brotli-1.0.6-3.el8.x86_64
dependency: libc.so.6(GLIBC_2.14)(64bit)
provider: glibc-2.28-151.el8.x86_64
dependency: libcrypt.so.1()(64bit)
provider: libxcrypt-4.1.1-4.el8.x86_64
dependency: libcrypt.so.1(XCRYPT_2.0)(64bit)
provider: libxcrypt-4.1.1-4.el8.x86_64
dependency: libdl.so.2()(64bit)
provider: glibc-2.28-151.el8.x86_64
dependency: libexpat.so.1()(64bit)
provider: expat-2.2.5-4.el8.x86_64
dependency: liblua-5.3.so()(64bit)
provider: lua-libs-5.3.4-11.el8.x86_64
dependency: libm.so.6()(64bit)
provider: glibc-2.28-151.el8.x86_64
dependency: libpcre.so.1()(64bit)
provider: pcre-8.42-4.el8.x86_64
dependency: libpthread.so.0()(64bit)
provider: glibc-2.28-151.el8.x86_64
dependency: libpthread.so.0(GLIBC_2.2.5)(64bit)
provider: glibc-2.28-151.el8.x86_64
dependency: libselinux.so.1()(64bit)
provider: libselinux-2.9-5.el8.x86_64
dependency: libsystemd.so.0()(64bit)
provider: systemd-libs-239-45.el8_4.3.x86_64
dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit)
provider: systemd-libs-239-45.el8_4.3.x86_64
dependency: libz.so.1()(64bit)
provider: zlib-1.2.11-17.el8.x86_64
dependency: mod_http2
provider: mod_http2-1.15.7-3.module+el8.4.0+553+7a69454b.x86_64
dependency: rtld(GNU_HASH)
provider: glibc-2.28-151.el8.i686
provider: glibc-2.28-151.el8.x86_64
dependency: system-logos-httpd >= 82.0
provider: rocky-logos-httpd-84.5-8.el8.noarch
dependency: systemd-units
provider: systemd-239-45.el8_4.3.i686
provider: systemd-239-45.el8_4.3.x86_64
4.3.7 仓库缓存
清除目录/var/cache/yum/缓存
yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
构建缓存:
yum makecache
范例:管理yum缓存
[root@rocky8 ~]# du -sh /var/cache/dnf
68M /var/cache/dnf
[root@rocky8 ~]# ls /var/cache/dnf/
appstream-62ae9a0bbea44fbe BaseOS.solv elrepo.solv extras-b5feef55fd8cf39e plus.solv
AppStream-abcace6ffbe81987 BaseOS-updateinfo.solvx EPEL-76d0321edb9c6fd0 extras-filenames.solvx plus-updateinfo.solvx
AppStream-filenames.solvx commandline-a76fe31ae310b0c7 EPEL-filenames.solvx extras.solv PowerTools-3d347ff58eb9b38f
AppStream.solv elrepo-f1a1068afed4d133 EPEL-presto.solvx extras-updateinfo.solvx PowerTools-filenames.solvx
AppStream-updateinfo.solvx elrepo-filenames.solvx EPEL.solv last_makecache PowerTools.solv
BaseOS-30e188a0248bace7 elrepo-kernel-e80375c2d5802dd1 EPEL-updateinfo.solvx packages.db PowerTools-updateinfo.solvx
baseos-3e608afeebc9a90b elrepo-kernel-filenames.solvx expired_repos.json plus-c5ae3d4b171938a0 tempfiles.json
BaseOS-filenames.solvx elrepo-kernel.solv extras-97d6e6e9746ba957 plus-filenames.solvx
[root@rocky8 ~]# yum clean all
62 files removed
[root@rocky8 ~]# du -sh /var/cache/dnf
1.7M /var/cache/dnf
[root@rocky8 ~]# dnf makecache
[root@rocky8 ~]# du -sh /var/cache/dnf
64M /var/cache/dnf
4.3.8 查看yum事务历史
yum 执行安装卸载命令会记录到相关日志中
日志 文件:
#CentOS 7以前版本日志
/var/log/yum.log
#CentOS 8 版本日志
/var/log/dnf.rpm.log
/var/log/dnf.log
日志命令
yum history [info|list|packages-list|packages-info|summary|addoninfo|redo|undo|rollback|new|sync|stats]
范例:
[root@rocky8 ~]# dnf history
ID | Command line | Date and time | Action(s) | Altered
-----------------------------------------------------------------------------------------------------------------------------------------------
4 | -y install autofs | 2021-10-14 00:18 | Install | 1
3 | install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm | 2021-10-13 23:34 | Install | 1
2 | -y install redhat-lsb-core | 2021-10-06 19:22 | Install | 26
1 | | 2021-10-06 19:16 | Install | 373 EE
[root@rocky8 ~]# dnf history info 4
Transaction ID : 4
Begin time : Thu 14 Oct 2021 12:18:59 AM CST
Begin rpmdb : 397:e39d5498ef54dc32436f9c988cd5aed2535bd210
End time : Thu 14 Oct 2021 12:19:00 AM CST (1 seconds)
End rpmdb : 398:bcdf0bbab28fd053669a36b7b9e11f4a37699858
User : root <root>
Return-Code : Success
Releasever : 8
Command Line : -y install autofs
Comment :
Packages Altered:
Install autofs-1:5.1.4-48.el8_4.1.x86_64 @BaseOS
[root@rocky8 ~]# dnf history undo 4 -y
[root@rocky8 ~]# dnf history redo 4 -y
4.3.9 安装及升级本地程序包
yum localinstall|install rpmfile1 [rpmfile2] [...]
yum localupdate|update rpmfile1 [rpmfile2] [...]
4.3.10 包组管理的相关命令
yum grouplist [hidden] [groupwildcard] [...]
yum groupinstall group1 [group2] [...]
yum groupupdate group1 [group2] [...]
yum groupremove group1 [group2] [...]
yum groupinfo group1 [...]
范例:最小化安装的系统安装图形环境
[root@rocky8 ~]# yum grouplist
Last metadata expiration check: 0:02:16 ago on Thu 14 Oct 2021 12:22:12 AM CST.
Available Environment Groups:
Server with GUI
Server
Workstation
KDE Plasma Workspaces
Custom Operating System
Virtualization Host
Installed Environment Groups:
Minimal Install
Available Groups:
Legacy UNIX Compatibility
Container Management
Development Tools
.NET Core Development
Graphical Administration Tools
Headless Management
Network Servers
RPM Development Tools
Scientific Support
Security Tools
Smart Card Support
System Tools
Fedora Packager
Xfce
[root@rocky8 ~]# yum groupinfo "Server with GUI"
Last metadata expiration check: 0:02:36 ago on Thu 14 Oct 2021 12:22:12 AM CST.
Environment Group: Server with GUI
Description: An integrated, easy-to-manage server with a graphical interface.
no group 'dns-server' from environment 'graphical-server-environment'
Mandatory Groups:
Common NetworkManager submodules
Container Management
Core
Fonts
GNOME
Guest Desktop Agents
Hardware Monitoring Utilities
Hardware Support
Headless Management
Input Methods
Internet Browser
Multimedia
Printing Client
Server product core
Standard
base-x
Optional Groups:
Basic Web Server
Debugging Tools
FTP Server
File and Storage Server
Guest Agents
Infiniband Support
Mail Server
Network File System Client
Network Servers
Performance Tools
Remote Desktop Clients
Remote Management for Linux
Virtualization Client
Virtualization Hypervisor
Virtualization Tools
Windows File Server
[root@rocky8 ~]# dnf groupinstall GNOME -y
[root@rocky8 ~]# init 5
标签:x86,28,elrepo,第八章,Repo,yum,软件包,64,root 来源: https://blog.csdn.net/qq_25599925/article/details/120817559