Thursday, October 02, 2014

How to use yum command to download package without installing it?

There are two ways to download a package without installing it.

First - use "downloadonly" plugin of yum.

1] Install the package including "downloadonly" plugin.

RHEL-5
[root@server ~]# yum install yum-downloadonly

RHEL-6
[root@server ~]# yum install yum-plugin-downloadonly

2] Now use downloadonly plugin with following yum command.

[root@server ~]# yum install --downloadonly --downloaddir=<directory-path> <package-name>

3] Confirm the downloaded package in specified download directory.

Note: 
  • This is only applicable to "yum install" and not for "yum groupinstall" .
  • If you specified only package name then latest package will be downloaded, to download
  • specific package type full package name and version.
  • If you do not use --downloaddir option files are saved by default in /var/cache/yum/.
Second - use "yumdownloader" utility to download package

1] Install the yum-utils package which includes "yumdownloader" utility.

[root@server ~]# yum install yum-utils

2] Now use the following command with desired package name.

[root@server ~]# yumdownloader <package-name>

Note:
  • The package is saved in the current working directly by default; use the --destdir option to specify an alternate location.
  • Be sure to add --resolve if you need to download dependencies.