Somehow, my apt
system got hosed on my Ubuntu 20.04.4 system, and now there are more than 1,800 packages that are marked as needing to be uninstalled.
This is from the Xubuntu
installation, which means I'm running the xfce
desktop.
I know that the recommended way to fix this kind of apt
problem is to do an apt autoremove
followed by reinstalls of the packages. However, if I do that, my system will then be totally unusable after the apt autoremove
, due to the fact that most of my system's packages will have been uninstalled.
I'm looking for an alternative way to fix my apt
database so that I don't have to destroy my system with the apt autoremove
command in order to correct apt
.
In order to illustrate the state of apt
on my system, here are some of the things I have run ...
% sudo apt-get install -f
[returns a list of the names of the 1,800 packages]
% sudo dpkg configure -a
[no output]
% sudo aptitude search ?broken
[no output]
% sudo cat /var/log/apt/history.log
Start-Date: 2022-05-04 18:01:54
Requested-By: [MYUSERID] (1000)
Upgrade: networkd-dispatcher:amd64 (2.1-2~ubuntu20.04.2, 2.1-2~ubuntu20.04.3), libvirt-daemon-system-systemd:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), openssl:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), librbd1:amd64 (15.2.14-0ubuntu0.20.04.2, 15.2.16-0ubuntu0.20.04.1), google-chrome-stable:amd64 (101.0.4951.41-1, 101.0.4951.54-1), libvirt-clients:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), iio-sensor-proxy:amd64 (2.8-1ubuntu1, 2.8-1ubuntu2), libvirt-daemon-driver-storage-rbd:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libpq5:amd64 (12.9-0ubuntu0.20.04.1, 12.10-0ubuntu0.20.04.1), ubuntu-drivers-common:amd64 (1:0.9.0~0.20.04.6, 1:0.9.0~0.20.04.7), libvirt-daemon-driver-qemu:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libvirt-daemon-system:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libssl-dev:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libssl-doc:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libmysqlclient21:amd64 (8.0.28-0ubuntu0.20.04.3, 8.0.29-0ubuntu0.20.04.2), libmysqlclient21:i386 (8.0.28-0ubuntu0.20.04.3, 8.0.29-0ubuntu0.20.04.2), libvirt0:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), lm-sensors:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libsensors-config:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libssl1.1:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libssl1.1:i386 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libsensors5:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libsensors5:i386 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), librados2:amd64 (15.2.14-0ubuntu0.20.04.2, 15.2.16-0ubuntu0.20.04.1), libvirt-daemon:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16)
End-Date: 2022-05-04 18:02:47
% sudo ls -l /etc/apt/sources.list
4 -rw-r--r-- 1 root root 3280 Jan 19 17:24 /etc/apt/sources.list
[note that the file hasn't changed in a few months]
% sudo ls -l /etc/apt/sources.list.d
total 16
4 -rw-r--r-- 1 root root 190 Jan 19 17:24 google-chrome.list
4 -rw-r--r-- 1 root root 190 Jan 19 17:24 google-chrome.list.save
4 -rw-r--r-- 1 root root 56 Apr 14 11:06 skype-stable.list
4 -rw-r--r-- 1 root root 56 Jan 19 17:24 skype-stable.list.save
[note that none of this has changed recently]
% sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:3 http://dl.winehq.org/wine-builds/ubuntu focal InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:6 http://archive.canonical.com/ubuntu focal InRelease
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [391 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B]
Get:11 http://us.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [9,568 B]
Get:12 http://us.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.8 kB]
Hit:13 https://repo.skype.com/deb stable InRelease
Get:14 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.6 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.3 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 1,155 kB in 2s (555 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
% sudo grep -r "^deb" /etc/apt/ --include=*.list
/etc/apt/sources.list.d/google-chrome.list:deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
/etc/apt/sources.list.d/skype-stable.list:deb [arch=amd64] https://repo.skype.com/deb stable main
/etc/apt/sources.list.d.save/alex-p-ubuntu-aegisub-focal.list:deb http://ppa.launchpad.net/alex-p/aegisub/ubuntu focal main
/etc/apt/sources.list.d.save/teamviewer.list:deb https://linux.teamviewer.com/deb stable main
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:deb http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:deb-src http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:deb http://dl.winehq.org/wine-builds/ubuntu/ focal main
I had a similar problem in the past which I fixed as described in the "Answers" section of the following post: apt forgot about more than 1,000 packages, and I'm unable to reinstall ... it's the Answer which begins with "I figured out how to fix this problem ..."
However, this seems like a hack-y way to fix this, and I'm not sure how reliable it will be if I run it now.
Can anyone suggest any other way to fix this problem without sudo apt autoremove
and without that hack-y method that I used in the past?
Thank you very much in advance.
PS: I take daily backups of my system. Are there perhaps any files or directories I can restore from my latest backup which would contain the non-broken versions of the apt
database?
PPS: I tried installing xubuntu-desktop
as discussed in the comments below. Sadly, it didn't help ...
% sudo apt install xubuntu-desktop
Reading package lists... Done
Building dependency tree
Reading state information... Done
xubuntu-desktop is already the newest version (2.233).
xubuntu-desktop set to manually installed.
The following packages were automatically installed and are no longer required:
[list of 1,800 package names, followed by ...]
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
And all those packages remain marked as requiring uninstallation.