2023-06-02_11-08.png
Ubuntu系统维持在线更新和稳定的利器:
截图 2023-06-02 09-28-44.png
对应命令:

sudo apt update
sudo apt upgrade

但随着系统的使用,常常会莫名其妙出现各种问题,导致无法更新,或者有小错误小警告导致不爽。www.ufans.top为你总结各种错误及解决方法如下:

错误1:列表类错误

E:Encountered a section with no Package: header, E:Problem with
MergeList
/var/lib/apt/lists/archive.ubuntu.comubuntudistspreciseuniversebinary-i386Packages,
E:The package lists or status file could not be parsed or opened.’
或者
W: 目标 Sources (main/source/Sources) 在 /etc/apt/sources.list:2 和
/etc/apt/sources.list:7 中被配置了多次

解决办法:

sudo rm -r /var/lib/apt/lists/*
sudo apt clean && sudo apt update

错误2:下载仓库信息类错误
如果出现:

W:Failed to fetch bzip2:/var/lib/apt/lists/partial/in.archive.ubuntu.com ubuntu
Hash Sum mismatch, W:Failed to fetch
bzip2:/var/lib/apt/lists/partial/in.archive.ubuntu.comubuntudistsoneiricmultiversebinary-i386Packages
Hash Sum mismatch, E:Some index files failed to download. They have
been ignored, or old ones used instead

解决的方法:

sudo rm -r /var/lib/apt/lists/*
sudo apt clean && sudo apt update

如果还是无效,可更换软件包来源:
2023-06-02_09-52.png

如果出现
20200215180035.png
你可以运行sudo apt-get update来查看哪个PPA更新失败,你可以把它从源列表中删除。
打开“软件与更新”,在“其它软件”处找到对应的ppa删除即可:
Software-Sources-Ubuntu-13.04.jpeg

错误3: 部分更新错误
在终端中运行更新会出现部分更新错误:

Not all updates can be installed Run a partial upgrade, to install as
many updates as possible

解决的方法:
在终端中运行以下命令来修复该错误:

sudo apt-get install -f

有时安装软件时,尤其是deb安装包时,也可以采用上述命令修复完善。

错误4:加载共享库时发生错误

该错误更多是安装错误,而不是更新错误。如果尝试从源码安装程序,你可能会碰到这个错误:

error while loading shared libraries: cannot open shared object file:
No such file or directory

解决的方法:
该错误可以通过在终端中运行以下命令来修复:

sudo /sbin/ldconfig -v

错误5:无法获取锁 /var/cache/apt/archives/lock

在另一个程序在使用APT时,会发生该错误。假定你正在Ubuntu软件中心安装某个东西,然后你又试着在其它终端中运行apt。

E: Could not get lock /var/cache/apt/archives/lock – open (11:
Resource temporarily unavailable) E: Unable to lock directory
/var/cache/apt/archives/

解决的方法:
通常,只要你把所有其它使用apt的程序关了,这个问题就会好的。但是,如果问题持续,可以使用以下命令:

sudo rm /var/lib/apt/lists/lock

如果上面的命令不起作用,可以试试这个命令:

sudo killall apt-get

错误6:GPG错误:下列签名无法验证

在添加一个PPA时,可能会导致以下错误GPG错误: 下列签名无法验证,这通常发生在终端中运行更新时:

W: GPG error: http://repo.mate-desktop.org saucy InRelease: The
following signatures couldn’t be verified because the public key is
not available: NO_PUBKEY 68980A0EA10B4DE8

解决的方法:
我们所要做的,就是获取系统中的这个公钥,从信息中获取密钥号。在上述信息中,密钥号为68980A0EA10B4DE8。该密钥可通过以下方式使用:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68980A0EA10B4DE8

在添加密钥后,再次运行更新就没有问题了。

错误7:BADSIG错误

另外一个与签名相关的Ubuntu更新错误是BADSIG错误,它看起来像这样:

W: A error occurred during the signature verification. The repository
is not updated and the previous index files will be used. GPG error:
http://extras.ubuntu.com precise Release: The following signatures
were invalid: BADSIG 16126D3A3E5C1192 Ubuntu Extras Archive Automatic
Signing Key W: GPG error: http://ppa.launchpad.net precise Release:
The following signatures were invalid: BADSIG 4C1CBC1B69B0E2F4
Launchpad PPA for Jonathan French W: Failed to fetch
http://extras.ubuntu.com/ubuntu/dists/precise/Release

解决的方法:
要修复该BADSIG错误,请在终端中使用以下命令:

sudo apt-get clean
cd /var/lib/apt
sudo mv lists oldlist
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update

错误8:网络断或意外终端导致的错误

E: GPG 错误:http://mirrors.163.com precise Release: 下列签名无效: NODATA 1
NODATA 2

解决办法:
出现这个错误表示没有连上网,检查一下网络状态。

如果在添加源,然后在更新源时中途中断了更新,只要再安装软件或者再去更新的时候就会出来的错误提示。

E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用) E: 无法对目录 /var/lib/apt/lists/ 加锁

解决办法:
输入指令:

sudo rm /var/lib/apt/lists/lock

错误9:apt-key崩溃

W: GPG error: https://mega.nz/linux/repo/xUbuntu_21.10 ./ InRelease:
The following signatures couldn't be verified because the public key
is not available: NO_PUBKEY 1A664B787094A482 E: The repository
'https://mega.nz/linux/repo/xUbuntu_21.10 ./ InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is
therefore disabled by default.

实际添加添加apt-key仍然无效,或者删除apt-key list无效。

解决方法:
方法一(注意实际对应修改):

wget -O- https://mega.nz/linux/repo/xUbuntu_21.10/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/mega-nz.gpg

方法二:删除相关的list:

cd /etc/apt/sources.list.d
sudo rm -rf megasync.list*
最后修改:2023 年 06 月 04 日
如果觉得我的文章对你有用,请随意赞赏