• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to clean YUM cache in CentOS / RHEL

By admin

For some operations (for example, a yum install operation), Yum downloads the packages to install into the Yum cache. The cached packages are located in a subdirectory structure from /var/cache/yum that reflects the architecture, the distribution release, and the repository from where the packages were downloaded.

After successful installation, the packages are deleted from the cache. To retain the cached packages, change the keepcache setting to 1 in the /etc/yum.conf file as follows:

# vi /etc/yum.conf
keepcache = 1

Cleaning the Yum Cache

Clean the Yum cache to reclaim disk space or to clear errors due to corrupted metadata files. To remove cached packages only, use:

# yum clean packages

To delete metadata for each enabled repository, use the following command:

# yum clean metadata

To delete package headers, use the following command:

# yum clean headers

To clean all cached information, use the following command:

# yum clean all

If you get the message “Metadata file does not match checksum” during a Yum operation, clearing the metadata from the cache might not help. In this case, adding the following line to /etc/yum.conf resolves the problem:

# vi /etc/yum.conf
http_caching=none

Changing default location of yum cache

Sometimes when the default yum cache location is full, you would get an error while installing any yum package.

insufficient space in download directory /var/cache/yum/rhel-x86_64-server-6/packages

As the /var filesystem where yum cache is located is full and there is no disk space for yum to download the system updates, the above error will be shown.

The yum cache location is configured in /etc/yum.conf file as cachedir option in the [main] section and can be changed:

$ cat /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to disable write access to USB devices using “hdparm” tool
  2. /proc/cpuinfo file explained
  3. Command ntpstat Shows unsynchronised (CentOS/RHEL)
  4. How to set children-max for udev Service in CentOS/RHEL 7
  5. How to check failed or bad login attempts in Linux
  6. CentOS / RHEL 7 : How to enable telnet for a group of users
  7. CentOS / RHEL 7 : Unable to start/enable iptables
  8. How to audit all Commands run on OEL 5,6 using auditd
  9. CentOS / RHEL 7 : How to modify the kernel command line
  10. Downgrading an rpm package to a lower version (using “rpm” command)

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary