Bootstrap FreeKB - YUM - Remove /var/cache/yum files using the yum clean command
YUM - Remove /var/cache/yum files using the yum clean command

Updated:   |  YUM articles

By default, YUM caches files in the /var/cache/yum directory. You do not want to manually delete files or directories below /var/cache/yum. Instead, the yum clean command can be used to remove files below /var/cache/yum.

Before using yum clean, you may want to use the du (disk usage) command to list the size of the /var/cache/yum directory.

~]$ du -hs /var/cache/yum
426M    /var/cache/yum

 

And then use the yum clean or yum clean all command to remove files from the /var/cache/yum directory.

yum clean all

 

And then reissue the du (disk usage) command to get the updated size of the /var/cache/yum directory.

~]$ du -hs /var/cache/yum
56M    /var/cache/yum

 

If the size of the /var/cache/yum directory was not reduced to 0, this typically means you have untracked or disabled repositories, which can be seen with the yum clean all --verbose command.

~]# yum clean all --verbose
73 M   disabled repos:
  73 M   /var/cache/yum/x86_64/7Server/rhel-server-rhscl-7-rpms
1.4 M  untracked repos:
  412 k  /var/cache/yum/x86_64/7Server/rhel-7-server-satellite-tools-6.9-rpms
  404 k  /var/cache/yum/x86_64/7Server/rhel-7-server-satellite-tools-6.5-rpms
  396 k  /var/cache/yum/x86_64/7Server/rhel-7-server-satellite-tools-6.8-rpms
  44 k   /var/cache/yum/x86_64/7Server/pe_repo
  12 k   /var/cache/yum/x86_64/7Server/rhel-7-server-supplementary-rpms
4.0 k  other data:
  4.0 k  /var/cache/yum/x86_64/7Server/timedhosts
74 M   total

 

The yum clean all command will not remove files from the /var/cache/yum directory that are mapped to untracked or disabled repositories, thus you may need to use the rm command to remove additional files from the /var/cache/yum directory.

rm -rf /var/cache/yum/*



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 00fe94 in the box below so that we can be sure you are a human.