Updated: 17 October 2026 · Applies to: dnf 4.20 on AlmaLinux 10.2 and dnf 4.14 on AlmaLinux 9.8 (yum is a link to dnf); the same commands work on Rocky Linux and RHEL 9 and 10
yum clean all deletes dnf's cache in /var/cache/dnf: the downloaded repository metadata, the solver files built from it and any package files kept there. It does not remove, update or change installed packages, their configuration or the RPM database. The next yum command simply downloads fresh metadata. To force a package to be installed again, run yum reinstall PACKAGE (the same as dnf reinstall).
On AlmaLinux, Rocky Linux and RHEL 8 and later, yum is only another name for dnf: on AlmaLinux 10 both /usr/bin/yum and /usr/bin/dnf point to dnf-3. CentOS 7 and CentOS Linux 8 are end of life; move such servers to AlmaLinux or Rocky Linux.
What yum clean all removes
Lab example from an AlmaLinux 10 test container with four repositories enabled:
$ du -sh /var/cache/dnf 61M /var/cache/dnf $ yum clean all 26 files removed $ du -sh /var/cache/dnf 1.3M /var/cache/dnf
clean all runs all of the cleaning types below. According to the DNF command reference, it also removes data left behind by disabled or removed repositories and by older release versions.
dnf clean metadata # repository metadata (repodata) used to see which packages exist dnf clean dbcache # solver cache files generated from the metadata dnf clean packages # downloaded package files dnf clean expire-cache # only marks the metadata as expired, deletes nothing
The old yum clean headers no longer exists. dnf answers dnf clean: error: argument type: invalid choice: 'headers' (choose from metadata, packages, dbcache, expire-cache, all).
To download fresh metadata straight away instead of on the next command, run dnf makecache. It prints one line per repository and Metadata cache created.
When cleaning the cache helps
- "Cannot download repomd.xml" or "Failed to download metadata for repo": run
yum clean alland try again. If it still fails, test the network and DNS (curl -I https://repo.almalinux.org/), or disable a broken third-party repository withdnf config-manager --set-disabled REPOID. See also the bad id for repo error. - "Checksum doesn't match" or "Package does not match intended download": a mirror was out of date while you downloaded. Clean the cache and try again later.
- Old package versions offered after a repository changed:
dnf clean metadataforces fresh metadata. - A full disk:
du -sh /var/cache/dnfshows how much space the cache uses. For "Insufficient space in download directory", see this guide.
Cleaning does not fix a damaged RPM database (errors such as "rpmdb open failed"). For that, see fix rpmdb open failed errors and rebuild the RPM database.
Keep downloaded packages
By default dnf deletes package files after installing them. To keep them, for example to install the same versions on other servers, add keepcache=True to the [main] section of /etc/dnf/dnf.conf. The files then stay in /var/cache/dnf/REPO-ID/packages/ until you run dnf clean packages; in our test, one reinstall with --setopt=keepcache=True left tree-2.1.0-8.el10.x86_64.rpm there, and dnf clean packages answered 1 file removed. To collect packages without installing them, see downloading RPM packages with dependencies.
How to force a reinstall with yum or dnf
- Reinstall the package from the repository:
yum reinstall tree
dnf shows a normal transaction withReinstalling: tree x86_64 2.1.0-8.el10 baseosand ends withComplete!. Add-yto skip the question. - Check that the files match the package again with
rpm -V tree. Before the reinstall our test showedmissing /usr/bin/tree; afterwardsrpm -Vprinted nothing, which means everything matches. - Know what happens to configuration files. In our test, a changed
/etc/nanorc(rpm -V nanoshowedS.5....T. c /etc/nanorc) kept the change afterdnf reinstall nano, and no.rpmnewfile was created. A deleted/etc/nanorcwas restored. So, to get a package's default configuration back, move the file away first, then reinstall.
If the reinstall fails, the message tells you why:
Package wget available, but not installed.: install it withdnf installinstead.No match for argument: NAME: check the package name withrpm -qa | grep NAME.Installed package tree-2.1.0-8.el10.x86_64 (from baseos) not available.: dnf can only reinstall the exact installed version from an enabled repository. Enable that repository, update the package instead withdnf update NAME, or reinstall from the matching RPM file as below. For installing a specific version, see install, downgrade or lock a package version.
Force a reinstall from an RPM file
dnf reinstall ./tree-2.1.0-8.el10.x86_64.rpm # resolves dependencies, recommended rpm -ivh --replacepkgs tree-2.1.0-8.el10.x86_64.rpm rpm -Uvh --force tree-2.1.0-8.el10.x86_64.rpm
A plain rpm -ivh stops with package tree-2.1.0-8.el10.x86_64 is already installed. --replacepkgs only allows a package that is already installed. According to the rpm manual, --force is the same as --replacepkgs, --replacefiles and --oldpackage together, so it also lets the package overwrite files of other packages and replace a newer version with an older one: use it only when you know why. More rpm options are in how to use the rpm command.
On Fedora, Ubuntu and Debian
- Fedora uses dnf5:
yumanddnfboth point to dnf5 (5.4.6 on Fedora 44).dnf clean allanddnf reinstall PACKAGEwork the same way, the cache is in/var/cache/libdnf5, andclean headersfails there too (Unknown cache type "headers"). - Ubuntu and Debian: apt keeps downloaded packages in
/var/cache/apt/archives.apt cleandeletes them all;apt autocleandeletes only those that can no longer be downloaded. To force a reinstall, runapt install --reinstall PACKAGE. On Debian 13 (apt 3.0.3) it reported0 upgraded, 0 newly installed, 1 reinstalledand restored a deleted file, checked withdpkg --verify PACKAGE.
Official documentation: DNF command reference (clean, makecache and reinstall) and DNF configuration reference (keepcache).