Yum is commonly used in major RPM based Linux distributions such as CentOS, Redhat and SuSE, it can help us perform automatic dependency checking. If you’d like to only download the RPM packages via yum and do not install/update them, it’s nearly impossible by default.
How can we download a RPM package using YUM? Generally, there are two ways, you can use either yum-downloadonly or yum-utils. 1, yum-downloadonly installation and usage example You just need to install a plugin called yum-downloadonly. This plugin supplies a new parameter called –downloadonly so that yum can download the package s without an further installation/upgrade. It’s much like apt-get‘s -d option in Ubuntu/Debian:
$ yum --help| grep download Loaded plugins: downloadonly, fastestmirror --downloadonly don't update, just download --downloaddir=DLDIR specifies an alternate directory to store package
A further question is How can I install the download-only plugin for Yum? It’s as simple as a normal install, you just need to run:
$ sudo yum install yum-downloadonly
If you wanna download a package without installation, you just need to add the parameter –downloadonly. By default the downloaded package will be stored in /var/cache/yum, you can specifies an alternate directory to store this file such as /opt, like this:
yum update httpd -y --downloadonly --downloaddir=/opt
2, yum-utils.noarch installation and usage example
Yum-utils is a collection of utilities and plugins extending and supplementing yum in different ways, and all the utilities are contained in yum-utils package, including the one that we need which is called yumdownloader.
# yum -y install yum-utils.noarch
Now we can use the yumdownloader command to download packages from yum repositories. Here’s an example:
# yumdownloader httpd
When you get the RPM, you can query further information from it, or decompress it.