yum 是自由和开源 的命令行 包管理用于运行计算机程序的Linux 操作系统使用RPM包管理器。[4]虽然 YUM 有一个命令行界面,但其他一些工具为YUM 功能提供了图形用户界面。
$ rpm -aq|grep yum|xargs rpm -e --nodeps
$ rpm -qa |grep yum
查看,验证地址: http://mirrors.163.com/centos/7/os/x86_64/Packages/
$ wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
$ wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-cron-3.4.3-168.el7.centos.noarch.rpm
$ wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
$ wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
$ wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
--2021-12-30 11:05:40-- http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:111048 (108K) [application/x-redhat-package-manager]
正在保存至: “python-urlgrabber-3.10-10.el7.noarch.rpm”
100%[==============================================================>] 111,048 --.-K/s 用时 0.1s
2021-12-30 11:05:40 (821 KB/s) - 已保存 “python-urlgrabber-3.10-10.el7.noarch.rpm” [111048/111048])
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-cron-3.4.3-168.el7.centos.noarch.rpm
--2021-12-30 11:05:57-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-cron-3.4.3-168.el7.centos.noarch.rpm
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:67120 (66K) [application/x-redhat-package-manager]
正在保存至: “yum-cron-3.4.3-168.el7.centos.noarch.rpm”
100%[==============================================================>] 67,120 --.-K/s 用时 0.09s
2021-12-30 11:06:24 (751 KB/s) - 已保存 “yum-cron-3.4.3-168.el7.centos.noarch.rpm” [67120/67120])
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
--2021-12-30 11:06:37-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1298856 (1.2M) [application/x-redhat-package-manager]
正在保存至: “yum-3.4.3-168.el7.centos.noarch.rpm”
100%[==============================================================>] 1,298,856 2.99MB/s 用时 0.4s
2021-12-30 11:06:39 (2.99 MB/s) - 已保存 “yum-3.4.3-168.el7.centos.noarch.rpm” [1298856/1298856])
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
--2021-12-30 11:06:49-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:28348 (28K) [application/x-redhat-package-manager]
正在保存至: “yum-metadata-parser-1.1.4-10.el7.x86_64.rpm”
100%[==============================================================>] 28,348 --.-K/s 用时 0.06s
2021-12-30 11:06:50 (492 KB/s) - 已保存 “yum-metadata-parser-1.1.4-10.el7.x86_64.rpm” [28348/28348])
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
--2021-12-30 11:06:59-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:35216 (34K) [application/x-redhat-package-manager]
正在保存至: “yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm”
100%[==============================================================>] 35,216 --.-K/s 用时 0.04s
2021-12-30 11:06:59 (797 KB/s) - 已保存 “yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm” [35216/35216])
[root@VM-0-9-centos ~]# ll
总用量 1516
-rw-r--r-- 1 root root 0 12月 19 22:45 --add-repo
-rw-r--r-- 1 root root 111048 4月 4 2020 python-urlgrabber-3.10-10.el7.noarch.rpm
-rw-r--r-- 1 root root 1298856 10月 15 2020 yum-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root 67120 10月 15 2020 yum-cron-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root 28348 7月 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r-- 1 root root 35216 5月 14 2020 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
注意对应包名,tab键可自动补全.
注意:yum-xxx-168.el7.centos.noarch.rpm 必须与 yum-plugin-fastestmirror-xxx.el7_8.noarch.rpm 同时安装
$ rpm -ivh --force --nodeps python-urlgrabber-3.10-10.el7.noarch.rpm
$ rpm -ivh --force --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
$ rpm -ivh --force --nodeps yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[root@VM-0-9-centos ~]# rpm -ivh --force --nodeps python-urlgrabber-3.10-10.el7.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:python-urlgrabber-3.10-10.el7 ################################# [100%]
[root@VM-0-9-centos ~]# rpm -ivh --force --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [100%]
[root@VM-0-9-centos ~]# rpm -ivh --force --nodeps yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:yum-plugin-fastestmirror-1.1.31-5################################# [ 50%]
2:yum-3.4.3-168.el7.centos 警告:/etc/yum.conf 已建立为 /etc/yum.conf.rpmnew
################################# [100%]
[root@VM-0-9-centos ~]#
[tiam@VM-0-9-centos root]$
超级用户root提示符为#
号,普通用户为$
号.
直接输入$ yum
即可.出现以下安装成功.
[root@VM-0-9-centos ~]# yum
您需要给出命令
Usage: yum [options] COMMAND
List of Commands:
check 检查 RPM 数据库问题
check-update 检查是否有可用的软件包更新
clean 删除缓存数据
deplist 列出软件包的依赖关系
distribution-synchronization 已同步软件包到最新可用版本
downgrade 降级软件包
erase 从系统中移除一个或多个软件包
fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
groups 显示或使用、组信息
help 显示用法提示
history 显示或使用事务历史
info 显示关于软件包或组的详细信息
install 向系统中安装一个或多个软件包
list 列出一个或一组软件包
load-transaction 从文件名中加载一个已存事务
makecache 创建元数据缓存
provides 查找提供指定内容的软件包
reinstall 覆盖安装软件包
repo-pkgs 将一个源当作一个软件包组,这样我们就可以一次性安装/移除全部软件包。
repolist 显示已配置的源
search 在软件包详细信息中搜索指定字符串
shell 运行交互式的 yum shell
swap Simple way to swap packages, instead of using shell
update 更新系统中的一个或多个软件包
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade 更新软件包同时考虑软件包取代关系
version 显示机器和/或可用的源版本。
Options:
-h, --help 显示此帮助消息并退出
-t, --tolerant 忽略错误
-C, --cacheonly 完全从系统缓存运行,不升级缓存
-c [config file], --config=[config file]
配置文件路径
-R [minutes], --randomwait=[minutes]
命令最长等待时间
-d [debug level], --debuglevel=[debug level]
调试输出级别
--showduplicates 在 list/search 命令下,显示源里重复的条目
-e [error level], --errorlevel=[error level]
错误输出级别
--rpmverbosity=[debug level name]
RPM 调试输出级别
-q, --quiet 静默执行
-v, --verbose 详尽的操作过程
-y, --assumeyes 回答全部问题为是
--assumeno 回答全部问题为否
--version 显示 Yum 版本然后退出
--installroot=[path] 设置安装根目录
--enablerepo=[repo] 启用一个或多个软件源(支持通配符)
--disablerepo=[repo] 禁用一个或多个软件源(支持通配符)
-x [package], --exclude=[package]
采用全名或通配符排除软件包
--disableexcludes=[repo]
禁止从主配置,从源或者从任何位置排除
--disableincludes=[repo]
disable includepkgs for a repo or for everything
--obsoletes 更新时处理软件包取代关系
--noplugins 禁用 Yum 插件
--nogpgcheck 禁用 GPG 签名检查
--disableplugin=[plugin]
禁用指定名称的插件
--enableplugin=[plugin]
启用指定名称的插件
--skip-broken 忽略存在依赖关系问题的软件包
--color=COLOR 配置是否使用颜色
--releasever=RELEASEVER
在 yum 配置和 repo 文件里设置 $releasever 的值
--downloadonly 仅下载而不更新
--downloaddir=DLDIR 指定一个其他文件夹用于保存软件包
--setopt=SETOPTS 设置任意配置和源选项
--bugfix Include bugfix relevant packages, in updates
--security Include security relevant packages, in updates
--advisory=ADVS, --advisories=ADVS
Include packages needed to fix the given advisory, in
updates
--bzs=BZS Include packages needed to fix the given BZ, in
updates
--cves=CVES Include packages needed to fix the given CVE, in
updates
--sec-severity=SEVS, --secseverity=SEVS
Include security relevant packages matching the
severity, in updates
插件选项:
[root@VM-0-9-centos ~]#
# 下载163配置仓库repo文件
$ wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
# 复制下载的文件到配置目录下
$ cp CentOS7-Base-163.repo /etc/yum.repos.d/
# 切换到配置目录下
$ cd /etc/yum.repos.d/
# 重命名
$ mv CentOS-Base.repo CentOS-Base.repo.bak
# 重命名
$ mv CentOS7-Base-163.repo CentOS-Base.repo
$ yum clean all
$ yum makecache
$ yum update
[root@VM-0-9-centos ~]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2021-12-30 11:51:24-- http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”
100%[==============================================================>] 1,572 --.-K/s 用时 0s
2021-12-30 11:51:24 (126 MB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])
[root@VM-0-9-centos ~]# ls
--add-repo yum-cron-3.4.3-168.el7.centos.noarch.rpm
CentOS7-Base-163.repo yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-urlgrabber-3.10-10.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
yum-3.4.3-168.el7.centos.noarch.rpm
[root@VM-0-9-centos ~]# ll
总用量 1520
-rw-r--r-- 1 root root 0 12月 19 22:45 --add-repo
-rw-r--r-- 1 root root 1572 12月 1 2016 CentOS7-Base-163.repo
-rw-r--r-- 1 root root 111048 4月 4 2020 python-urlgrabber-3.10-10.el7.noarch.rpm
-rw-r--r-- 1 root root 1298856 10月 15 2020 yum-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root 67120 10月 15 2020 yum-cron-3.4.3-168.el7.centos.noarch.rpm
-rw-r--r-- 1 root root 28348 7月 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r-- 1 root root 35216 5月 14 2020 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[root@VM-0-9-centos ~]# cp CentOS7-Base-163.repo /etc/yum.repos.d/
[root@VM-0-9-centos ~]# cd /etc/yum.repos.d/
[root@VM-0-9-centos yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@VM-0-9-centos yum.repos.d]# mv CentOS7-Base-163.repo CentOS-Base.repo
[root@VM-0-9-centos yum.repos.d]# yum clean all
Repository epel is listed more than once in the configuration
正在清理软件源: base docker-ce-stable epel extras updates
Other repos take up 30 M of disk space (use --verbose for details)
[root@VM-0-9-centos yum.repos.d]# yum makecache
Repository epel is listed more than once in the configuration
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/20): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/20): base/7/x86_64/filelists_db | 7.2 MB 00:00:01
(3/20): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(4/20): base/7/x86_64/other_db | 2.6 MB 00:00:00
(5/20): docker-ce-stable/7/x86_64/filelists_db | 29 kB 00:00:01
(6/20): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:01
(7/20): epel/7/x86_64/group_gz | 96 kB 00:00:00
(8/20): docker-ce-stable/7/x86_64/primary_db | 70 kB 00:00:00
(9/20): docker-ce-stable/7/x86_64/other_db | 122 kB 00:00:00
(10/20): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(11/20): epel/7/x86_64/prestodelta | 2.1 kB 00:00:00
(12/20): epel/7/x86_64/filelists_db | 12 MB 00:00:00
(13/20): extras/7/x86_64/primary_db | 243 kB 00:00:00
(14/20): extras/7/x86_64/filelists_db | 259 kB 00:00:00
(15/20): epel/7/x86_64/primary_db | 7.0 MB 00:00:00
(16/20): epel/7/x86_64/other_db | 3.4 MB 00:00:00
(17/20): extras/7/x86_64/other_db | 145 kB 00:00:00
(18/20): updates/7/x86_64/primary_db | 13 MB 00:00:00
(19/20): updates/7/x86_64/other_db | 903 kB 00:00:00
(20/20): updates/7/x86_64/filelists_db | 7.0 MB 00:00:01
元数据缓存已建立
[root@VM-0-9-centos yum.repos.d]# yum update
Repository epel is listed more than once in the configuration
No packages marked for update
[root@VM-0-9-centos yum.repos.d]# ll
总用量 24
-rw-r--r-- 1 root root 1572 12月 30 11:51 CentOS-Base.repo
-rw-r--r-- 1 root root 614 10月 23 02:40 CentOS-Base.repo.bak
-rw-r--r-- 1 root root 230 10月 23 02:40 CentOS-Epel.repo
-rw-r--r-- 1 root root 616 11月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root 1919 12月 16 23:00 docker-ce.repo
-rw-r--r-- 1 root root 1358 9月 5 01:37 epel.repo
[root@VM-0-9-centos yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[root@VM-0-9-centos yum.repos.d]#