How to Remove DNF Cache on Linux

Delete DNF cache on Linux and reclaim storage space safely using Kudu’s cleanup tools.

By Kudu Team

Fix this automatically with Kudu

Run a free system scan to detect and resolve this issue automatically — no manual steps required.

Download Kudu Free →

What Causes This?

DNF stores downloaded package files, metadata, and temporary transaction data in its cache so it can install and update software faster. Over time, that cache can grow large, especially on systems that are updated often or have installed many packages. Old metadata, partially downloaded packages, and leftover files from interrupted updates can all waste disk space.

Common Symptoms

  • Linux is using more disk space than expected
  • /var or the root partition is getting full
  • DNF updates seem to keep large amounts of old data
  • You want to reclaim storage without removing installed packages
  • Package operations leave behind temporary files

How to Fix It Manually

  1. Open a terminal.

    • On most Linux desktops, press Ctrl+Alt+T.
    • You can also open your app menu and search for Terminal.
  2. Check how much space the DNF cache is using.

    • Run:
      sudo du -sh /var/cache/dnf
    • This shows the total size of the DNF cache folder.
  3. Clean only expired or unnecessary metadata first.

    • Run:
      sudo dnf clean expire-cache
      sudo dnf clean metadata
    • This removes old repository metadata without touching installed software.
  4. Remove cached package files.

    • Run:
      sudo dnf clean packages
    • This deletes downloaded RPM files that DNF kept after installs and updates.
  5. Clear everything in the DNF cache if you want the most space back.

    • Run:
      sudo dnf clean all
    • This removes packages, metadata, and other cached data.
    • It does not uninstall programs, but DNF may need to re-download metadata the next time you use it.
  6. Verify the cache was reduced.

    • Run:
      sudo du -sh /var/cache/dnf
    • Compare the new size with the earlier result.
  7. If files still remain, manually inspect the cache directory.

    • Run:
      ls -lah /var/cache/dnf
    • If needed, you can remove leftover contents manually:
      sudo rm -rf /var/cache/dnf/*
    • Use this command carefully. Make sure you type the path exactly as shown.
  8. Refresh DNF afterward if needed.

    • Run:
      sudo dnf makecache
    • This rebuilds repository metadata so future installs and updates work normally.

Fix It Automatically with Kudu

If you do not want to hunt through cache folders and run cleanup commands manually, Kudu can help automate the process. Kudu scans for unnecessary temporary files, old package caches, and other storage waste so you can safely free up space faster. It is the easier option if you want routine cleanup without digging through system directories yourself.

Download Kudu Free →

Fix this automatically with Kudu

Run a free system scan to detect and resolve this issue automatically — no manual steps required.

Download Kudu Free →