yum(Yellow dog Updater,Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。
基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。
yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。
命令
yum [options][command][package...]
- options:可选,选项包括-h(帮助),-y(当安装过程提示选择全部为”yes”),-q(不显示安装的过程)等等。
- command:要进行的操作。
-
yum常用命令
1.列出所有可更新的软件清单命令:
yum check-update- 2.更新所有软件命令:
yum update - 3.仅安装指定的软件命令:
yum install <package_name> - 4.仅更新指定的软件命令:
yum update <package_name> - 5.列出所有可安裝的软件清单命令:
yum list - 6.删除软件包命令:
yum remove <package_name> - 7.查找软件包 命令:
yum search <keyword> - 8.清除缓存命令:
yum clean packages: 清除缓存目录下的软件包yum clean headers: 清除缓存目录下的 headersyum clean oldheaders: 清除缓存目录下旧的 headersyum clean, yum clean all (= yum clean packages; yum clean oldheaders):清除缓存目录下的软件包及旧的headers
yum 帮助文档
Usage: yum [options] COMMANDList 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 shellswap Simple way to swap packages, instead of using shellupdate 更新系统中的一个或多个软件包update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your systemupdateinfo Acts on repository update informationupgrade 更新软件包同时考虑软件包取代关系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=ADVSInclude packages needed to fix the given advisory, inupdates--bzs=BZS Include packages needed to fix the given BZ, inupdates--cves=CVES Include packages needed to fix the given CVE, inupdates--sec-severity=SEVS, --secseverity=SEVSInclude security relevant packages matching theseverity, in updates插件选项:
国内 yum 源
网易(163)
# 1. 首先备份 /etc/yum.repos.d/CentOS-Base.repomv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup# 2.下载对应版本 repo 文件, 放入 /etc/yum.repos.d/ (操作前请做好相应备份)• CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo• CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo• CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repowget http://mirrors.163.com/.help/CentOS6-Base-163.repomv CentOS6-Base-163.repo CentOS-Base.repo# 3. 运行以下命令生成缓存yum clean allyum makecache
中科大
- CentOS5:https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=1
- CentOS6:https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
- CentOS7:https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3
阿里云
参考:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b119hS1mP
1. 备份mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/CentOS 6wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo或者curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoCentOS 7wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo或者curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoCentOS 8wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo或者curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo3. 运行 yum makecache 生成缓存4. 其他非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
