How to Make DNF and YUM Save Downloaded RPM Packages

DNF/YUM can automatically download the RPM packages and install them. Under some situations, we may prefer to make a copy of the RPM files for offline usage so that no need to have network connections to install the software packages. For such purposes, we need to make a copy of the RPM packages. It is possible to visit the repositories and download the RPM files. The problem is there are many dependencies among the packages and manually resolving the dependencies and downloading all packages is tedious. Let’s take a look at the functions from DNF/YUM to "cache" these RPM packages.

Method 1: Download RPM packages using DNF/YUM

You can make DNF store a copy of the packages and dependencies as follows.

# dnf install --downloadonly --downloaddir=/path/to/dir/ PACKAGE

–downloaddir=, –destdir=

Redirect downloaded packages to provided directory. The option has to be used together with the -downloadonly command line option, with the download command (dnf-plugins-core) or with the system-upgrade command (dnf-plugins-extras).


Download the resolved package set without performing any rpm transaction (install/upgrade/erase).

Check more of the usage from DNF manual. If you are interested in the implementation, check

Method 2: Set the global DNF configuration file

You can also change the global DNF configuration file to make DNF cache all packages downloaded.

Edit /etc/dnf/dnf.conf and set keepcache to True. Then the packages can be found in DNF/YUM’s default cache directory. Note that this is a global configuration and all the packages will be stored.


Keeps downloaded packages in the cache when set to True. Even if it is set to False and packages have not been installed they will still persist until next successful transaction. The default is False.

Check more about the configuration file from DNF doc. If you are interested in the implementation, check the

Leave a Reply

Your email address will not be published. Required fields are marked *