由于更新导致 apt-get 出现问题

由于更新导致 apt-get 出现问题

几天前我更新了 Ubuntu,因此无法登录电脑,所以我错误地在内核中删除了更新的版本,但我可以继续工作。

现在的问题是,每次我使用该apt-get命令时,它都会以这些行结束(例如,尝试安装 ruby​​):

Reading package lists... Done
Building dependency tree       
Reading state information... Done
ruby is already the newest version (1:2.5.1).
The following packages were automatically installed and are no longer required:
  command-not-found-data gcc-5-base gir1.2-gst-plugins-base-1.0
  gir1.2-gstreamer-1.0 gir1.2-rb-3.0 gir1.2-totem-1.0 gir1.2-totemplparser-1.0
  gyp libdmapsharing-3.0-2 libgpod-common libgpod4 libgsoap-2.8.60
  libhttp-parser2.7.1 libjs-async libjs-inherits libjs-node-uuid libnetplan0
  libsgutils2-2 libssl1.0-dev libuv1 libuv1-dev libvncserver1 libxatracker2
  libxnvctrl0 libxvmc1 linux-hwe-5.4-headers-5.4.0-42
  linux-hwe-5.4-headers-5.4.0-56 linux-hwe-5.4-headers-5.4.0-58
  linux-hwe-5.4-headers-5.4.0-59 linux-hwe-5.4-headers-5.4.0-62 node-abbrev
  node-ansi node-ansi-color-table node-archy node-async node-balanced-match
  node-block-stream node-brace-expansion node-combined-stream node-concat-map
  node-cookie-jar node-delayed-stream node-forever-agent node-form-data
  node-fs.realpath node-fstream node-fstream-ignore node-github-url-from-git
  node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight
  node-inherits node-ini node-isexe node-json-stringify-safe node-lockfile
  node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
  node-node-uuid node-nopt node-npmlog node-once node-osenv
  node-path-is-absolute node-pseudomap node-qs node-read node-request
  node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct
  node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent
  node-underscore node-validate-npm-package-license node-which node-wrappy
  node-yallist nodejs-doc pkg-config
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
Setting up linux-headers-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 4
dpkg: error processing package linux-headers-5.4.0-65-generic (--configure):
 installed linux-headers-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-headers-generic-hwe-18.04:
 linux-headers-generic-hwe-18.04 depends on linux-headers-5.4.0-65-generic; however:
  Package linux-headers-5.4.0-65-generic is not configured yet.

dpkg: error processing package linux-headers-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic-hwe-18.04:
 linux-generic-hwe-18.04 depends on linux-headers-generic-hwe-18.04 (= 5.4.0.65.73~18.04.60); however:
  Package linux-headers-generic-hwe-18.04 is not configured yet.

dpkg: error processing package linux-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          No apport report written because the error message indicates its a followup error from a previous failure.
                                                    Processing triggers for linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-5.4.0-65-generic (--configure):
 installed linux-image-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-headers-5.4.0-65-generic
 linux-headers-generic-hwe-18.04
 linux-generic-hwe-18.04
 linux-image-5.4.0-65-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

我该如何修复它?(也许这是件愚蠢的事情,但我不是使用 Ubuntu 的专业人士,所以提前致歉)。

编辑:

运行后sudo apt autoremove

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
Setting up linux-headers-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 4
dpkg: error processing package linux-headers-5.4.0-65-generic (--configure):
 installed linux-headers-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-headers-generic-hwe-18.04:
 linux-headers-generic-hwe-18.04 depends on linux-headers-5.4.0-65-generic; however:
  Package linux-headers-5.4.0-65-generic is not configured yet.

dpkg: error processing package linux-headers-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic-hwe-18.04:
 linux-generic-hwe-18.04 depends on linux-headers-generic-hwe-18.04 (= 5.4.0.65.73~18.04.60); however:
  Package linux-headers-generic-hwe-18.04 is not configured yet.

dpkg: error processing package linux-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
     No apport report written because the error message indicates its a followup error from a previous failure.
          Processing triggers for linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-5.4.0-65-generic (--configure):
 installed linux-image-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-headers-5.4.0-65-generic
 linux-headers-generic-hwe-18.04
 linux-generic-hwe-18.04
 linux-image-5.4.0-65-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

跑步后sudo apt purge

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
Setting up linux-headers-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 4
dpkg: error processing package linux-headers-5.4.0-65-generic (--configure):
 installed linux-headers-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-headers-generic-hwe-18.04:
 linux-headers-generic-hwe-18.04 depends on linux-headers-5.4.0-65-generic; however:
  Package linux-headers-5.4.0-65-generic is not configured yet.

dpkg: error processing package linux-headers-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic-hwe-18.04:
 linux-generic-hwe-18.04 depends on linux-headers-generic-hwe-18.04 (= 5.4.0.65.73~18.04.60); however:
  Package linux-headers-generic-hwe-18.04 is not configured yet.

dpkg: error processing package linux-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
     No apport report written because the error message indicates its a followup error from a previous failure.
          Processing triggers for linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-5.4.0-65-generic (--configure):
 installed linux-image-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-headers-5.4.0-65-generic
 linux-headers-generic-hwe-18.04
 linux-generic-hwe-18.04
 linux-image-5.4.0-65-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

跑步后sudo apt-get -f install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
Setting up linux-headers-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 4
dpkg: error processing package linux-headers-5.4.0-65-generic (--configure):
 installed linux-headers-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-headers-generic-hwe-18.04:
 linux-headers-generic-hwe-18.04 depends on linux-headers-5.4.0-65-generic; however:
  Package linux-headers-5.4.0-65-generic is not configured yet.

dpkg: error processing package linux-headers-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic-hwe-18.04:
 linux-generic-hwe-18.04 depends on linux-headers-generic-hwe-18.04 (= 5.4.0.65.73~18.04.60); however:
  Package linux-headers-generic-hwe-18.04 is not configured yet.

dpkg: error processing package linux-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
     No apport report written because the error message indicates its a followup error from a previous failure.
          Processing triggers for linux-image-5.4.0-65-generic (5.4.0-65.73~18.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-65-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
   ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-5.4.0-65-generic (--configure):
 installed linux-image-5.4.0-65-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-headers-5.4.0-65-generic
 linux-headers-generic-hwe-18.04
 linux-generic-hwe-18.04
 linux-image-5.4.0-65-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

跑步后sudo dpkg-reconfigure linux-image-5.4.0-65-generic

/usr/sbin/dpkg-reconfigure: linux-image-5.4.0-65-generic is broken or not fully installed

运行后sudo dpkg-reconfigure --force linux-image-5.4.0-65-generic没有输出

答案1

你的apt-get意思是什么apt-get install

首先,输出告诉您 ruby​​ 已安装。

然后它会列出不需要的包,并在最后告诉你如何删除它们sudo apt autoremove 我建议你之后sudo apt purge也运行

在第二组错误消息中,dpkg(基本上是 apt 调用的程序)告诉您 a)不存在配置文件,以及 b)您有依赖关系问题,因此我会尝试sudo apt-get -f install(-f steht für fix-missing)

可能配置错误仍然存​​在,因此我会尝试重新配置, sudo dpkg-reconfigure linux-image-5.4.0-65-generic 对 linux-headers-generic-hwe-18.04 linux-generic-hwe-18.04 linux-image-5.4.0-65-generic 也进行同样的操作

如果出现错误或无法解决问题,请尝试sudo dpkg-reconfigure --force linux-image-5.4.0-65-generic其他方法。但是请注意,我不确定这最后一条命令。我认为这应该不危险,但我不是 100% 确定。

谢谢你给我自我学习的机会!

边注 apt并且apt-get几乎一样,但 apt 更加用户友好

初学者提示:尝试man yourprogram经常使用或更好man yourprogramm | less -p "specific function inside the program"。然后使用“n”滚动到找到搜索表达式的不同实例(并使用 shift+n 返回一个搜索词)示例:man less | less -p "-p"在程序手册中搜索搜索模式“-p”。这也适用于帮助标志。例如。。大多数less --help | less -p "-p"情况下,--help 或 -h 仅提供比手册更粗略的帮助,但有时没有手册。| 管道第一个命令的输出到第二个命令。因此,less 通过 -p 搜索整个手册页,并在搜索模式第一次出现时开始输出。

man -K "Search-Pattern"的搜索每一个搜索模式的手册页(慢!)apropos "search-pattern"您可以在程序描述中搜索模式,结果是程序名称。

最后的初学者建议:安装 tldr(太长了没读完),sudo apt install tldr因为有了它tldr programm你能获得很多程序最常用的用例和灵感。

最后:!! 重复上一个命令。所以用 sudo !! 你可以重复你忘记输入 sudo 的命令 ;)

相关内容