Debian / Ubuntu Linux: Clear the Package Cache

by on January 16, 2009 · 8 comments· LAST UPDATED January 16, 2009

in , ,

Q. I've Debian Linux installed on 10 GB hard disk and noticed that /var/cache/apt/archives/ has lots of file taking my precious 1Gb disk space. Can I remove those file safely without causing any side effect on my setup?

A.If you are running out of disk space, you can try deleting the cache of package files. By default, the apt willkeep all the packages it has downloaded in case they’re needed in the future.

apt-get clean command clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. When APT is used as a dselect method, clean is run automatically. Those who do not use dselect will likely want to run apt-get clean from time to time to free up disk space.

To clear the cache from the command line, type the following:
$ sudo apt-get clean
# apt-get clean

There is also autoclean option. 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. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 8 comments… read them below or add one }

1 Tchetche January 16, 2009 at 11:20 am

You can also use aptitude :

aptitude clean : delete downloaded packages
aptitude autoclean : delete old files from downloaded packages

Note that I don’t really see the difference…


2 Leaman Crews January 16, 2009 at 3:36 pm

Tchetche, the difference is as Vivek describes in the article. autoclean automatically removes older packages that are unlikely to ever be needed. A plain old clean would just dump all the packages (manually, when you run it).


3 lefty.crupps January 17, 2009 at 3:57 pm

Could you explain this ‘dselect’ method to us? I have a list of commonly installed apps and I pipe that list into new Debian installs, something like this I think:
dpkg -dselect < packages.txt
(I forget the exact syntax, so feel free to correct me). Then all those packages get installed, but (1) i have no idea what it really has done, and (2) how to I un-select those packages if, say, my list was wrong or i’ve changed m mind? I’ve always just been ‘forced’ to go with those options once they’re set even if not installed.


4 Elias K Gardner March 12, 2009 at 10:39 pm

Out of curiosity is there any gui method to do this?

Note: I’m fully capable of using the terminal and will do so immediately to free up space but I know many that are more comfortable if all they have to do is point and click.


5 Maxei April 4, 2009 at 5:19 pm

Use aptitude. It has a GUI in which you can do point and click. Just invoke it with the command line:



6 bracha February 13, 2011 at 7:41 am

my computer doesnt let me download anything except .doc files. everything else, it says low disk space.
so two questions: how do i delete stuff i dont need?
and can i download straight to a memory stick? cuz it never gives me that option…


7 evanp July 29, 2011 at 1:32 am

wow thankyou!! it works!


8 xXx February 7, 2013 at 12:35 pm

Just to make it clearer:
The autoclean parameter cleans only packages that are no longer available in the repositories we have in our sources.list, like packages that have been replaced by newer versions, or have been dropped from the repositories.


Leave a Comment

Tagged as: , , , , , , , , , , ,

Previous Faq:

Next Faq: