I sometimes face a problem that I only want to search or install a single tiny package and I am on a very limited internet connection (say: mobile data in a remote place abroad). Being more of an emergency case, I wouldn't mind using the cached repository contents; the last update would have been just a week or two ago. Yet dnf insists on downloading several MB of metadata which takes forever and which I don't want, and earlier today it happened that I was just rendered unable to finish a simple search operation due to this. I tried running the command offline but it refuses to operate if the metadata is not current. Is there an option forcing the command to use the old data, or a configuration entry to change the period for how long it is considered valid?

  • You download the specific rpm. However searching it in pages might mean (or not) more data than getting the metadata. – Rui F Ribeiro Jan 17 '17 at 18:58

If you look in the various dnf and yum repo config files you should find several explicit metadata expiry times, eg:



You can override these on the dnf command line using --setopt=, but you must explicitly do it for every enabled repository, as well as the dnf main configuration. So you end up with something like

sudo dnf --setopt=metadata_expire=-1 \
 --setopt=fedora.metadata_expire=-1 \
 --setopt=fedora-update.metadata_expire=-1 \
 --setopt=rpmfusion-free.metadata_expire=-1 \
 search abcdef

Note the use of sudo to avoid dnf creating a separate cache for the user.

  • You can also set this to a short value (i.e., 1m ) to force the cache to be dumped quickly, thought there may be other more elegant ways to do that. – imjustmatthew Nov 11 at 23:46

I know this question is a little old (and this option might be new) but this just worked for me:

 -C, --cacheonly
              Run entirely from system cache, don't update the cache and use it even in case it is expired.

So dnf -C install ... worked for me

p.s. in my case I was installing RPMs that I downloaded elsewhere and transferred over sneakernet because my networking is busted and I did not want to subvert dnf by installing directly with the rpm executable


It's not temporary, but it is reversible.

sudo zypper modifyrepo --no-refresh --all


sudo zypper modifyrepo --no-refresh --remote

You can manually refresh, when you have the data to spare with

sudo zypper refresh

This will also turn off refresh for the repos when using the GUI.

You can also control them in the GUI with the Repositories option in YAST, but that will do refresh, unless already turned off, when first launched.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.