Ther are multiple ways in which you can download a yum package without installing it. The 2 most commonly used methods are described here in the post.
1. using the “downloadonly” plugin for yum
2. using “yumdownloader” utility.
Method 1 : using the “downloadonly” plugin for yum
1. Install the package including “downloadonly” plugin:
# yum install yum-plugin-downloadonly
2. Run yum command with “–downloadonly” option as follows:
# yum install --downloadonly --downloaddir=[directory] [package]
For example to download the package for firefox without actually installing it, use the command shown below:
# yum install --downloadonly --downloaddir=/tmp firefox
The firefox package gets downloded into the specified /tmp directory. Confirm the RPM files are available in the specified download directory.
# ls -lrt /tmp/firefox-52.5.0-1.el7.centos.x86_64.rpm -rw-r--r--. 1 root root 87273716 Nov 17 16:21 /tmp/firefox-52.5.0-1.el7.centos.x86_64.rpm
3. You can also download multiple packages at the same time using the downloadonly plugin. For example to download packages for firefox and mutt at the same time, use the command below :
# yum install --downloadonly --downloaddir=/tmp firefox mutt
Method 2 : using the “yumdownloader” utility
The “yumdownloader” command is particularly useful when you want to download a package which is already installed on your system.
1. Install the yum-utils package:
# yum install yum-utils
2. Run the command followed by the desired package.
# yumdownloader [package]
For example to download a package for mutt which is already installed on the system, use the below command.
# yumdownloader mutt Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.vcu.edu * epel: mirror.us.leaseweb.net * extras: mirror.lug.udel.edu * nux-dextop: li.nux.ro * updates: mirror.wdc1.us.leaseweb.net mutt-1.5.21-27.el7.x86_64.rpm | 1.4 MB 00:00:00
3. You would find the latest mutt package downloaded in the current working diretory.
# ls -lrt mutt-1.5.21-27.el7.x86_64.rpm -rw-r--r--. 1 root root 1444476 Aug 10 18:21 mutt-1.5.21-27.el7.x86_64.rpm
You can also specify a download directory to download the package. For example,
# yumdownloader --destdir=/var/tmp mutt