How to disable APT cache in Debian or Ubuntu

Question: I do not want to keep downloaded .deb package files after installing them with apt-get or aptitude. How can I disable APT cache to save disk space on my Linux?

When you install a package with apt-get or aptitude on a Debian-based system, the downloaded package is, by default, kept in the APT cache located at /var/cache/apt/archives. This is really not necessary as you typically do not re-install the same package ever again. Over time, the content in /var/cache/apt/archives will grow.

If you want to turn off the APT cache, so that downloaded packages are not kept there, you can create the following file in /etc/apt/apt.conf.d.

$ sudo vi /etc/apt/apt.conf.d/02nocache
Dir::Cache "";
Dir::Cache::archives "";

At this point, apt-get or aptitude will no longer store downloaded .deb files in the APT cache.

You can go head and empty the current APT cache.

$ sudo rm -rf /var/cache/apt/archives

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

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