How to recover deleted "dpkg" directory? - Ask Ubuntu


unfortunately i've deleted dpkg directory while removing lock. mistake typed

root@sam:~$ rm -r /var/lib/dpkg 

now when trying install/uninstall packages shows me following error.

e: not open lock file /var/lib/dpkg/lock - open (2: no such file or directory) 

what should now?

root + rm + -r = disaster

so did condemn perdition?

ls -l /var/lib/dpkg/ total 9964 drwxr-xr-x 2 root root    4096 nov 28 11:18 alternatives -rw-r--r-- 1 root root      11 sep 18 14:08 arch -rw-r--r-- 1 root root 2573807 nov 28 11:18 available -rw-r--r-- 1 root root 2561322 nov 28 10:25 available-old -rw-r--r-- 1 root root       8 abr 24  2013 cmethopt -rw-r--r-- 1 root root     538 sep 25 17:24 diversions -rw-r--r-- 1 root root     457 sep 25 17:24 diversions-old drwxr-xr-x 2 root root  483328 nov 28 11:17 info -rw-r----- 1 root root       0 nov 28 11:18 lock drwxr-xr-x 2 root root    4096 mar 22  2013 parts -rw-r--r-- 1 root root     135 abr 24  2013 statoverride -rw-r--r-- 1 root root 2269113 nov 28 11:18 status -rw-r--r-- 1 root root 2268870 nov 28 11:18 status-old drwxr-xr-x 2 root root    4096 nov 28 11:18 triggers drwxr-xr-x 2 root root    4096 nov 28 11:18 updates 

you removed 5 directories, status file, etc. so, lets try fix stuff. first, create directory:

sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates} 

recover backups:

sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status 

now, let's see if dpkg working (start praying):

apt-get download dpkg sudo dpkg -i dpkg*.deb 

if "ok" repair base files too:

apt-get download base-files sudo dpkg -i base-files*.deb 

now try update package list, etc.:

dpkg --audit sudo apt-get update sudo apt-get check 

now, let's take deep breath. phew. ls -l /var/lib/dpkg , compare above list. if -old file not present don't worry there tomorrow.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User