Home Debian How to Clear Apt Cache in Debian, Ubuntu and Linux Mint

How to Clear Apt Cache in Debian, Ubuntu and Linux Mint

apt (Advanced Packaging Tool) is the package installation and dependency management tool in Debian and other Debian-based distributions. It works on top of ‘Dpkg‘ which is nothing but the Debian package installer.

The way apt installs packages is: it downloads the package for the required software, and additionally it downloads the packages for all the dependencies for the required software.

Once the packages are extracted and installation is complete, they are moved to a Cache directory which is located at ‘/var/cache/apt/archives’. Some packages for libraries, etc. are also located in other directories.

The reason why these packages are kept in the cache is that: next time another software has an existing package in the cache (with the required version), Apt will not download the package but instead use it from the Cache itself.

However as the system gets older, a lot of packages get cluttered in the Cache. Hence, it is a good practice to clear Apt Cache from time to time to free up the occupied space.

Today, we will see how to clear the Apt Cache in Debian and other Debian-based distributions.

Apt Clean Command

To delete the apt cache, we can call apt with the ‘clean‘ parameter to remove all the files in the cache directory. The user need not manually delete those files.

You can run ‘apt clean‘ with a parameter called ‘--dry-run‘, i.e. the dry run parameter, which will simply show you the directories from which packages will be deleted, and will not actually delete the packages.

$ sudo apt clean --dry-run
Clear Apt Cache in Ubuntu
Clear Apt Cache in Ubuntu

To delete all these directories you can run apt clean (without dry run).

$ sudo apt clean

Apt Autoclean Command

Similar to apt clean, there is another command called ‘apt autoclean’. This command will remove the packages from Cache, for which a newer version is available in the repository.

apt will check the repository for a newer version of every package in the Cache.

$ sudo apt autoclean
Auto Clean Apt Cache in Ubuntu
Auto Clean Apt Cache in Ubuntu

The other packages in the cache, which don’t yet have a newer version in the repository, will remain in the cache and not be deleted with autoclean.


In this article, we learned how to clear the apt cache in Debian and Debian-based distributions. It is a good practice to clear the Cache from time to time. Users can also schedule a cron job (which automatically runs a command at specific intervals of time) to clear the Cache.

If you have any questions, let us know in the comments below!

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.