16.04 无法运行 apt-get 任何内容,总是出现错误

16.04 无法运行 apt-get 任何内容,总是出现错误

我收到此错误:

$ apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-extra-4.4.0-53-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 161 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 227614 files and directories currently installed.)
Removing linux-image-extra-4.4.0-53-generic (4.4.0-53.74) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-53-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
sort: /lib/x86_64-linux-gnu/libpthread.so.0: version `GLIBC_2.275' not found (required by sort)
sort: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.4' not found (required by sort)
sort: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.275' not found (required by sort)
run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-53-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-53-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

当我尝试使用 dpkg 删除有问题的软件包时:

$ sudo dpkg --purge linux-image-extra-4.4.0-53-generic
(Reading database ... 227614 files and directories currently installed.)
Removing linux-image-extra-4.4.0-53-generic (4.4.0-53.74) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-53-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
sort: /lib/x86_64-linux-gnu/libpthread.so.0: version `GLIBC_2.275' not found (required by sort)
sort: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.4' not found (required by sort)
sort: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.275' not found (required by sort)
run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-53-generic (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-53-generic

无法安装 libc(不确定为什么它不在那里)因为我无法运行apt-get


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   xenial

$ apt-cache policy libc6 coreutils linux-image-extra-4.4.0-53-generic
libc6:
  Installed: 2.23-0ubuntu5
  Candidate: 2.23-0ubuntu5
  Version table:
 *** 2.23-0ubuntu5 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.23-0ubuntu3 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
coreutils:
  Installed: 8.25-2ubuntu2
  Candidate: 8.25-2ubuntu2
  Version table:
 *** 8.25-2ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
linux-image-extra-4.4.0-53-generic:
  Installed: 4.4.0-53.74
  Candidate: 4.4.0-53.74
  Version table:
 *** 4.4.0-53.74 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status

答案1

看起来软件包libc6和/或coreutils已损坏。要修复此问题,您需要重新安装它们,而无需 Apt​​ 软件包操作的帮助。

  1. libc6将文件和包下载coreutils到临时目录中(或者您想要保存它们直到安装结束的任何位置):

    cd /tmp
    apt-get download libc6 coreutils
    
  2. 安装它们:

    sudo dpkg -i {libc6,coreutils}_*.deb
    
  3. 使用 Apt 修复剩余的打包问题:

    sudo apt-get install -f
    

相关内容