How to Clear Apt Cache and Reclaim Precious Disk Space?

Apt Cache is the memory occupied by the hidden files, which can be clear to make some memory free. The reclaiming precious memory phenomenon directs the user to delete the files/apps that are not being used for long. This post will demonstrate how to clear apt-cache and reclaim precious space.

This blog will elaborate on the below-mentioned topics:

Let’s get into the first one:

What is apt Cache in Linux?

When different packages are installed on a Linux machine using the apt package manager and Deb packages, their installation files are stored in the /var/cache/apt/archives directory. Then from this directory, the packages are installed on Linux distributions. After some time, when the packages are removed from the Linux, these files remain in the directory. At the time of reinstallation, instead of downloading the installation files, the packages are installed from already downloaded installation files present in  /var/cache/apt/archives.

How to Clear apt Cache and Reclaim Disk Space in Linux?

In Linux distributions, the apt-cache is frequently monitored to keep the cache refreshed for upcoming programs or any application. The apt cache can be cleaned using the below-mentioned methods, which depend on the user’s needs.

Using “apt clean”

The “apt clean” command cleans up the local repository except the lock files placed in “/var/cache/apt/archives” and the “/var/cache/apt/archives”.

$ sudo apt clean -y

Using “apt autoclean”

The “apt autoclean” command removes the package files that have been useless for a long time. This command keeps the cache from flowing out. This command can be used as follows:

$ sudo apt autoclean -y

The auto clean command will delete all those files from the /var/cache/apt/archives that are no longer in use or are obsolete.

That’s all about this guide!

Conclusion

To clear apt-cache and reclaim precious disk space, use either “sudo apt clean -y” or “sudo apt autoclean -y” in Linux distributions. This write-up has demonstrated the purpose of the “apt-cache” and described how to clean up “apt-cache” and reclaim the precious disk space.