升级Ubuntu 18.04时出现dpkg错误(1)
这是apt-get upgrade
输出:
Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages have been kept back: linux-generic linux-headers-generic linux-image-generic 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. 6 not fully installed or removed. After this operation, 0 B of additional disk space will be used. N: Ignoring file '50unattended-upgrades.ucftmp' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension Do you want to continue? [Y/n] y Setting up grub-pc (2.02-2ubuntu8.2) ... dpkg: error processing package grub-pc (--configure): installed grub-pc package post-installation script subprocess returned error exit status 10 Setting up gdm3 (3.28.2-0ubuntu1.3) ... dpkg: error processing package gdm3 (--configure): installed gdm3 package post-installation script subprocess returned error exit status 10 Setting up unattended-upgrades (1.1ubuntu1.18.04.5) ... dpkg: error processing package unattended-upgrades (--configure): installed unattended-upgrades package post-installation script subprocess returned error exit status 10 Setting up google-chrome-stable (68.0.3440.75-1) ... update-alternatives: error: cannot scan directory '/var/lib/dpkg/alternatives': No such file or directory dpkg: error processing package google-chrome-stable (--configure): installed google-chrome-stable package post-installation script subprocess returned error exit status 2 No apport report written because MaxReports is reached already Setting up console-setup-linux (1.178ubuntu2.3) ... update-alternatives: error: cannot scan directory '/var/lib/dpkg/alternatives': No such file or directory dpkg: error processing package console-setup-linux (--configure): installed console-setup-linux package post-installation script subprocess returned error exit status 2 No apport report written because MaxReports is reached already dpkg: dependency problems prevent configuration of console-setup: console-setup depends on console-setup-linux | console-setup-freebsd | hurd; however: Package console-setup-linux is not configured yet. Package console-setup-freebsd is not installed. Package hurd is not installed. dpkg: error processing package console-setup (--configure): dependency problems - leaving unconfigured No apport report written because MaxReports is reached already Errors were encountered while processing: grub-pc gdm3 unattended-upgrades google-chrome-stable console-setup-linux console-setup E: Sub-process /usr/bin/dpkg returned an error code (1)
我该怎么做才能解决这个问题?
非常简单。 由于您收到的错误(例如“尚未配置Package console-setup-linux”),您的应用程序尚未配置。 这样做:
sudo dpkg --configure -a
然后再次尝试升级。 如果它给你错误,你“已经破了包”输入:
sudo apt -f install
然后运行sudo apt upgrade
注意:不再需要apt-get
。 你可以简单地输入sudo apt upgrade
来完成同样的事情。
相关的错误消息是:
error: cannot scan directory '/var/lib/dpkg/alternatives': No such file or directory
将alternative目录的备份存档从/var/backups/
复制到/var/lib/dpkg/
,重命名并解压缩。
sudo cp -r /var/backups/alternatives.tar.0 /var/lib/dpkg/ cd /var/lib/dpkg/ sudo mv -T alternatives.tar.0 alternatives.tar # rename alternatives.tar.0 sudo tar -xvf alternatives.tar sudo rm alternatives.tar sudo apt update sudo apt upgrade
如果这解决了您已完成的问题,但您也可能意外删除了/var/lib/dpkg/
的其他默认目录,并且还需要从备份中还原它们。 /var/lib/dpkg/
中的默认目录是:
备择方案
信息
部分
触发器
更新
可能缺少/var/lib/dpkg/status
文件,也需要从备份中恢复。 如果您收到任何No such file or directory
错误消息,请将其复制到您的问题中并在评论中通知我,我将在下一步编辑此答案。
如果你编辑你的问题,请将此命令的结果添加到它:
cd /var/lib/dpkg/ && ls
此命令将列出/var/lib/dpkg/
目录的所有内容,以便我可以列出需要从备份中还原的所有缺少的文件和目录。
- Ubuntu 18.04:连接到Lenovo P50后,蓝牙设备立即断开连接
- Ubuntu 18.04 systemd-udevd使用高CPU,与nvidia图形冲突
- 我认为英特尔酷睿i3-3217U @ 1.80GHz(四核,我认为)有资格作为“2 GHz双核处理器或更好”
- 自戴尔D630上安装18.04以来启动时间较慢
- 跳过获取配置文件’contrib / binary-i386 / Packages’作为存储库…不支持体系结构’i386′
- 我应该可以选择升级到18.04.1吗?
- easy_install:找不到命令
- 无法将Ubuntu 18.04从USB安装到全新的Acer Swift 1
- 如何在ubuntu 18.04上安装需要gksu包的应用程序?