Can we clean yum cache files manually?

6,681

Solution 1

After successful installation, packages should be deleted from the yum cache. You should check in the file /etc/yum.conf, whether the keepcache setting is 1 instead of 0.

The RedHat post Maybe you want: rm -rf /var/cache/yum says that the command yum clean all gives the impression that enabled and disabled/removed repos are cleaned but in reality, performs only these tasks:

  • clean all cache from enabled repos
  • remove all data from unknown repos
  • preserve cache of disabled/removed repos

The fix in RHBA-2017:2295 should have added a reminder for this command saying:

Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

In any case, whatever your situation, you can issue the recommended command:

rm -rf /var/cache/yum

Solution 2

Manual deletion is quite safe and will not cause problems with yum. This is fine:

rm -rf /var/cache/yum

You can also check this post on other steps that may help in clearing disk space.

Share:
6,681

Related videos on Youtube

max
Author by

max

working as a linux system admin.

Updated on September 18, 2022

Comments

  • max
    max almost 2 years

    I am using Redhat 7 while running yum update I am getting Bus error (core dumped) error.

    After troubleshooting I found that / was full because of /var/cache/yum/x86_64/7server/rhel-x86_64-server-7/gen folder.

    Inside this folder below files contains GB of data.

    enter image description here

    I tried yum clean all command to clean up the space but it is not working.

    Can I manually delete these files?

    Manual delete will cause any problem to yum ?

  • YoYo
    YoYo over 3 years
    In no case it is safe to start typing anything rm -rf. Depending on when the cat jumps on my desk scaring the hell out of me, my trembling pinky hits the enter at either / or /var
  • Steve Summit
    Steve Summit over 2 years
    @YoYo That's a valid concern. I address it by typing xxrm -rf /var/cache/…, then staring at the command for a while to make absolutely positively sure it's correct, then taking a deep breath, deleting the leading xx, then hitting Return.
  • Steve Summit
    Steve Summit over 2 years
    A colleague and I just discovered that significant space was being tied down (3% of our disk, which meant almost 2 gig) by some database files and other metadata, even though keepcache was set to 0. rm -rf fixed it.
  • YoYo
    YoYo over 2 years
    @SteveSummit lol - but I probably start doing it that way. Plus why not splitting the space bar and having an enter button under one of our stronger thumbs.