Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

Learn how to save disk space by clearing APT cache

Hello, friends. In this short post, you will learn a fabulous trick that allows you to save disk space, and that is to clean the APT cache. This way, you can quickly remove unnecessary files that are just taking up disk space.

What is the APT cache?

The APT package manager keeps a list of packages so that you don’t have to download it every time. However, as we use and install more and more applications than the cache increases in size.

The problem with this is that sometimes it can weigh Gigabytes, and they are packages that the system does not really need anymore since they have already been installed.

So, in many occasions, it is convenient to clean this file to save disk space.

Two commands that can help us

To do this procedure, two commands are usually required that, although similar, work somewhat differently.

First, there is the apt autoclean command which according to the APT help:

Erase old downloaded archive files

And there is apt clean which:

Erase downloaded archive files

So as you can see, the process is simple.

How to save disk space by clearing APT cache

Therefore, the procedure is simple to do. First, refresh the entire APT cache

sudo apt update

Next, it’s a good idea to update the whole system to make the cleanup more reliable

sudo apt upgrade

Now you can run

sudo apt autoclean

Thanks to this command, the cache will be cleared of unneeded packages that are not a difficulty. This is what it says in man.

Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless.

But if you want a total cleanup, then run clean

sudo apt clean

As you can see, these commands require root permissions to work.

Save disk space by clearing APT cache
Save disk space by clearing APT cache

Just like that, you can save disk space by clearing the APT cache.

Conclusion

APT is a package manager that is the heart of Debian and Ubuntu, but knowing how to manage it also means knowing how to clear its cache and improve the system.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook

x