yum总结:
repolist #针对仓库操作
all #显示所有
list #显示所有可安装的软件包
installed #显示已经安装的
updates #显示可更新的
check-update #显示可更新的
update #更新
install #安装
localinstall #本地安装
reinstall #重新安装
remove #卸载
erase #卸载
info #显示软件包信息
search #搜索
provides #查询命令属于哪个软件包
groups #组包管理
install #安装
remove #移除
clean #清空
all #清空所有
packages #清空软件包
plugins #清空插件
makecahce #生成缓存
history #历史记录
list all #显示所有
info ID #显示某次记录的信息
undo ID #回滚这次的操作
yum-config-manager #yum仓库管理工具
--disable #禁用仓库
--enable #启用仓库
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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
[root@qls ~]# ll /etc/yum.repos.d/ total 40 -rw-r--r-- 1 root root 1664 Nov 23 2018 CentOS-Base.repo -rw-r--r-- 1 root root 1309 Nov 23 2018 CentOS-CR.repo -rw-r--r-- 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo -rw-r--r-- 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo -rw-r--r-- 1 root root 630 Nov 23 2018 CentOS-Media.repo -rw-r--r-- 1 root root 1331 Nov 23 2018 CentOS-Sources.repo -rw-r--r-- 1 root root 5701 Nov 23 2018 CentOS-Vault.repo -rw-r--r-- 1 root root 951 Oct 3 2017 epel.repo -rw-r--r-- 1 root root 1050 Oct 3 2017 epel-testing.repo 怎么获取yum源 本地的ISO镜像 yum源仓库 联网的方式下载 本地yum仓库 yum的种类 base #基础源 epel #扩展源 软件官方源 # nginx zabbix docker 阿里源 清华源 中科大 163源 #更新源 [root@qls ~]# rm -rf /etc/yum.repos.d/* [root@qls ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo [root@qls ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo [root@qls ~]# ll /etc/yum.repos.d/ total 8 -rw-r--r-- 1 root root 2523 Jul 30 09:51 CentOS-Base.repo -rw-r--r-- 1 root root 664 May 11 2018 epel.repo #显示可用的yum仓库 [root@qls ~]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status !base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,070 !epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,422 !extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 412 !updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 900 repolist: 24,804 #显示所有的 [root@qls ~]# yum repolist all Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status !base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 10,070 centosplus/7/x86_64 CentOS-7 - Plus - mirrors.aliyun.com disabled contrib/7/x86_64 CentOS-7 - Contrib - mirrors.aliyun.com disabled !epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 enabled: 13,422 epel-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled epel-source Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled !extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 412 !updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 900 repolist: 24,804 [root@qls ~]# yum install -y yum-utils [root@qls ~]# yum-config-manager --disable epel [root@qls ~]# yum repolist all Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 10,070 centosplus/7/x86_64 CentOS-7 - Plus - mirrors.aliyun.com disabled contrib/7/x86_64 CentOS-7 - Contrib - mirrors.aliyun.com disabled epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 disabled epel-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled epel-source Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 412 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 900 repolist: 11,382 [root@qls ~]# yum-config-manager --enable epel #软件包管理 #显示所有可安装的包 [root@qls ~]# yum list #显示系统中已经安装的包 [root@qls ~]# yum list installed [root@qls ~]# yum list | grep ^tree tree.x86_64 1.6.0-10.el7 @base treelayout.noarch 1.0.3-4.el7 epel treelayout-demo.noarch 1.0.3-4.el7 epel treelayout-javadoc.noarch 1.0.3-4.el7 epel #显示可更新的包 [root@qls ~]# yum check-update [root@qls ~]# yum list updates [root@qls ~]# rpm -qa httpd httpd-2.4.6-88.el7.centos.x86_64 #更新某个软件包 [root@qls ~]# yum update httpd -y [root@qls ~]# rpm -qa httpd httpd-2.4.6-93.el7.centos.x86_64 #安装软件包 [root@qls ~]# yum install tree #交互式 麻烦 [root@qls ~]# yum install tree -y #免交互 #卸载 [root@qls ~]# yum remove tree -y [root@qls ~]# yum erase tree -y #联网安装软件包 [root@qls ~]# yum install -y https://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm #本地安装 [root@qls ~]# yum localinstall -y /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm [root@qls ~]# systemctl start httpd [root@qls ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2020-07-30 10:36:26 CST; 6s ago [root@qls ~]# rm -f /etc/httpd/conf/httpd.conf [root@qls ~]# systemctl restart httpd Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. #重新安装 [root@qls ~]# yum reinstall -y httpd #搜索 [root@qls ~]# yum search ifconfig Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ================================================= N/S matched: ifconfig ================================================= python36-ifcfg.noarch : Python cross-platform network interface discovery (ifconfig/ipconfig/ip) Name and summary matches only, use "search all" for everything. #联网搜索命令属于哪个软件包 [root@qls ~]# yum provides ifconfig Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com epel/x86_64/filelists_db | 12 MB 00:00:04 net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools Repo : @base Matched from: Filename : /usr/sbin/ifconfig #查看软件包相关信息 [root@qls ~]# yum info tree Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages Name : tree Arch : x86_64 Version : 1.6.0 Release : 10.el7 Size : 87 k Repo : installed Summary : File system tree viewer URL : http://mama.indstate.edu/users/ice/tree/ License : GPLv2+ Description : The tree utility recursively displays the contents of directories in a : tree-like format. Tree is basically a UNIX port of the DOS tree : utility. #组包的安装 [root@qls ~]# yum groups install Python #组包的卸载 [root@qls ~]# yum groups remove Python #yum缓存 #清除包的缓存 [root@qls ~]# yum clean packages Loaded plugins: fastestmirror Cleaning repos: base epel extras updates 0 package files removed #清除插件的缓存 [root@qls ~]# yum clean plugins Loaded plugins: fastestmirror Cleaning repos: base epel extras updates Cleaning up list of fastest mirrors #清除所有缓存 [root@qls ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: base epel extras updates #生成缓存 [root@qls ~]# yum makecache #yum 历史记录 [root@qls ~]# yum history Loaded plugins: fastestmirror ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 27 | reinstall -y httpd | 2020-07-30 10:37 | Reinstall | 1 26 | localinstall -y /mnt/Pac | 2020-07-30 10:11 | Install | 1 25 | erase tree -y | 2020-07-30 10:10 | Erase | 1 24 | install -y https://mirro | 2020-07-30 10:09 | Install | 1 #显示所有历史记录 [root@qls ~]# yum history list all Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 27 | root <root> | 2020-07-30 10:37 | Reinstall | 1 26 | root <root> | 2020-07-30 10:11 | Install | 1 25 | root <root> | 2020-07-30 10:10 | Erase | 1 24 | root <root> | 2020-07-30 10:09 | Install | 1 23 | root <root> | 2020-07-30 10:08 | Erase | 1 22 | root <root> | 2020-07-30 10:08 | Install | 1 #查看某个ID的历史信息 [root@qls ~]# yum history info 15 Loaded plugins: fastestmirror Transaction ID : 15 Begin time : Wed Jul 22 08:51:56 2020 Begin rpmdb : 372:6b59857cbbb441dc1cf9e1a96ab23013fd830365 End time : (0 seconds) End rpmdb : 373:c16ad60498e5079097783959293418aeedfc68b5 User : root <root> Return-Code : Success Command Line : install -y psmisc Transaction performed with: Installed rpm-4.11.3-35.el7.x86_64 @anaconda Installed yum-3.4.3-161.el7.centos.noarch @anaconda Installed yum-plugin-fastestmirror-1.1.31-50.el7.noarch @anaconda Packages Altered: Install psmisc-22.20-16.el7.x86_64 @base history info #回滚历史ID为10的操作 [root@qls ~]# yum history undo 10 -y [root@qls ~]# yum --setopt=history_list_view=commands history list all Loaded plugins: fastestmirror ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 28 | history undo 10 | 2020-07-30 10:49 | Erase | 21 27 | reinstall -y httpd | 2020-07-30 10:37 | Reinstall | 1 26 | localinstall -y /mnt/Pac | 2020-07-30 10:11 | Install | 1 25 | erase tree -y | 2020-07-30 10:10 | Erase | 1 24 | install -y https://mirro | 2020-07-30 10:09 | Install | 1 23 | erase tree -y | 2020-07-30 10:08 | Erase | 1 22 | install tree -y | 2020-07-30 10:08 | Install | 1 21 | remove tree -y | 2020-07-30 10:08 | Erase | 1 [root@qls ~]# ll /etc/yum.conf #只下载 不安装 指定下载的路径 [root@qls ~]# yum install -y --downloadonly --downloaddir=/opt nginx [root@qls ~]# ll /opt/ total 4380 -rw-r--r-- 1 root root 93872 Jul 4 2014 centos-indexhtml-7-9.el7.centos.noarch.rpm -rw-r--r-- 1 root root 65788 Jul 4 2014 dejavu-fonts-common-2.33-6.el7.noarch.rpm -rw-r--r-- 1 root root 1482820 Jul 4 2014 dejavu-sans-fonts-2.33-6.el7.noarch.rpm -rw-r--r-- 1 root root 260512 Nov 12 2018 fontconfig-2.13.0-4.3.el7.x86_64.rpm -rw-r--r-- 1 root root 10116 Jul 4 2014 fontpackages-filesystem-1.44-8.el7.noarch.rpm -rw-r--r-- 1 root root 149492 Jul 4 2014 gd-2.0.35-26.el7.x86_64.rpm -rw-r--r-- 1 root root 278636 Apr 25 2018 gperftools-libs-2.6.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 137752 Aug 23 2019 libjpeg-turbo-1.2.90-8.el7.x86_64.rpm -rw-r--r-- 1 root root 621364 Aug 23 2019 libX11-1.6.7-2.el7.x86_64.rpm -rw-r--r-- 1 root root 168172 Aug 23 2019 libX11-common-1.6.7-2.el7.noarch.rpm -rw-r--r-- 1 root root 29784 Jul 4 2014 libXau-1.0.8-2.1.el7.x86_64.rpm -rw-r--r-- 1 root root 218900 Nov 12 2018 libxcb-1.13-1.el7.x86_64.rpm -rw-r--r-- 1 root root 56800 Aug 11 2017 libXpm-3.5.12-1.el7.x86_64.rpm -rw-r--r-- 1 root root 575413 Oct 4 2019 nginx-1.16.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 19857 Oct 4 2019 nginx-all-modules-1.16.1-1.el7.noarch.rpm -rw-r--r-- 1 root root 21089 Oct 4 2019 nginx-filesystem-1.16.1-1.el7.noarch.rpm -rw-r--r-- 1 root root 30445 Oct 4 2019 nginx-mod-http-image-filter-1.16.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 39849 Oct 4 2019 nginx-mod-http-perl-1.16.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 29613 Oct 4 2019 nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 58301 Oct 4 2019 nginx-mod-mail-1.16.1-1.el7.x86_64.rpm -rw-r--r-- 1 root root 86465 Oct 4 2019 nginx-mod-stream-1.16.1-1.el7.x86_64.rpm [root@qls ~]# cat /etc/yum.conf [main] #cachedir=/var/cache/yum/$basearch/$releasever cachedir=/opt #指定下载保存路径 keepcache=1 #开启缓存 [root@qls ~]# yum install -y nginx [root@qls ~]# ll /opt/ total 12 drwxr-xr-x 4 root root 256 Jul 30 11:03 base drwxr-xr-x 4 root root 4096 Jul 30 11:03 epel drwxr-xr-x 4 root root 161 Jul 30 11:03 extras -rw-r--r-- 1 root root 117 Jul 30 11:04 timedhosts -rw-r--r-- 1 root root 107 Jul 30 11:03 timedhosts.txt drwxr-xr-x 4 root root 161 Jul 30 11:03 updates [root@qls ~]# find /opt/ -name "*.rpm" /opt/base/packages/centos-indexhtml-7-9.el7.centos.noarch.rpm /opt/base/packages/dejavu-fonts-common-2.33-6.el7.noarch.rpm /opt/base/packages/fontconfig-2.13.0-4.3.el7.x86_64.rpm /opt/base/packages/dejavu-sans-fonts-2.33-6.el7.noarch.rpm /opt/base/packages/fontpackages-filesystem-1.44-8.el7.noarch.rpm /opt/base/packages/gd-2.0.35-26.el7.x86_64.rpm /opt/base/packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm /opt/base/packages/libX11-1.6.7-2.el7.x86_64.rpm /opt/base/packages/libX11-common-1.6.7-2.el7.noarch.rpm /opt/base/packages/libXau-1.0.8-2.1.el7.x86_64.rpm /opt/base/packages/libXpm-3.5.12-1.el7.x86_64.rpm /opt/base/packages/libjpeg-turbo-1.2.90-8.el7.x86_64.rpm /opt/base/packages/libxcb-1.13-1.el7.x86_64.rpm /opt/epel/packages/nginx-all-modules-1.16.1-1.el7.noarch.rpm /opt/epel/packages/nginx-1.16.1-1.el7.x86_64.rpm /opt/epel/packages/nginx-filesystem-1.16.1-1.el7.noarch.rpm /opt/epel/packages/nginx-mod-http-image-filter-1.16.1-1.el7.x86_64.rpm /opt/epel/packages/nginx-mod-http-perl-1.16.1-1.el7.x86_64.rpm /opt/epel/packages/nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64.rpm /opt/epel/packages/nginx-mod-mail-1.16.1-1.el7.x86_64.rpm /opt/epel/packages/nginx-mod-stream-1.16.1-1.el7.x86_64.rpm |