yum 软件管理器

yum软件管理器

yum是一个强大的软件包管理器,能够自动解决安装时rpm包之间的依赖关系。

一、使用yum管理软件包

1、使用命令 yum help 查看使用方法

[root@majinhai ~]# yum help
已加载插件:fastestmirror, langpacks
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 向系统中安装一个或多个软件包
langavailable Check available languages
langinfo List languages information
langinstall Install appropriate language packs for a language
langlist List installed languages
langremove Remove installed language packs for a language
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

2、使用yum search ‘字符串’ 在软件包详细信息中搜索指定字符串 
例如:yum search ifconfig 查看ifconfig属于哪个包

[root@majinhai ~]# yum search ifconfig
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun. com
* extra s: mirrors.aliyun.com
* updates: mirrors.aliyun.com
===================================== 匹配:ifconfig ======================================
net-tools.x86_64 : Basic networking tools
[root@majinhai ~]#

3、使用yum install ‘包名’ 向系统中安装一个或多个软件包 
上面查到net-tools这个包里面包含了ifconfig这个命令,接下来我们安装这个包 
输入yum install -y net-tools ( -y, –assumeyes 回答全部问题为是)

[root@majinhai ~]# yum install -y net-tools
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86 _64.0.2.0-0.22.20131004git.el7 将被 安装
--> 解决依赖关系完成
 
依赖关系解决
 
===========================================================================================
Package 架构 版本 源 大小
===========================================================================================
正在安装:
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
 
事务概要
===========================================================================================
安装 1 软件包
 
总下载量:305 k
安装大小:917 k
Downloading packages:
No Presto metadata available for base
net-tools-2.0-0.22.20131004git.el7.x86 _64.rpm | 305 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
验证中 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
 
已安装:
net-tools.x86_64 0:2.0-0.22.20131004git.el7
 
完毕!

4、yum info ‘包名’ info 显示关于软件包或组的详细信息 
查看net-tools包的详细信息 
键入 yum info net-tools

[root@majinhai ~] # yum info net-tools
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
可安装的软件包
名称 :net-tools
架构 :x86_64
版本 :2.0
发布 :0.22.20131004git.el7
大小 :305 k
源 :base/7/x86_64
简介 : Basic networking tools
网址 :http://sourceforge.net/projects/net-tools/
协议 : GPLv2+
描述 : The net-tools package contains basic networking tools,
: including ifconfig, netstat, route, and others.
: Most of them are obsolete. For replacement check iproute package.

5、yum provides ‘路径’ provides 查找提供指定内容的软件包。也就是说,查看指定目录与那些软件包有关系 
键入yum provides /etc/yum.repos.d/

[root@majinhai ~]# yum provides /etc/yum.repos.d/
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
yum- 3.4.3-158.el7.centos.noarch : RPM package installer/updater/manager
源 :base
匹配来源:
文件名 :/etc/yum.repos.d/
yum- 3.4.3-158.el7.centos.noarch : RPM package installer/updater/manager
源 :@anaconda
匹配来源:
文件名 :/etc/yum.repos.d/

6、yum list ‘字符串’ list 列出一个或一组软件包,查看已安装的和可用的软件包, 
例如:查询yum相关的软件包 
键入 yum list yum

[root@majinhai yum.repos.d]# yum list yum
已加载插件: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
已安装的软件包
yum.noarch 3.4.3-158.el7.centos @anaconda

7、yum update 获取并安装更新版本的软件包,包括依赖关系;通常情况下yum uptate尝试保留原版本的配置文件,但在某些情况下,如果打包厂商认为旧版本的配置文件在更新后将无法使用,则会对其进行重命名;如果不加参数直接运行yum uptate 将会安装所有更新。

二、使用yum管理组软件

yum 另一个强大的功能就是具有组的概念,就是针对某个目的而一起安装的相关软件的集合。如;一次性安装gnome桌面等 
1、yum grouplist 命令将列出已安装和可用的组的名称。 
命令yum grouplist

[root@majinhai ~]# yum grouplist
已加载插件: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
已安装环境分组:
GNOME 桌面
可用的环境分组:
最小安装
基础设施服务器
计算节点
文件及打印服务器
基本网页服务器
虚拟化主机
GUI 的服务器
KDE Plasma Workspaces
开发及生成工作站
可用组:
传统 UNIX 兼容性
兼容性程序库
图形管理工具
安全性工具
开发工具
控制台互联网工具
智能卡支持
科学记数法支持
系统管理
系统管理工具
完成

2、yum groupinstall ‘字符串’安装某个指定的组 
命令yum groupinstall ‘GNOME 桌面’ 安装GNOME图形化界面

假装此处是正常的
[root@majinhai ~]# yum groupinstall 'GNOME 桌面'
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun. com
* extra s: mirrors.aliyun.com
* updates: mirrors.aliyun.com

3、yum groupinfo ‘字符串’ 显示该组的详细信息。它将列出比选、默认和可选软件包或组ID前面可能标有标记; 
示例:列出GNOME 桌面 软件组详细信息

标记 含义
= 软件包已安装,以作为该组的一部分安装
+ 软件包未安装,将在安装或更新该组时安装
- 软件包未安装,不会再安装或更新该组时安装
未标记 软件包已安装,但不是通过该组安装的

yum groupinfo ’GNOME桌面‘

[root@majinhai ~]# yum groupinfo 'GNOME 桌面'
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
 
环境分组:GNOME 桌面
环境 ID:gnome-desktop-environment
描述:GNOME 是一个非常直观且用户友好的桌面环境。
必备组:
= base
=core
=desktop-debugging
=dial-up
=directory-client
=fonts
=gnome-desktop
=guest-agents
=guest-desktop-agents
=input-methods
=internet-browser
=java-platform
=multimedia
=network-file-system-client
=networkmanager-submodules
=print-client
=x11
可选组:
+backup-client
+gnome-apps
+internet-applications
+legacy-x
+office-suite
+remote-desktop-clients
+smart-card

三、查看历史事件及记录

所有操作及安装和删除的操作记录都会保存在/var/log/yum.log中。

1、查看/var/log/yum.log最后10行

tail -10 /var/log/yum.log

[root@majinhai ~]# tail -10 /var/log/yum.log
Aug 04 16:21:19 Installed: 1:pnm2ppa-1.04-28.el7.x86_64
Aug 04 16:21:22 Installed: man-pages-3.53-5.el7.noarch
Aug 04 16:21:22 Installed: kpatch-0.4.0-3.el7.noarch
Aug 04 16:21:22 Installed: 10:qemu-guest-agent-2.8.0-2.el7.x86_64
Aug 04 16:21:22 Installed: 2:mtr-0.85-7.el7.x86_64
Aug 04 16:21:22 Installed: rfkill-0.4-9.el7.x86_64
Aug 04 16:21:22 Installed: net-tools-2.0-0.22.20131004git.el7.x86_64
Aug 04 16:21:22 Installed: words-3.0-22.el7.noarch
Aug 04 16:21:23 Installed: tcsh-6.18.01-15.el7.x86_64
Aug 04 20:55:16 Erased: net-tools-2.0-0.22.20131004git.el7.x86_64

2、yum history 查看安装和删除操作记录的摘要 
yum history

[root @majinhai ~]# yum history
已加载插件:fastestmirror, langpacks
ID | 登录用户 | 日期和时间 | 操作 | 变更数
-------------------------------------------------------------------------------
3 | root <root> | 2018-08-04 20:55 | Erase | 1
2 | root <root> | 2018-08-04 16:16 | I, U | 1068 EE
1 | 系统 <空> | 2018-08-03 17:10 | Install | 307
history list

3、yum history undo ’字符串‘ 撤销事件。 
例如:撤销 ID为2的操作 
yum history undo 2

[root @majinhai ~]# yum history undo 2

4、yum localinstall ’*rpm‘ 安装本地RPM包。

[root @majinhai ~]# yum localinstall 123.rpm
 
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/majinhai/p/9425310.html