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

Removed accidentally /var/lib/dpkg/info/, now I am having problems with installing/removing packages, it prompts errors, cause can not find the info about installed packages.

Is there any way to save the system or need to reinstall debian completely? :/

share|improve this question
up vote 6 down vote accepted

You should be able to regenerate the directory using something like this:

for i in $(dpkg -l|awk '/^ii/ {print $2}')
    apt-get --reinstall -y install $i

What that snippet should do is reinstall every package you already have installed. It will also upgrade everything. If you don't want to do that, you'll have to extend the script to install the specific version you currently have installed, which is not guaranteed to work as those packages may no longer exist in the repository.

More info and a slightly different approach:

EDIT: Important tip from the above linked article:

Some packages will still not install correctly as more stuff is missing from /var/lib/dpkg. In particular the package "ucf" is important to enable the kernel and possibly some others to install correctly.

Without /var/lib/dpkg/info/ucf.templates the kernel install produces this error:

failed to install/upgrade: User postinst hook script [/sbin/update-grub] exited with value 10

Install ucf:

apt-get --reinstall install ucf

That article describes recovering from completely deleting all of /var/lib/dpkg, so this extra step may not apply to your situation.

share|improve this answer
Thanks a lot for your reply! You saved my day! The script was running over 4 hours, but it done like 95% of the job! +++ – Wiggler Jtag Mar 5 '13 at 23:34

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.