$linuxjunkies
>

dnf-makecache(8)

Generate the DNF package manager cache from repository metadata.

UbuntuDebianFedoraArch

Synopsis

dnf [OPTIONS] makecache [--refresh]

Description

dnf makecache downloads and caches the metadata from all configured DNF repositories. This speeds up subsequent DNF operations by pre-populating the local cache instead of fetching metadata on each command.

By default, DNF automatically refreshes the cache when it expires (typically every 48 hours). This command is useful for manually refreshing the cache immediately, such as after adding new repositories or before running batch operations.

The --refresh flag forces a fresh download even if the cache is still considered valid.

Common options

FlagWhat it does
--refreshForce download of fresh metadata even if cache is still valid
-y, --assumeyesAssume yes to all prompts; useful in scripts
-v, --verboseIncrease verbosity to show detailed cache download progress
--enablerepo=REPOEnable a specific repository for cache generation
--disablerepo=REPODisable a specific repository when generating cache
--releasever=VERSIONSet the release version for repository variable substitution

Examples

Build the DNF cache from configured repositories; runs silently if cache is fresh

sudo dnf makecache

Force a fresh download of all repository metadata, updating the cache immediately

sudo dnf makecache --refresh

Refresh the cache with verbose output showing download progress for each repository

sudo dnf makecache --refresh -v

Generate cache including only the fedora-updates repository

sudo dnf makecache --enablerepo=fedora-updates

Silently refresh cache and pipe output to check for any errors

sudo dnf makecache -y 2>&1 | grep -i error

Refresh the cache and immediately check for available package updates

dnf makecache --refresh && dnf upgrade

Related commands