IntroductionYUM (Yellowdog Updater, Modified) is a package manager for RPM-based distributions. While YUM is a powerful tool for managing packages and dependencies, the utility sometimes caches a lot of data, taking up disk space.This tutorial explains how to clean YUM cache and keep the system running smoothly.
- A Linux system with YUM installed (this tutorial uses CentOS 7).
- Access to the terminal.
- Sudo permissions.
How to Clear YUM Cache?When a user installs a package, YUM downloads and stores it in /var/cache/yum. However, packages remain in cache even after they've been installed and removed. In time, the stored cache may take up too much disk space or cause issues due to corrupt metadata.To reclaim disk space, use the following methods to clear the YUM cache.
1. Clean Cached YUM PackagesRun the following command to purge all cached packages from the enabled repositories cache directory:
The command lists the repos it goes through and deletes cached packages..
sudo yum clean packages
2. Clean Package HeadersWhen YUM updates the local cache, it downloads the package headers and stores them as xml metadata in /var/cache/yum.To delete cached package headers, run:
sudo yum clean headers
3. Delete Metadata for Each Enabled RepositoryYUM uses metadata, such as the package name, version, and dependencies, to manage and update packages.Clean cached metadata from each enabled repository with:
sudo yum clean metadata
4. Clean All Cached FilesRemove all cached files from all enabled repositories at once with:
sudo yum clean all
The "Metadata File Does not Match Checksum" ErrorDeleting YUM cache can help resolve issues with corrupt metadata. However, if you receive the "Metadata file does not match checksum" error, cleaning the YUM cache might not help resolve it. As an alternative solution, disable YUM package caching.1. Open the /etc/yum.conf file using a text editor.
2. Find and edit
http_caching=none.3. Save and exit the file.Complete the YUM operation that invoked the error and revert the settings in the YUM configuration file once complete.