yum的全程是 yellow dog updater modified。 说实话,看到这个解释我也挺懵逼的。为啥是黄狗?为啥不是白狗呢? 有人说,中国自古就有诗为证了:黄狗身上白,白狗身上肿……这波解释666。 好吧,这只是说笑,以前有个叫基于redhat的Linux发行版:yellow dog Linux,后来这个版本不再维护了,但是它的包管理器yellow dog updater modified被保留了下来。 题外话:yellow dog是指不加入工会的工人,在美国是非常受鄙视的。 正文 yum它是一个在线的软件安装命令,通行在redhat、CentOS、Fedora等多个Linux发行版上。 主要作用就是自动安装、升级rpm软件包,可以自动检查并解决rpm包之间的依赖关系。 就跟现在前后端开发常用的maven install、npm install等包管理工具类似。 语法 yum [选项] [指令] [软件包] 常用参数 参数选项 | 解释说明 —|— -y,–assumeyes | 确认操作,最常用 –nogpgcheck | 忽略GPG验证 –noplugins |禁用所有插件 -q, –quiet | 静默模式 -v, –verbose | 详细模式; –color=COLOR | 带颜色 –downloadonly | 仅下载包,不安装或升级。默认下载在yum的缓存目录中,默认为/var/cache/yum/$basearch/$releasever –downloaddir=DLDIR | 指定下载目录 常用命令 参数选项 | 解释说明 —|— yum install -y | 安装软件包 yum localinstall <本地已下载安装包> | 安装本地RPM包 yum remove | 完全移除,包含依赖项。较为危险,可能会误卸载别的软件依赖项 yum update | 更新软件包 yum update | 更新系统 yum check-update | 列出所有可更新的软件清单命令 yum list | 列出指定软件包 yum list | grep | 模糊搜索相关RPM yum list | 列出所有可用软件,可用less展示 yum list installed | 列出所有已安装软件包 yum search all | 如果不记得确切名称,可以用search all查找可用的相关包 yum info | 获取软件包信息 yum deplist | 查看依赖 yum provides | 查找特定文件属于哪个包,示例yum provides /etc/my.cnf yum grouplist | 列出可用群组 yum groupinstall | 安装群组软件包 yum groupupdate | 更新群组软件包 yum groupremove | 卸载群组软件包 yum repolist | 可出启用的yum源 yum repolist all | 列出所有yum源 yum clean all | 清楚所有yum的缓存内容 yum clean packages | 清除缓存目录下的软件包 yum clean headers | 清除缓存目录下的 headers yum clean oldheaders | 清除缓存目录下旧的 headers yum history | 安装历史 yum makecache fast | 创建yum缓存 tips 使用yum history的时候报错,可能是因为没有权限,而不是别的原因。 使用yum的时候最好使用具有root权限的账号。 示例 安装压缩软件7z 命令: yum install -y p7zip 示例: [root@yaomm ~]# yum install -y p7zip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.cloud.aliyuncs.com * extras: mirrors.cloud.aliyuncs.com * updates: mirrors.cloud.aliyuncs.com Resolving Dependencies --> Running transaction check ---> Package p7zip.x86_64 0:16.02-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================================================================================================================================================= Installing: p7zip x86_64 16.02-10.el7 epel 604 k Transaction Summary ========================================================================================================================================================================================================================================================================================= Install 1 Package Total download size: 604 k Installed size: 1.7 M Downloading packages: p7zip-16.02-10.el7.x86_64.rpm | 604 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : p7zip-16.02-10.el7.x86_64 1/1 Verifying : p7zip-16.02-10.el7.x86_64 1/1 Installed: p7zip.x86_64 0:16.02-10.el7 Complete! 查看历史列表: [root@yaomm ~]# yum history Loaded plugins: fastestmirror ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 36 | install -y p7zip | 2020-07-06 22:44 | Install | 1 35 | install firewalld -y | 2020-06-04 19:33 | Update | 3 34 | install libffi-devel -y | 2020-06-04 19:32 | I, U | 2 33 | install epel-release -y | 2020-06-04 19:30 | Install | 1 EE 32 | install -y wget python-d | 2020-06-04 19:30 | I, U | 47 31 | install ntp -y | 2020-06-04 19:29 | Update | 2 30 | install tmux | 2020-05-29 17:18 | Install | 2 29 | install traceroute baidu | 2020-05-08 21:06 | Install | 1 28 | install zip -y | 2020-04-30 15:03 | Install | 1 27 | remove zip -y | 2020-04-30 14:56 | Erase | 1 26 | install certbot python2- | 2020-04-16 23:57 | Install | 2 25 | remove certbot python2-c | 2020-04-16 23:57 | Erase | 2 24 | install certbot python2- | 2020-04-16 23:41 | Install | 2 23 | install -y python-devel | 2020-04-16 23:40 | I, U | 6 22 | remove certbot | 2020-04-16 23:40 | Erase | 2 21 | -y install yum-utils | 2020-04-16 23:33 | Install | 3 20 | install certbot python2- | 2020-04-16 23:18 | Install | 30 ## 19 | install -y nginx | 2020-04-16 23:16 | Install | 1 E< 18 | install zip | 2020-04-16 22:57 | Install | 1 > 17 | install unzip | 2020-03-21 12:28 | Install | 1 history list