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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. Wallch (Wallpaper Changer) – Rotate Ubuntu Desktop Wallpapers
  2. How to Change the Network Bonding Mode in CentOS/RHEL 6
  3. CentOS / RHEL : How to Disable and Blacklist Linux Kernel Module to prevent it from loading automatically
  4. CentOS / RHEL 7 : How to boot into rescue mode from installation DVD/ISO
  5. CentOS / RHEL 7 : Never run the iptables service and FirewallD service at the same time!
  6. Understanding System Security Services Daemon (SSSD)
  7. Troubleshooting “connection refused” From Remote Servers in CentOS/RHEL 7 (Either Firewalld or iptables service issue)
  8. CentOS / RHEL : How to prioritize the devices used for swap partition
  9. The locate Command in Linux
  10. iotop Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright