shallow丿ove
yum工具操作
- yum list #列出可用的所有软件包
[root@localhost ~]# ls /etc/yum.repos.d/CentOS-CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [root@localhost ~]# vi /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
CentOS-Base.repo,类似于一个容器,将所有rpm包放置于此,其中[base]就是yum的仓库名字
- yum install [-y] 包名
[root@localhost ~]# yum install texlive Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn Resolving Dependencies --> Running transaction check ---> Package texlive.x86_64 2:2012-38.20130427_r30134.el7 will be installed --> Processing Dependency: texlive-scheme-basic for package: 2:texlive-2012-38.20130427_r30134.el7.x86_64 …… texlive-zapfchan noarch 2:svn28614.0-38.el7 base 102 k texlive-zapfding noarch 2:svn28614.0-38.el7 base 65 k zziplib x86_64 0.13.62-5.el7 base 81 k Transaction Summary =================================================================================================== Install 1 Package (+246 Dependent packages) Total download size: 123 M Installed size: 237 M Is this ok [y/d/N]: N Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-11-14.03-35.L1YwuV.yumtx
若单用rpm安装texlive包时,则还需要安装246个依赖包。而使用yum工具同时可以解决软件的依赖关系,选项-y选项指的是对于每次询问都以yes作回答。这里Is this ok [y/d/N]:的d指的是只下载所有软件包,但并不安装。
- yum search 包名关键字 #搜索与包名相关的软件包
[root@localhost ~]# yum search vim Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn ======================================== N/S matched: vim ========================================= protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions vim-X11.x86_64 : The VIM version of the vi editor for the X Window System vim-common.x86_64 : The common files needed by any version of the VIM editor vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements vim-filesystem.x86_64 : VIM filesystem layout vim-minimal.x86_64 : A minimal version of the VIM editor Name and summary matches only, use "search all" for everything.
搜索与vim相关的包,但同时这种搜索方式会大量与包名无关的东西,这时候可以使用过滤命令来过滤一些无用的信息
[root@localhost ~]# yum list | grep 'vim' vim-minimal.x86_64 2:7.4.160-2.el7 @anaconda protobuf-vim.x86_64 2.5.0-8.el7 base vim-X11.x86_64 2:7.4.160-2.el7 base vim-common.x86_64 2:7.4.160-2.el7 base vim-enhanced.x86_64 2:7.4.160-2.el7 base vim-filesystem.x86_64 2:7.4.160-2.el7 base
- yum grouplist #列出所有组 yum groupinstall [-y] 组名 #安装组套件
[root@localhost ~]# yum grouplist Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done
例如:
[root@localhost ~]# yum groupinstall 'Virtualization Host' Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn Warning: Group core does not have any packages to install. Resolving Dependencies --> Running transaction check ---> Package abrt-addon-ccpp.x86_64 0:2.1.11-48.el7.centos will be installed --> Processing Dependency: abrt-libs = 2.1.11-48.el7.centos for package: abrt-addon-ccpp-2.1.11-48.el7.centos.x86_64 …… systemd x86_64 219-42.el7_4.4 updates 5.2 M systemd-libs x86_64 219-42.el7_4.4 updates 376 k systemd-sysv x86_64 219-42.el7_4.4 updates 70 k Transaction Summary =================================================================================================== Install 70 Packages (+216 Dependent packages) Upgrade ( 5 Dependent packages) Total download size: 92 M Is this ok [y/d/N]: N Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-11-14.04-31.EGR_5a.yumtx
安装不同组就会安装不同套件,不同类型组的rpm数量也就不同。
- yum remove [-y] 包名 #卸载软件包以及所有依赖包
使用rpm -e卸载软件包时,会提示依赖关系,在卸载此软件包时必须卸载所有有依赖关系的包,而yum工具可以完全自动卸载软件包以及所有依赖包
[root@localhost ~]# rpm -e ppp error: Failed dependencies: ppp = 2.4.5 is needed by (installed) NetworkManager-1:0.9.9.1-13.git20140326.4dba720.el7.x86_64
[root@localhost ~]# yum remove ppp Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package ppp.x86_64 0:2.4.5-33.el7 will be erased --> Processing Dependency: ppp = 2.4.5 for package: 1:NetworkManager-0.9.9.1-13.git20140326.4dba720.el7.x86_64 --> Running transaction check ---> Package NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 will be erased --> Processing Dependency: NetworkManager(x86-64) = 1:0.9.9.1-13.git20140326.4dba720.el7 for package: 1:NetworkManager-tui-0.9.9.1-13.git20140326.4dba720.el7.x86_64 --> Running transaction check ---> Package NetworkManager-tui.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved =================================================================================================== Package Arch Version Repository Size =================================================================================================== Removing: ppp x86_64 2.4.5-33.el7 @anaconda 852 k Removing for dependencies: NetworkManager x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda 5.9 M NetworkManager-tui x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda 253 k Transaction Summary =================================================================================================== Remove 1 Package (+2 Dependent packages) Installed size: 7.0 M Is this ok [y/N]: N Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-11-14.04-43.nJuUxJ.yumtx
-
yum update [-y] 包名 #更新软件包
-
yum provides "/*/命令"
[root@localhost ~]# yum provides "/*/vim" Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system Repo : base Matched from: Filename : /usr/share/cmake/editors/vim 2:docker-unit-test-1.12.6-48.git0fdc778.el7.centos.x86_64 : Automates deployment of containerized : applications - for running unit tests Repo : extras Matched from: Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/contrib/syntax/vim Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/runc-79c3939053c870fbb4de5484d98640d5ba028ef4/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim 2:docker-unit-test-1.12.6-55.gitc4618fb.el7.centos.x86_64 : Automates deployment of containerized : applications - for running unit tests Repo : extras Matched from: Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/contrib/syntax/vim Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/runc-31a9f6e22729606814e9bcbcf9eeebc1887527cb/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim 2:docker-unit-test-1.12.6-61.git85d7426.el7.centos.x86_64 : Automates deployment of containerized : applications - for running unit tests Repo : extras Matched from: Filename : /var/lib/docker-unit-test/runc-c5d311627d39439c5b1cc35c67a51c9c6ccda648/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/contrib/syntax/vim Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim git-1.8.3.1-11.el7.x86_64 : Fast Version Control System Repo : base Matched from: Filename : /usr/share/doc/git-1.8.3.1/contrib/vim git-1.8.3.1-12.el7_4.x86_64 : Fast Version Control System Repo : updates Matched from: Filename : /usr/share/doc/git-1.8.3.1/contrib/vim 2:vim-common-7.4.160-2.el7.x86_64 : The common files needed by any version of the VIM editor Repo : base Matched from: Filename : /usr/share/vim 2:vim-enhanced-7.4.160-2.el7.x86_64 : A version of the VIM editor which includes recent : enhancements Repo : base Matched from: Filename : /usr/bin/vim
而rpm -qf
which vim
用于查询命令源哪个已安装的软件包
yum搭建本地仓库
[root@localhost ~]# ls /mnt CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7 EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL[root@localhost ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak[root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo[root@localhost yum.repos.d]# rm -rf ./*[root@localhost yum.repos.d]# vi dvd.repo [dvd] name=install dvd baseurl=file:///mnt enable=1 gpgcheck=0[root@localhost yum.repos.d]# yum clean all Loaded plugins: fastestmirror Cleaning repos: dvd Cleaning up everything Cleaning up list of fastest mirrors[root@localhost yum.repos.d]# yum list | less
其中dvd就是本地仓库名字,带@表示已安装
[root@localhost yum.repos.d]# yum install GConf2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package GConf2.x86_64 0:3.2.6-8.el7 will be installed --> Processing Dependency: /usr/bin/killall for package: GConf2-3.2.6-8.el7.x86_64 --> Running transaction check ---> Package psmisc.x86_64 0:22.20-15.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: GConf2 x86_64 3.2.6-8.el7 dvd 1.0 M Installing for dependencies: psmisc x86_64 22.20-15.el7 dvd 141 k Transaction Summary ================================================================================================== Install 1 Package (+1 Dependent package) Total download size: 1.1 M Installed size: 6.8 M Is this ok [y/d/N]: N Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-11-14.05-25.euCvOB.yumtx
本地使用yum也能解决依赖关系
yum更换国内源
[root@localhost yum.repos.d]# rm -f dvd.repo [root@localhost yum.repos.d]# cp ../yum.repos.d.bak/* . cp: omitting directory ‘../yum.repos.d.bak/yum.repos.d’[root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo[root@localhost yum.repos.d]# rm -f CentOS-Base.repo [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo若没有安装wget命令,则可以使用curl -O[root@localhost yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1572 100 1572 0 0 6179 0 --:--:-- --:--:-- --:--:-- 6213[root@localhost yum.repos.d]# ls CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo[root@localhost yum.repos.d]# vi CentOS7-Base-163.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
其中[base]baseurl的$releasever是指Linux版本,$basearch是平台
[root@localhost yum.repos.d]# yum install -y wget Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.14-15.el7_4.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: wget x86_64 1.14-15.el7_4.1 updates 547 k Transaction Summary ================================================================================================== Install 1 Package Total download size: 547 k Installed size: 2.0 M Downloading packages: wget-1.14-15.el7_4.1.x86_64.rpm | 547 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : wget-1.14-15.el7_4.1.x86_64 1/1 Verifying : wget-1.14-15.el7_4.1.x86_64 1/1 Installed: wget.x86_64 0:1.14-15.el7_4.1 Complete!
yum下载rpm包方
安装扩展源epel
- yum install -y epel-release
- yum list | grep epel
[root@localhost ~]# cd /etc/yum.repos.d[root@localhost ~]# ls CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo [root@localhost yum.repos.d]# yum install -y epel-release Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: epel-release noarch 7-9 extras 14 k Transaction Summary ================================================================================================== Install 1 Package Total download size: 14 k Installed size: 24 k Downloading packages: epel-release-7-9.noarch.rpm | 14 kB 00:00:05 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-9.noarch 1/1 Verifying : epel-release-7-9.noarch 1/1 Installed: epel-release.noarch 0:7-9 Complete![root@localhost ~]# ls CentOS7-Base-163.repo CentOS-Sources.repo epel.repo CentOS-Debuginfo.repo CentOS-Vault.repo epel-testing.repo
[root@localhost ~]# vi epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1
yum下载rpm包方式
- yum install -y 包名 --downloadonly #只下载rpm包但不安装
[root@localhost ~]# yum install zsh --downloadonly Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.2-28.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: zsh x86_64 5.0.2-28.el7 base 2.4 M Transaction Summary ================================================================================================== Install 1 Package Total download size: 2.4 M Installed size: 5.6 M Background downloading packages, then exiting: zsh-5.0.2-28.el7.x86_64.rpm | 2.4 MB 00:00:03 exiting because "Download Only" specified[root@localhost ~]# rpm -q zsh package zsh is not installed
- ls /var/cache/yum/x86_64/7/ #查找默认下载位置
[root@localhost ~]# ls /var/cache/yum/x86_64/7/base/packages/ zsh-5.0.2-28.el7.x86_64.rpm
通过Repository的仓库名找路径
- yum install -y 包名 --downloadonly --downloaddir=路径 #指定下载路径
[root@localhost ~]# yum install zsh --downloadonly --downloaddir=/root/ Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: mirror.ehost.vn Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.2-28.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: zsh x86_64 5.0.2-28.el7 base 2.4 M Transaction Summary ================================================================================================== Install 1 Package Total download size: 2.4 M Installed size: 5.6 M Background downloading packages, then exiting: exiting because "Download Only" specified[root@localhost ~]# ls anaconda-ks.cfg zsh-5.0.2-28.el7.x86_64.rpm
- yum reinstall -y 包名 --downloadonly --downloaddir=路径 #重新下载包
[root@localhost ~]# yum install vim-enhanced --downloadonly --downloaddir=/root/ Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk Package 2:vim-enhanced-7.4.160-2.el7.x86_64 already installed and latest version Nothing to do
当系统已安装了rpm包,再次下载rpm则不会成功,这时候使用reinstall重新安装则可以成功下载rpm包
[root@localhost ~]# yum reinstall vim-enhanced --downloadonly --downloaddir=/root/ Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk Resolving Dependencies --> Running transaction check ---> Package vim-enhanced.x86_64 2:7.4.160-2.el7 will be reinstalled --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Reinstalling: vim-enhanced x86_64 2:7.4.160-2.el7 base 1.0 M Transaction Summary ================================================================================================== Reinstall 1 Package Total download size: 1.0 M Installed size: 2.2 M Background downloading packages, then exiting: vim-enhanced-7.4.160-2.el7.x86_64.rpm | 1.0 MB 00:00:01 exiting because "Download Only" specified[root@localhost ~]# ls anaconda-ks.cfg vim-enhanced-7.4.160-2.el7.x86_64.rpm zsh-5.0.2-28.el7.x86_64.rpm