Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to restore the functionality of /var/lib/apt/lists and /var/apt/cache after deleting them or minmizing them in some wa

I am trying to shrink down an Ubuntu VM to the smallest size and decided to delete /var/lib/apt/lists and /var/cache/apt with the intention of restoring them when the system needs to be updated. I have done /var/cache/apt without major side effects, simply recreating some directories reenables it. The /var/lib/apt/lists is the one I am unsure of. Is it possible delete it and restore its functionality by recreating like /var/cache/apt?

Does doing that destroy the knowledge apt and dpkg have of the systems configuration or is that stored elsewhere?

share|improve this question
up vote 13 down vote accepted

Yes, you can delete them!

Let's clone a VM and see what happens! :)

$ rm -r /var/cache/apt /var/lib/apt/lists
$ apt-get update #takes a while re-fetching everything
$ apt-get install <some-random-package>

Directories are recreated from the apt-get update operation and all is well. I might leave the *.gpg files alone if you're feeling paranoid, but otherwise those files are all ok to disappear.

In the past, I've had issues where I've had to manually mkdir /var/cache/apt/archives, but that no longer seems to be an issue.

share|improve this answer
To delete the cache, you don't need to delete the directories, just the files: rm -r /var/cache/apt/* /var/lib/apt/lists/* – alfredocambera May 8 '15 at 14:20
Why is the "lists" stuff not in /var/cache if it's really a cache ? I would be reluctant to delete something that's not clearly a cache. – Johan Boule Apr 25 at 21:15

On Ubuntu 10.04 LTS the directories are not recreated. So you have to be careful not to delete these. You can use the following command to delete only the files.

sudo find /var/cache/apt/ -type f -exec rm -v {} \;
sudo find /var/lib/apt/lists -type f -exec rm -v {} \;

To recreate the cache use

sudo apt-get update

A better answer is probably Debian/Ubuntu - How to restore /var/cache/apt structure after deleting it?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.