Learn how to Clear the DNF and APT Caches in Linux


Each DNF and APT — the package deal managers for Purple Hat and Ubuntu-based Linux distributions — retailer cached info to make sure the software program set up course of is way sooner and extra dependable. With these caches in place, neither package deal supervisor has to obtain the data everytime you try to replace, improve, or set up software program.

However typically, that cache info can turn out to be outdated or corrupted. When that occurs, you would possibly discover that the DNF of APT doesn’t operate correctly.

What do you do? You clear the cache, which is able to delete all of that info, so you may have a clear slate.

How do you clear these caches? Let me present you.

SEE: Debian vs Ubuntu: Which Linux Distro Matches Your Wants Finest? (TechRepublic)

Learn how to clear the cache for the DNF package deal supervisor

The easiest way to wash the DNF cache is by working the command:

sudo dnf clear dbcache

It will take away all cache recordsdata generated from the repository metadata.

If that doesn’t resolve your issues, you may run an entire clear with the command:

sudo dnf clear all

SEE: High Instructions Linux Admins Must Know (TechRepublic Premium)

Learn how to clear the cache for the APT package deal supervisor

With the APT package deal supervisor, you may situation the command:

sudo apt-get clear

It will take away the content material from /var/cache/apt/archives (apart from the lock file).

One other APT choice is to run:

sudo apt-get autoclean

This solely removes the packages that can not be downloaded from repositories. In different phrases, should you downloaded a .deb package deal and put in it (versus putting in it from a distant repository), any file related to that package deal will stay.

And that’s all there may be to cleansing the package deal supervisor caches for each Purple Hat and Ubuntu-based distributions. You in all probability gained’t have to make use of these instruments, however should you do, you know the way.

This text was initially printed in June 2021. It was up to date by Antony Peyton in January 2025.



Supply hyperlink

Leave a Reply

Your email address will not be published. Required fields are marked *