How to use dnf/yum to download a package without installing it
Environment
- Red Hat Enterprise Linux All Versions
Issue
- How do I use
dnf/yumto download a package without installing it?
Resolution
There are two ways to download a package (RPM file) without installing it.
One is using the "downloadonly" option/plugin for yum/dnf, the other is to use the yumdownloader utility.
Using the "--downloadonly" option in yum/dnf
-
Run
yumor thednfcommand with "--downloadonly" option as follows:# yum install --downloadonly --downloaddir=<directory> <package-name-without-rpm-extension> OR # dnf install --downloadonly --downloaddir=<directory> <package-name-without-rpm-extension> -
Confirm the RPM files are available in the specified download directory.
# ls -al <directory>
Note:
- Before using the plugin, check /etc/yum/pluginconf.d/downloadonly.conf to confirm that this plugin is "enabled=1"
- This is applicable for "yum install/yum update" and not for "yum groupinstall". Use "yum groupinfo" to identify packages within a specific group.
- If only the package name is specified, the latest available package is downloaded (such as sshd). Otherwise, you can specify the full package name and version (such as httpd-2.2.3-22.el5).
- Specify the package name without the .rpm extension, such as httpd-2.2.3-22.el5
- If you do not use the --downloaddir option, files are saved by default in /var/cache/yum/ in rhel-{arch}-channel/packages
- If desired, you can download multiple packages on the same command.
- You still need to re-download the repodata if the repodata expires before you re-use the cache. By default it takes two hours to expire.
- From RHEL8 onward, the yum command has been replaced with dnf, so dnf can be used in place of yum in the commands in this article.
Yumdownloader (All versions of RHEL )
If downloading a installed package, yumdownloader is useful.
-
Install the yum-utils package:
# yum install yum-utils -
Run the command followed by the desired package:
# yumdownloader <package-name-without-rpm-extension>
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.
- For more information:
$ man yumdownloader
Older Versions of RHEL ( RHEL 5/6 )
-
Install the package including "downloadonly" plugin (RHEL5/6):
(RHEL5) # yum install yum-downloadonly (RHEL6) # yum install yum-plugin-downloadonly -
Run
yumor thednfcommand with "--downloadonly" option as follows:# yum install --downloadonly --downloaddir=<directory> <package-name-without-rpm-extension> -
Confirm the RPM files are available in the specified download directory.
# ls -al <directory>
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments