Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I was running out of space on an Ubuntu server, so I did this command to save space

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

However now when trying to do things with apt, I get the following errors:

E: Could not open lock file /var/cache/apt/archives/lock - open (2 No such file or directory)

E: Unable to lock the download directory

And things like

Archive directory /var/cache/apt/archives/partial is missing.

Clearly I have removed some directory structure. Is there some way to do a apt-get rebuild-var-tree or similar?

share|improve this question
3  
not a 'proper' answer so it'll need to be a comment but next time you could try apt-get autoclean (or possibly apt-get clean) – Journeyman Geek Feb 5 '10 at 13:25
up vote 17 down vote accepted

You need two things there:

sudo mkdir -p /var/cache/apt/archives/partial
sudo touch /var/cache/apt/archives/lock
sudo chmod 640 /var/cache/apt/archives/lock

Removing this directory manually is a bad idea generally. To clean archives cleanly, use:

sudo apt-get clean
share|improve this answer
    
thanks it works fine My lenny is coming back – benoit Jan 29 '11 at 4:05
    
Under debian, I think we should not use sudo. simply use: mkdir -p /var/cache/apt/archives/partial touch /var/cache/apt/archives/lock chmod 640 /var/cache/apt/archives/lock – user83606 Jun 5 '11 at 16:49
2  
You should always use sudo. – bahamat Jun 5 '11 at 17:49

protected by Community Jun 5 '11 at 19:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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