第一次运行sudo apt update
,sudo apt update
一切正常,但运行后sudo apt upgrade
出现以下错误。
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-headers-5.4.0-59 linux-headers-5.4.0-59-generic linux-image-5.4.0-59-generic linux-modules-5.4.0-59-generic linux-modules-extra-5.4.0-59-generic
The following packages will be upgraded:
libasound2 libasound2-data libatopology2 libproxy1-plugin-gsettings libproxy1-plugin-networkmanager libproxy1v5 linux-generic-hwe-20.04 linux-headers-generic-hwe-20.04
linux-image-generic-hwe-20.04 linux-libc-dev nautilus-sendto python-apt-common python3-apt
13 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 72.5 kB/76.0 MB of archives.
After this operation, 360 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2 [5,284 B]
Ign:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2 [18.1 kB]
Ign:2 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2
Get:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2 [49.1 kB]
Ign:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2
Get:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2 [5,284 B]
Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.152 80]
Get:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2 [18.1 kB]
Err:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.152 80]
Get:3 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2 [49.1 kB]
Err:3 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1-plugin-networkmanager_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1-plugin-gsettings_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1v5_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
结果cat /etc/apt/sources.list
:
# deb cdrom:[Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://in.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal universe
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://in.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
结果sudo apt update --fix-missing
:
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
13 packages can be upgraded. Run 'apt list --upgradable' to see them.
结果sudo apt upgrade
:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-headers-5.4.0-59 linux-headers-5.4.0-59-generic linux-image-5.4.0-59-generic linux-modules-5.4.0-59-generic linux-modules-extra-5.4.0-59-generic
The following packages will be upgraded:
libasound2 libasound2-data libatopology2 libproxy1-plugin-gsettings libproxy1-plugin-networkmanager libproxy1v5 linux-generic-hwe-20.04 linux-headers-generic-hwe-20.04
linux-image-generic-hwe-20.04 linux-libc-dev nautilus-sendto python-apt-common python3-apt
13 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 72.5 kB/76.0 MB of archives.
After this operation, 360 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2 [5,284 B]
Ign:1 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2
Get:2 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2 [18.1 kB]
Ign:2 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2
Get:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2 [49.1 kB]
Ign:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2
Get:1 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2 [5,284 B]
Err:1 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-networkmanager amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.142 80]
Get:2 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2 [18.1 kB]
Err:2 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1-plugin-gsettings amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.142 80]
Get:3 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2 [49.1 kB]
Err:3 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libproxy1v5 amd64 0.4.15-10ubuntu1.2
Undetermined Error [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1-plugin-networkmanager_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1-plugin-gsettings_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libproxy/libproxy1v5_0.4.15-10ubuntu1.2_amd64.deb Undetermined Error [IP: 91.189.88.142 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
答案1
通过在终端中运行以下命令将您的存储库列表恢复为原始 Ubuntu Focal 列表:
sudo nano /etc/apt/sources.list
将打开一个文件编辑器。删除其中的所有行,然后将以下内容复制并粘贴到文件编辑器中:
deb http://archive.ubuntu.com/ubuntu focal main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse universe restricted
Ctrl然后按+保存并关闭文件,X然后按Y,然后按Enter
为了验证您是否正确保存了文件,请在终端中运行以下命令:
cat /etc/apt/sources.list
输出应该准确:
deb http://archive.ubuntu.com/ubuntu focal main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse universe restricted
Ubuntu 存储库具有定义的格式。例如,它们应该是这样的
deb http://archive.ubuntu.com/ubuntu bionic main
。解释:
deb
:这些存储库包含二进制文件或预编译包。大多数用户都需要这些存储库。
http://archive.ubuntu.com/ubuntu
:URI(统一资源标识符),在本例中是互联网上的位置。
focal
:是您的 Ubuntu 安装的发布名称。
main
&restricted
...ETC:是部分名称或组成部分。可以有多个部分名称,以空格分隔。
之后,请通过在终端中运行以下命令清除 apt 缓存:
sudo apt clean && sudo apt autoclean
然后通过在终端中运行以下命令来更新您的存储库列表:
sudo apt update
您现在应该能够安装软件包并再次更新系统。
如果之后仍然出现错误,请先/etc/apt/sources.list.d/
通过在终端中运行以下命令备份到您的主目录:
mkdir ~/old_sources_list_d && sudo cp -r /etc/apt/sources.list.d/* ~/old_sources_list_d/
之后,请通过/etc/apt/sources.list.d/
在终端中运行以下命令清除所有现有的 PPA 和存储库列表:
sudo rm -r /etc/apt/sources.list.d/*
之后,请通过在终端中运行以下命令清除 apt 缓存:
sudo apt clean && sudo apt autoclean
然后,请通过在终端中再次运行以下命令来更新您的存储库列表:
sudo apt update
注意:
检查您的互联网连接是否在防火墙后面、是否受到任何限制或是否在代理后面,并相应地配置您的系统和连接,或更改为其他连接(如果可用)。防火墙可以阻止对某些 URL 的访问,而代理可以在其缓存系统中保留旧的过期链接,这会导致目标损坏或无响应。代理还可以修改 HTTP 请求的标头并干扰来自 Web 服务器的响应并更改它们,您的计算机最终可能会收到 APT 无法正确处理的错误响应。这在大量用户使用的网络中很常见,并且出于可用性和安全性原因资源或互联网速度有限。
通过运行以下命令检查是否存在 APT 代理配置文件:
ls /etc/apt/apt.conf.d/*proxy*
如果命令返回任何结果,请将这些文件移出/etc/apt/apt.conf.d/
目录或删除它们。
答案2
摘自@krisna-kakade 的评论。
以下内容对我有用,无需采取进一步行动。
sudo apt update --fix-missing
sudo apt upgrade