Notice the first and last lines of /var/lib/dpkg/triggers/File
are duplicates (both contain the same about hicolor
). Try removing one of the lines (leaving the other!):
sudo gedit /var/lib/dpkg/triggers/File
then save it. Then try installing/removing software again.
You might also want to run sudo apt-get clean
, since apt-get
might have cached the packages that failed to install.
Using root and recursive rm (rm -r
) is a recipe for disasters, don't do it. The files and directories that were deleted are as follows:
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, the status file, etc. So, lets try to fix the stuff. First, create the directory:
sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates}
Recover some backups:
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
Check if dpkg is working:
apt-get download dpkg
sudo dpkg -i dpkg*.deb
If everything is "ok" then repair your base files too:
apt-get download base-files
sudo dpkg -i base-files*.deb
Now try to update your package list, etc.:
dpkg --audit
sudo apt-get update
sudo apt-get check
Compare ls -l /var/lib/dpkg
with the above list. If some -old
file is not present don't worry it as it would be created with the normal usage of the system.
Best Answer
Download the dpkg package for your release from https://launchpad.net/ubuntu/+source/dpkg/.
Extract the file.
cd
to the root of the dpkg source directory.You may need to download some packages if
./configure
fails