yum is the default package manager for Red Hat based systems, such as CentOS, Fedora or RHEL. Using yum, you can install or update a RPM package while resolving its package dependencies automatically. What if you want to download a RPM package without installing it on the system? For example, you may want to archive some RPM packages for later use or to install them on another machine.
Here is how to download a RPM package from yum repositories.
Method One: Yum
The yum command itself can be used to download a RPM package. The standard yum command offers '--downloadonly' option for this purpose.
By default, a downloaded RPM package will be saved in:
In the above, [repository] is the name of the repository (e.g., base, fedora, updates) from which the package is downloaded.
If you want to download a package to a specific directory (e.g., /tmp):
Note that if a package to download has any unmet dependencies, yum will download all dependent packages as well. None of them will be installed.
One important thing is that on CentOS/RHEL 6 or earlier, you will need to install a separate yum plugin (called yum-plugin-downloadonly) to be able to use '--downloadonly' command option:
Without this plugin, you will get the following error with yum:
Command line error: no such option: --downloadonly
Method Two: Yumdownloader
Another method to download a RPM package is via a dedicated package downloader tool called yumdownloader. This tool is part of yum-utils package which contains a suite of helper tools for yum package manager.
To download a RPM package:
The downloaded package will be saved in the current directory. You need to use root privilege because yumdownloader will update package index files during downloading. Unlike yum command above, none of the dependent package(s) will be downloaded.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!