Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I accidentally removes all files in /var/cache/ directory with sudo rm -rf command. Now I cannot see the files in Trash to bring them back.

I would like to know how bad is the situation if these files are removed? Is Ubuntu going to work normally and recreate the directories in cache again automatically?

If not, which directories do I have to create in /var/cache/ manually to let everything work fine?

I have already manually made apt and apache2 and debconf in cache directoy but I do not know if I miss more important directory which needed to be created there.

I hope somebody can guide me to fix this issue.

share|improve this question
add comment

2 Answers

Cache directories fortunately should be expendable. Reinstalling the related packages should bring them back. The problem is /var/cache/apt as you need it for installing.

So let's recreate it manually:

sudo mkdir -p /var/cache/apt/archives

Now you can reinstall packages. On a default installation, these packages own directories in var cache, and this is how you reinstall them:

sudo apt-get install --reinstall cracklib-runtime cups debconf \
    dictionaries-common lightdm man-db nscd pm-utils pppconfig \
    samba-common software-center

The only thing I'm not sure about is whether debconf will run without the files in /var/cache/debconf. But try it!

share|improve this answer
    
Thank you for your fix. Only error which I got was no lightdm was found. I think thatś because Im using the older version of ubuntu which does not support lightdm. beheer01@WEB:/var/cache$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 10.04.4 LTS Release: 10.04 Codename: lucid Sould I use sudo apt-get install --reinstall dm in place of lightdm for lucid? –  user110474 Nov 25 '12 at 12:36
    
In lucid, it's gdm instead of lightdm –  Dennis Kaarsemaker Nov 25 '12 at 13:20
    
Dank je wel Dennis. Nu ziet er allemaal goed uit. Thanks –  user110474 Nov 26 '12 at 15:42
    
Yes, don't delete /var/cache/apt/archives dir, but you can delete files: /var/cache/apt/pkgcache.bin and /var/cache/apt/srcpkgcache.bin, but them will be recreated by "apt-get update". –  diyism Jun 24 '13 at 11:57
add comment

rm -rf deletes all files in the given directory immediately without asking and recursively (all sub directories and files). There are not stored in the trash, they are gone.

It depends on the installed packages, which folders and files you need in this directory. For example: apache, apt, cups, debconf, flashplugin-installer, git, samba, lightdm, pm-utls, man, software-center ...

Maybe you can take a look on the Ubuntu live cd, which files and folders are the standard files in this directory.

EDIT: Maybe you can try these tools (on your own risk):

extundelete

testdisk

share|improve this answer
    
Thank you for your answer. I will try Ubuntu live cd to find out which files and directories are missing. –  user110474 Nov 25 '12 at 12:54
add comment

Your Answer

 
discard

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.