Ubuntu

How to Clear Apt Cache on Ubuntu 20.04

1. Introduction

Ubuntu users usually use the command apt-get to install software packages on their operating systems. Whenever they run the apt-get command, a .deb file will be saved on their local machine. This helps packages can be accessed locally, so when you need to reinstall them, it’s will speed up the installation process.

The downloaded deb files are located in /var/cache/apt/archives/. When you run the apt-get update and apt-get install command, the apt cache will be updated.

This tutorial will show you the way to clear the apt cache on your Ubuntu machine.

2. Why we need to remove the apt cache?

As time goes by, the cache increases so much and it will take up a lot of memory. When you removing a software package then reinstall it, your operating system will search for the local apt cache, and the same version of the software will be reinstalled.

To list all the deb files, run:

$ ls /var/cache/apt/archives

In order to check how much disk space occupied by the apt cache, let’s run the following command:

$ sudo du -sh /var/cache/apt/archives

It takes 110MB.

3. Clear the apt cache

It’s time to clear the apt cache on your Ubuntu machine. You can simply run the following command:

$ sudo apt-get clean

Now, let’s list all files in /var/cache/apt/archives again:

$ ls /var/cache/apt/archives

As you can see, all of the deb files have already been removed.

4. Conclusion

You’ve already go through the steps of listing and cleaning the apt cache on your Ubuntu system.

If you have any concerns, please let me know. Thank you for reading.

Similar Posts