Like another user, I have accidentally deleted /var/lib/dpkg
and have poor backups. I need to reinstall dpkg
from beginning. The solution provided to that answer is not working for me.
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
$ ls -l /var/lib/dpkg
total 16
drwxr-xr-x 2 root root 4096 Mar 25 21:26 alternatives
drwxr-xr-x 2 root root 4096 Mar 25 21:26 info
-rw-r----- 1 root root 0 Mar 25 21:46 lock
-rw-r----- 1 root root 0 Mar 25 21:46 lock-frontend
drwxr-xr-x 2 root root 4096 Mar 25 21:26 parts
drwxr-xr-x 2 root root 4096 Mar 25 21:26 status
What I've tried
References to what I've tried:
From (1), I was able to recover sudo cp /var/backups/dpkg.status.0
into /var/lib/dpkg/status
. But attempting apt-get download dpkg
fails. So, trying the solution from link (2) above, I get partway:
mkdir /tmp/dpkg
cd /tmp/dpkg
wget http://security.ubuntu.com/ubuntu/pool/main/d/dpkg/dpkg_1.17.5ubuntu5.2_i386.deb
ar x dpkg*.deb data.tar.gz
tar xvzf data.tar.gz ./usr/bin/dpkg
cp ./usr/bin/dpkg /usr/bin/
sudo apt-get update
apt-get update
gets my package lists, but then returns an error. Attempting apt-get clean
first, as suggested in Solution 3, returns the same error. I get the same error with anything related to apt-get
(except apt-get clean
):
Reading package lists... Error!
E: Read error - read (21: Is a directory)
E: The package lists or status file could not be parsed or opened.
Note that I am missing / have deleted file /var/lib/dpkg/status-old
.
Continuing to run down the rabbit hole of help resources, I found Solution 4. But when I tried sudo dpkg -a configure
, it produces:
dpkg: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory `
This is the same error I get from solution (1) when running sudo dpkg -i dpkg*.deb
Solution 4 further suggests using the program synaptic. But I cannot install since package manager is broken :(.
Any help would be greatly appreciated!!
dpkg
within 16.04 directly – alexwhitworth Apr 08 '19 at 21:41