Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Clean the YUM Cache in CentOS

This guide shows how to free disk space and fix update errors by cleaning the YUM cache. It needs root access.

Web Hosting2 min read7 steps
Note: You need root access. Root is the admin user with full control of the server. VPS and dedicated server customers have it. CentOS is older software; newer systems such as AlmaLinux use dnf in a very similar way.

What is YUM and its cache?

YUM is a tool that installs and updates software on CentOS. A cache is a store of saved copies kept for later use. YUM saves downloaded packages and lists of software in its cache so it can work faster. Over time the cache can grow large. Sometimes it also becomes old or broken, and then YUM shows odd errors.

When should you clean it?

  • The disk is almost full.
  • YUM says a package is damaged or cannot be found.
  • YUM shows errors about repository data (a repository is an online store of software).

Steps

  1. Log in to your server over SSH as root. SSH lets you type commands on a server from a distance.
  2. See how much space the cache uses:
du -sh /var/cache/yum

This prints the size of the cache folder.

  1. Clean everything:
yum clean all

This removes saved packages, headers and list data. It does not remove software you installed.

  1. If you only want to remove downloaded packages, run:
yum clean packages
  1. To remove only the old software lists, run:
yum clean metadata
  1. Build a fresh cache:
yum makecache

This downloads new lists, so YUM is ready again.

  1. Test with a simple check:
yum check-update

This lists updates that are waiting. If it runs without errors, the cache is fine.

Still getting errors?

Try removing the cache folder contents by hand. Be careful with the path:

rm -rf /var/cache/yum/*
yum makecache

The first line deletes only cached files. Type it exactly, because a wrong path can delete other data. Take a backup first if you are unsure.

Tip: If errors continue, open a support ticket with the full error text.

Quick recap

  • The YUM cache stores downloads and software lists.
  • Run yum clean all to clear it.
  • Run yum makecache to rebuild it.
  • Cleaning does not remove installed software.
  • Be careful with rm -rf.