Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I accidentlly deleted /var folder form my ubuntu istalltion. Can it be restored somehow, without loosing the installation? Please suggest what options I do have?

share|improve this question
Isn't that exactly what backups are for? –  David Schwartz Nov 9 '11 at 9:33
add comment

1 Answer

/var contains some important folders which hold the state for programs (in /var/lib). Your program state (dpkg) has gone too, so you will end up with a reinstallation of programs anyway.

Since /var/log has gone too, you cannot analyse /var/log/apt/history.log either so you have to rely on your memory to know which programs you've installed. After restoring the dpkg and packages database (probably by sudo install -D -m755 /var/lib/dpkg && sudo apt-get update), you can use dpkg -S /path/to/file to get the package for a given path.

That said, a reinstallation would be the easiest way. Make a backup of /home (and possibly /etc if you changed system-wide settings or users/groups) and do a reinstall. If your /home was on a separate partition, it's even easier: mark that partition as /home in the installer, but do not tick "format".

share|improve this answer
I don't understand: if he lost /var, how can he look at /var/log/apt/history.log? –  Lohoris Nov 9 '11 at 9:20
@Lohoris: well, that's technically possible since /var/log could be a separate mount point. Updated answer with for a more likely situation. –  Lekensteyn Nov 9 '11 at 9:37
add comment

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.