我的 Ubuntu 出现了一些问题,几个月来一直无法修复。每当我尝试更新/安装任何新东西时,它都无法安装,包括 Chrome 更新、运行软件更新程序和其他各种东西。
我在这里被告知“似乎存在依赖性问题,很可能是由于之前的安装中断造成的。请先尝试运行 sudo apt install -f 来修复任何依赖性问题”,软件更新程序也给我这样的建议,它说:“无法安装或删除任何软件。请使用包管理器“Synaptic”或在终端中运行“sudo apt-get install -f”来首先修复此问题。”但是,当我在终端中执行此操作时,我不断收到以下响应消息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libde265-0 libfwup1 libheif1 libllvm6.0 libllvm7 libllvm8
linux-modules-4.15.0-1043-oem linux-oem-headers-4.15.0-1036
linux-oem-headers-4.15.0-1038 linux-oem-headers-4.15.0-1039
linux-oem-headers-4.15.0-1043 oem-fix-tlp-realtek-lp1819812-blacklistr8153
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
linux-image-4.15.0-1043-oem linux-image-4.15.0-1050-oem
0 upgraded, 0 newly installed, 2 to remove and 237 not upgraded.
5 not fully installed or removed.
After this operation, 16.8 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 336469 files and directories currently installed.)
Removing linux-image-4.15.0-1043-oem (4.15.0-1043.48) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-1043-oem
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: If: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.15.0-1043-oem (--remove):
installed linux-image-4.15.0-1043-oem package post-removal script subprocess returned error exit status 1
Removing linux-image-4.15.0-1050-oem (4.15.0-1050.57) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-1050-oem
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: If: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.15.0-1050-oem (--remove):
installed linux-image-4.15.0-1050-oem package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-1043-oem
linux-image-4.15.0-1050-oem
E: Sub-process /usr/bin/dpkg returned an error code (1)
而我永远无法超越这个阶段。有人能提供一些建议吗?非常感谢,提前感谢。:-)
答案1
为了长远目标。
sudo nano /etc/default/grub
确保第 1 行以 # 开头
# If you change this file, run 'update-grub' afterwards to update
然后sudo dpkg --configure -a && sudo apt -f install
答案2
尝试后
sudo apt-get update –fix-missing
和
sudo dpkg --configure -a
和
sudo apt-get install -f
损坏软件包的问题仍然存在,解决方案是手动编辑 dpkg 状态文件。
sudo nano /var/lib/dpkg/status
(您可以使用 vim 或 gedit 代替 nano)
找到损坏的包,删除有关它的整个信息块并保存文件。
解锁 dpkg – (消息 /var/lib/dpkg/lock)
sudo fuser -vki /var/lib/dpkg/lock
sudo dpkg --configure -a
一切顺利 !!!