Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How to clean Yum cache in Linux System?

YUM is a tool for managing software on your computer, especially in CentOS. It keeps track of what software you've downloaded, installed, or removed. In this guide, we'll learn how to clean up this tracking information.

Introduction to YUM

YUM stands for Yellowdog Updater, Modified. It's a tool you use through the command line on Linux systems like CentOS, RHEL, and Fedora. It uses another tool called RPM in the background to handle software. There are similar tools like apt for Debian systems.

Like apt, YUM deals with software repositories and uses rpm behind the scenes. YUM is made with the Python programming language and is mostly used through the command line, but there are also graphical versions like YUMex.

What is RPM?

Before we continue, let's talk a little about RPM, which is the system that YUM uses. RPM is a way of packaging software, and it has these important characteristics:

1. It's used to distribute apps to people digitally.

2. It checks to make sure the apps are from a trusted source and haven't been tampered with using things like hashes and digital signatures.

3. It doesn't have rules that stop people from copying these packages.

Why is it Important to Learn How to Clean YUM Cache?

When you use YUM to download and install software, those software packages are stored in a particular place called the cache. This cache lives in a folder at /var/cache/yum, and it keeps track of things like what kind of computer you have, what version of Linux you're using, and where the software came from.

Usually, YUM should clean up this cache automatically after you install software, but sometimes it doesn't. Over time, this cache can get really big and use up a lot of your computer's resources, which can make it slow down.

You might even see an error message that says something like "not enough space in download directory /var/cache/YUM/rhel-x86_64-server-6/packages." This means that your computer's storage is full because of all the stuff in the cache, and there's no room to download updates.

So, it's important to learn how to clean up the YUM cache to free up space and keep your system running smoothly.

Disabling caching for YUM

You have the option to stop YUM from storing things in its cache. By default, YUM saves downloaded packages, headers, and some information in a special place. You can change this by tweaking a setting in a file called /etc/yum.conf. This setting is called "keepcache." To turn off caching, set its value to 0, like this:

keepcache=0

How to Clear YUM Cache on CentOS

Now, let's talk about how to clean up YUM's storage. To do this, you'll need a server running CentOS, and you should have an account with root privileges. Here are the steps:

Recover Space Taken by Broken Files

To get rid of the YUM cache and free up space from broken files, follow these steps:

Step 1: Open the Terminal by going to the System menu and choosing Terminal.

Step 2: Type the following command and press Enter:

# yum clean packages

It might take a little while to clear the cache. You might see messages like:

Remove the old package information completely

If you want to completely remove old package info, follow these steps in the Terminal:

# yum clean headers

Delete the metadata from the enabled repository

To erase the metadata from the source you're using, do this in the Terminal:

# yum clean metadata

Remove the package headers

To remove the package headers, use this command in the terminal:

# yum clean headers

Clear Everything in the Cache

To clean out everything from the cache, use this command:

# yum clean all

This command will delete all the files stored in the YUM cache.

Changing the default location of the YUM cache

To wrap things up, let's talk quickly about how you can change where YUM keeps its cache. The spot where YUM stores its cache is set in a file called /etc/yum.conf.

In there, you'll find a part labeled [main], and inside that, you'll see a line that says "cachedir." You can open this file with your preferred text editor and adjust that line like this:

[main]

cachedir=/var/cache/YUM/$basearch/$releasever

Conclusion:

Over time, YUM can gather a bunch of stuff like RPM headers and other information. This stuff can take up quite a bit of space on your computer. It's all stored in a place called /var/cache/yum. You can control this cache using the YUM command with different settings.

If you choose to delete these YUM cache files, YUM will need to download them again the next time you update your system. This might take a little while, but it's not a big deal if your internet connection is speedy.


Was this answer helpful?

« Back

chat