Ubuntu 18.04.6 LTS를 실행하는 오래된 서버가 있는데 누군가가 잘못된 Ubuntu 20.04 패키지를 설치하거나 업그레이드하려고 시도하여 apt가 손상되고 소위 "Frankensystem"이 발생한 것으로 의심됩니다.
특히 서버가 원격 위치에 있기 때문에 전체 시스템을 다시 설치하지 않고 이 문제를 해결하고 싶습니다. 깨진 패키지를 하나씩 수정하는 것이 가능한가요? 그렇다면 어떻게 해야 하나요?
내가 겪는 오류는 다음과 같습니다.
실행할 때 sudo apt update
:
$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Fetched 222 kB in 2s (118 kB/s)
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
import apt_pkg
ImportError: libapt-pkg.so.6.0: cannot open shared object file: No such file or directory
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
실행할 때 sudo apt --fix-broken install
:
$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
dirmngr : Depends: init-system-helpers (>= 1.52) but 1.51 is installed
gir1.2-gtk-3.0 : Depends: gir1.2-gdkpixbuf-2.0 (>= 2.40.0) but 2.36.11-2 is installed
Depends: gir1.2-pango-1.0 (>= 1.41.0) but 1.40.14-1ubuntu0.1 is installed
Depends: libgtk-3-0 (>= 3.24.7) but 3.22.30-1ubuntu4 is installed
gnupg : Depends: gpgv (>= 2.2.19-3ubuntu2.2) but 2.2.4-1ubuntu1.6 is installed
gnupg-utils : Depends: libreadline8 (>= 6.0) but it is not installed
gpg : Depends: libreadline8 (>= 6.0) but it is not installed
gpg-agent : Depends: init-system-helpers (>= 1.52) but 1.51 is installed
gpgconf : Depends: libreadline8 (>= 6.0) but it is not installed
gpgsm : Depends: libreadline8 (>= 6.0) but it is not installed
hplip : Depends: hplip-data (= 3.20.3+dfsg0-2) but 3.17.10+
내가 확인했을 때 존재하는 것을 /usr/lib/x86_64-linux-gnu
찾았 libapt-pkg.so.5.0
지만 없습니다.libapt-pkg.so.6.0
또한 Python3 버전이 3.6.9이기 때문에 이상한 점을 /usr/lib/python3/dist-packages
발견했습니다 .apt_pkg.cpython-38-x86_64-linux-gnu.so
백업과 관련하여 다음 파일을 찾았습니다.
/var/backups$ ls -l
total 7276
-rw-r--r-- 1 root root 153600 Apr 10 00:08 alternatives.tar.0
-rw-r--r-- 1 root root 9783 Jun 24 2022 alternatives.tar.1.gz
-rw-r--r-- 1 root root 9808 Nov 27 2021 alternatives.tar.2.gz
-rw-r--r-- 1 root root 9421 Mar 27 2021 alternatives.tar.3.gz
-rw-r--r-- 1 root root 6161 Mar 18 2021 alternatives.tar.4.gz
-rw-r--r-- 1 root root 6090 Jan 25 2021 alternatives.tar.5.gz
-rw-r--r-- 1 root root 6061 Nov 28 2020 alternatives.tar.6.gz
-rw-r--r-- 1 root root 154853 Apr 9 23:02 apt.extended_states.0
-rw-r--r-- 1 root root 12962 Apr 9 21:44 apt.extended_states.1.gz
-rw-r--r-- 1 root root 12828 Jul 26 2022 apt.extended_states.2.gz
-rw-r--r-- 1 root root 12821 Jul 4 2022 apt.extended_states.3.gz
-rw-r--r-- 1 root root 12806 Jun 23 2022 apt.extended_states.4.gz
-rw-r--r-- 1 root root 13304 Jun 17 2022 apt.extended_states.5.gz
-rw-r--r-- 1 root root 13269 Nov 26 2021 apt.extended_states.6.gz
-rw-r--r-- 1 root root 4649 Jun 23 2022 dpkg.diversions.0
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.1.gz
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.2.gz
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.3.gz
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.4.gz
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.5.gz
-rw-r--r-- 1 root root 657 Jun 23 2022 dpkg.diversions.6.gz
-rw-r--r-- 1 root root 348 Mar 18 2021 dpkg.statoverride.0
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.1.gz
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.2.gz
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.3.gz
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.4.gz
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.5.gz
-rw-r--r-- 1 root root 213 Mar 18 2021 dpkg.statoverride.6.gz
-rw-r--r-- 1 root root 2529012 Jul 3 16:58 dpkg.status.0
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.1.gz
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.2.gz
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.3.gz
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.4.gz
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.5.gz
-rw-r--r-- 1 root root 708160 Apr 10 00:09 dpkg.status.6.gz
-rw------- 1 root root 1336 Apr 9 22:33 group.bak
-rw------- 1 root shadow 1107 Apr 9 22:33 gshadow.bak
-rw------- 1 root root 3518 Apr 9 22:33 passwd.bak
-rw-r--r-- 1 root smmsp 64178 Mar 18 2021 sendmail.cf.bak
-rw-r--r-- 1 root smmsp 4058 Mar 18 2021 sendmail.mc.bak
-rw------- 1 root shadow 2479 Apr 9 22:33 shadow.bak
-rw-r--r-- 1 root smmsp 44618 Mar 18 2021 submit.cf.bak
-rw-r--r-- 1 root smmsp 2375 Mar 18 2021 submit.mc.bak
아니면 이러한 파일을 사용하여 시스템을 작동 가능한 상태로 복원할 수 있습니까?