1

Whenever I try to run any apt-get command, it gives me this error message:

dpkg: error: corrupt info database format file '/var/lib/dpkg/info/format'

E: Sub-process /usr/bin/dpkg returned an error code (2)

Please advice how to rectify this.

3

1 Answer 1

1

Delete that "format" file, or if you're paranoid, back it up (move it to the RAM disk):

sudo mv /var/lib/dpkg/info/format /dev/shm

Mine only contains the number 1 and a carriage return (\n), resulting in a two byte file. You can create this from the command line:

sudo printf "1\n" > /var/lib/dpkg/info/format

If it fails, then simply restore your backed up "format" file over the top of the new one you created.

sudo mv /dev/shm/format /var/lib/dpkg/info/
4
  • Are there any risks with doing this? Could you edit to include them, and a rm command so that we are less likely to delete the wrong file?
    – Tim
    Aug 6, 2014 at 15:13
  • If you're paranoid, then do this: sudo mv /var/lib/dpkg/info/format /dev/shm which will move the "format" file into the RAM disk, then create a new file using your favourite text editor (type in 1 then enter, then save your file). If it fails, then simply mv /dev/shm/format /var/lib/dpkg/info/ which will restore your backed up "format" file over the top of the new one you created. Aug 6, 2014 at 15:25
  • Nope, I am not able to edit this file. >mewtomat@MewtoMat:~$ sudo mv /var/lib/dpkg/info/format /dev/shm >[sudo] password for mewtomat: >mewtomat@MewtoMat:~$ sudo printf "1\n" > /var/lib/dpkg/info/format >bash: /var/lib/dpkg/info/format: Permission denied >mewtomat@MewtoMat:~$ sudo mv /dev/shm/format /var/lib/dpkg/info/ >mewtomat@MewtoMat:~$
    – user312936
    Aug 7, 2014 at 7:52
  • Do "sudo nano /var/lib/dpkg/info/format" and then when the editor appears, type in "1" then Enter, then press CTRL+X, then "Y" and then Enter to save your changes. Aug 8, 2014 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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