命令
yum
描述
Yellowdog Updater Modified
在线安装软件包
用法
1
| yum [options] command [package ...]
|
选项
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Options: List of Commands: check-update 检查是否有可用的软件包更新 clean 删除缓存 deplist 显示软件包的依赖关系 downgrade 降级软件包 remove 删除软件包 groups 显示或管理软件包组 history 显示或管理安装历史 info 显示软件包详情 install 安装软件包 list 显示所有软件包 load-transaction 从文件名加载以保存的事务,一般为/tmp/yum_save_tx.*文件 makecache 生成镜像源的软件包缓存 provides 查询指定命令是由哪个软件包提供的 reinstall 重新安装软件包 repolist 显示软件源信息 search 搜索软件包 shell 进入yum交互模式 swap Simple way to swap packages, instead of using shell update 更新软件包,包括系统版本和内核 upgrade 更新软件包
Options: -c [config file] 指定yum配置文件 --showduplicates 显示列表或搜索命令中的重复项 -q, --quiet 精简显示安装过程 -v, --verbose 显示详情 -y, --assumeyes 出现提示时自动输入yes --assumeno 出现提示时自动输入no --installroot=[path] 指定安装的根目录 --enablerepo=[repo] 启用软件源,支持通配符 --disablerepo=[repo] 禁用软件源,支持通配符 -x [package], --exclude=[package] 排除指定软件包 --noplugins 禁用插件 --nogpgcheck 禁用gpg检查 --skip-broken 跳过错误的包 --downloadonly 只下载软件包 --downloaddir=DLDIR 指定下载软件包的存储路径 --bugfix 在更新中包含与bug修复相关的包 --security 在更新中包括与安全相关的包
|
注意
名称说明: 软件源=软件仓库=镜像仓库
yum配置文件/etc/yum.conf
,yum源目录/etc/yum.repos.d/
yum支持安装本地rpm包并自动解决依赖关系yum install xxx.rpm
yum命令存在bug,目前在新系统(8.0+)上已被最新的安装工具dnf
命令替代
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
| $ yum clean all $ yum makecache Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 mysql-connectors-community | 2.6 kB 00:00:00 mysql-tools-community | 2.6 kB 00:00:00 mysql80-community | 2.6 kB 00:00:00 updates | 2.9 kB 00:00:00 Metadata Cache Created
$ yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status base/7/x86_64 CentOS-7 - Base 10,072 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,551 extras/7/x86_64 CentOS-7 - Extras 453 mysql-connectors-community/x86_64 MySQL Connectors Community 185 mysql-tools-community/x86_64 MySQL Tools Community 123 mysql80-community/x86_64 MySQL 8.0 Community Server 229 updates/7/x86_64 CentOS-7 - Updates 1,729
$ yum -v repolist base Loading "fastestmirror" plugin Config time: 0.008 Yum version: 3.4.3 Loading mirror speeds from cached hostfile Setting up Package Sacks pkgsack time: 0.011 Repo-id : base/7/x86_64 Repo-name : CentOS-7 - Base Repo-status : enabled Repo-revision: 1604001756 Repo-updated : Fri Oct 30 04:03:00 2020 Repo-pkgs : 10,072 Repo-size : 8.9 G Repo-baseurl : https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ Repo-expire : 21,600 second(s) (last: Mon Jan 17 09:37:51 2022) Filter : read-only:present Repo-filename: /etc/yum.repos.d/CentOS-Base.repo repolist: 10,072
$ yum search mysql
$ yum info mysql-community-client.x86_64 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Available Packages Name : mysql-community-client Arch : x86_64 Version : 8.0.23 Release : 1.el7 Size : 48 M Repo : mysql80-community/x86_64 Summary : MySQL database client applications and tools URL : http://www.mysql.com/ License : Copyright (c) 2000, 2020, Oracle and/or its affiliates. Under GPLv2 license as shown in : the Description field. Description : This package contains the standard MySQL clients and administration : tools.
$ yum -y install mysql-community-client.x86_64 ...
$ yum history Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 12 | root <root> | 2021-03-11 20:02 | Install | 4 11 | root <root> | 2021-03-05 10:22 | Erase | 7 EE 10 | root <root> | 2021-03-04 22:06 | Install | 1 9 | root <root> | 2021-03-04 21:55 | I, O | 7 EE 8 | root <root> | 2021-03-04 18:31 | Install | 1 7 | root <root> | 2021-03-03 17:05 | Install | 1 6 | root <root> | 2021-01-11 12:39 | Install | 9 5 | root <root> | 2021-01-07 14:50 | Install | 82 4 | root <root> | 2021-01-07 22:50 | Install | 2 3 | root <root> | 2021-01-07 22:48 | I, U | 53 EE 2 | root <root> | 2021-01-07 22:47 | Install | 1 1 | System <unset> | 2020-11-27 05:42 | Install | 299
$ yum history info 12
$ yum history undo 12
$ yum remove mysql80-community-release.noarch
$ yum list all | grep vim vim-common.x86_64 2:7.4.629-8.el7_9 @updates vim-enhanced.x86_64 2:7.4.629-8.el7_9 @updates vim-filesystem.x86_64 2:7.4.629-8.el7_9 @updates vim-minimal.x86_64 2:7.4.629-8.el7_9 @updates beakerlib-vim-syntax.noarch 1.25-1.el7 epel boxes-vim.noarch 1.3-4.el7 epel fluxbox-vim-syntax.noarch 1.3.7-1.el7 epel geany-plugins-vimode.x86_64 1.36-1.el7 epel neovim.x86_64 0.3.0-2.el7 epel protobuf-vim.x86_64 2.5.0-8.el7 base python2-neovim.noarch 0.3.2-1.el7 epel python36-neovim.noarch 0.3.2-1.el7 epel vim-X11.x86_64 2:7.4.629-8.el7_9 updates vim-ansible.noarch 3.0-1.el7 epel vim-fugitive.noarch 2.5-1.el7 epel vim-go.x86_64 1.8-3.el7 epel vim-gtk-syntax.noarch 20130716-1.el7 epel vim-halibut.noarch 1.2-1.el7 epel vim-jellybeans.noarch 1.7-1.el7 epel vim-toml.noarch 0-0.2.20180615git85ba827.el7 epel vim-trailing-whitespace.noarch 1.0-1.20191209git6b7cdec.el7 epel vim-vimoutliner.noarch 0.4.0-8.el7 epel xtuple-csvimp.x86_64 0.5.4-8.el7 epel xtuple-csvimp-devel.x86_64 0.5.4-8.el7 epel
$ yum list installed | grep vim vim-common.x86_64 2:7.4.629-8.el7_9 @updates vim-enhanced.x86_64 2:7.4.629-8.el7_9 @updates vim-filesystem.x86_64 2:7.4.629-8.el7_9 @updates vim-minimal.x86_64 2:7.4.629-8.el7_9 @updates
$ yum provides killall Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile psmisc-22.20-17.el7.x86_64 : Utilities for managing processes on your system Repo : base Matched from: Filename : /usr/bin/killall
$ yum update
$ yum --exclude "kernel* centos-release* linux-firmware*" update
$ yum kernel-headers-$(uname -r) kernel-devel-$(uname -r)
$ sed -i '/distroverpkg/a\exclude=kernel* centos-release* linux-firmware*' /etc/yum.conf
yum install yum-utils yumdownloader openssh
yum --downloadonly --downloaddir=/tmp install wget yum --downloadonly --downloaddir=/tmp reinstall openssh openssh-server
rpm -qpl /tmp/openssh-server-7.4p1-22.el7_9.x86_64.rpm
rpm2cpio openssh-7.4p1-22.el7_9.x86_64.rpm |cpio -t rpm2cpio openssh-7.4p1-22.el7_9.x86_64.rpm |cpio -t |grep bin
rpm2cpio openssh-7.4p1-22.el7_9.x86_64.rpm |cpio -idmv rpm2cpio openssh-server-7.4p1-22.el7_9.x86_64.rpm |cpio -idv ./etc/ssh/sshd_config
|