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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to change the default location (/var/cache/yum) of yum cache

by admin

The cachedir specifies the directory where yum stores downloaded packages, although with keepcache set to 0, yum does not store these packages after installing them. Consider a case where the /var filesystem where yum cache is located is full and there is no diskspace for yum to download the system updates. Also, you do not have set the keepcache variable to 0. The “yum install” command would end up with the error like:

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

You always have an option to clean the yum cache using the below post.

How to clean YUM cache in CentOS / RHEL

But, if you do not want to go that way and want to change the default cache location itself, then follow the steps outlined below.

Changing the location of yum cache from the default /var/cache/yum

1. 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

As per the man page for yum.conf:

# man yum.conf
[main] OPTIONS
The [main] section must exist for yum to do anything. It consists of the following options:
    cachedir Directory where yum should store its cache and db files. The default is `/var/cache/yum'.

2. Let’s assume that you want the yum cache location to be a new directory called /yum_cache. Make appropriate changes to the /etc/yum.conf file as shown below for changing the default cache location.

# cat /etc/yum.conf 
[main]
cachedir=/yum_cache/$basearch/$releasever

Although you can change the location of yum cache anytime, it is recommended to check and clean /var volume, or, in case all the files on it are needed, to increase the volume size.

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. OpenLDAP Server and Client Utilities list
  2. CentOS / RHEL : How to Recover from deleted /etc/passwd file
  3. autorandr Command Examples in Linux
  4. fc: Open the most recent command and edit it
  5. How To Configure NIS (Network Information System) Master and Slave Servers in CentOS/RHEL
  6. ifrename: command not found
  7. apt: command not found
  8. ern: Electrode Native platform command line client
  9. dirb: command not found
  10. AdGuardHome – A network-wide software for blocking ads & tracking (Command Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • gixy Command Examples
  • gitsome Command Examples
  • gitmoji Command Examples
  • gitlint Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright