搬到另一个国家后,无法更新或安装任何东西。

几天前,我在我的电脑上安装了Ubuntu,一切都正常运行。
碰巧我去了另一个国家,现在还在那里。所以每当我运行更新或尝试从Ubuntu软件中安装任何东西时,什么都不起作用,尽管我的互联网连接正常,我可以使用我的电脑访问互联网(我现在就是用它来写这些文字)。
我尝试将服务器更改为我现在所在国家的服务器之一,但没有效果。所以我改成了Ubuntu的主服务器,也没有效果。
我重新启动了电脑,运行了sudo apt autocleansudo apt clean,但没有任何变化。
每当我运行更新过程时,仍然会出现这些错误:
sudo apt update
Ign:1 http://archive.canonical.com/ubuntu bionic InRelease
Err:2 http://archive.canonical.com/ubuntu bionic Release
  404  Not Found [IP: 91.189.92.191 80]
Ign:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Ign:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Ign:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Ign:6 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Err:7 http://archive.ubuntu.com/ubuntu bionic Release
  404  Not Found [IP: 91.189.88.174 80]
Err:8 http://archive.ubuntu.com/ubuntu bionic-updates Release
  404  Not Found [IP: 91.189.88.174 80]
Err:9 http://archive.ubuntu.com/ubuntu bionic-backports Release
  404  Not Found [IP: 91.189.88.174 80]
Err:10 http://archive.ubuntu.com/ubuntu bionic-security Release
  404  Not Found [IP: 91.189.88.174 80]
Reading package lists... Done
E: The repository 'http://archive.canonical.com/ubuntu bionic Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

有人知道如何修复这个问题吗?

编辑:
问题不是我在/etc/apt/sources.list中没有正确的链接。我的问题是,当我运行更新时,在终端中显示的链接与我在/etc/apt/sources.list中的链接不相似。 当我按照Raffa的建议更新了/etc/apt/sources.list后,仍然出现类似的错误。

sudo apt update 
Ign:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Ign:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Err:4 http://security.ubuntu.com/ubuntu bionic-security Release
  404  Not Found [IP: 91.189.91.14 80]
Err:5 http://archive.ubuntu.com/ubuntu bionic Release
  404  Not Found [IP: 91.189.88.31 80]
Err:6 http://archive.ubuntu.com/ubuntu bionic-updates Release
  404  Not Found [IP: 91.189.88.31 80]
Reading package lists... Done
E: The repository 'http://security.ubuntu.com/ubuntu bionic-security Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

虽然 /etc/apt/sources.list 文件中包含了 Raffa 提到的链接。
cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse universe restricted
5个回答

由于某种原因,APT在指定的存储库列表中找不到“Release”文件。
为了解决这个问题,我建议以下操作:
- 检查您与互联网的连接是否受到防火墙、限制或代理的影响,并相应地配置您的系统和连接,或者如果有其他可用的连接,请切换到其他连接。 - 运行以下命令检查是否存在APT代理配置文件:
ls /etc/apt/apt.conf.d/*proxy*

如果命令返回任何结果,将这些文件移出/etc/apt/apt.conf.d/目录,或者删除它们。
  • 通过在终端中运行以下命令,将存储库列表恢复为原始的Ubuntu Bionic Beaver列表:
sudo nano /etc/apt/sources.list

将打开一个文件编辑器。删除其中的所有行,然后将以下内容复制并粘贴到文件编辑器中:
deb http://archive.ubuntu.com/ubuntu bionic main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse universe restricted

然后,按下Ctrl + X,然后按下Y,最后按下Enter来保存并关闭文件。
为了验证您是否正确保存了文件,请在终端中运行以下命令:
cat /etc/apt/sources.list

输出应该是这样的:
deb http://archive.ubuntu.com/ubuntu bionic main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse universe restricted

Ubuntu的软件仓库有着明确定义的格式。例如,它们应该是类似于deb http://archive.ubuntu.com/ubuntu bionic main这样的形式。
解释: deb:这些仓库包含二进制文件或预编译的软件包。对于大多数用户来说,这些仓库是必需的。 http://archive.ubuntu.com/ubuntu:这是一个统一资源标识符(URI),在这种情况下是指互联网上的一个位置。 bionic:是您的Ubuntu安装的发行版名称。 mainrestricted等等:是部分名称或组件。可以有多个部分名称,用空格分隔。
请在终端中运行以下命令来更新您的存储库列表:
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/

在此之后,请通过在终端中运行以下命令清除所有现有的PPA和存储库列表:/etc/apt/sources.list.d/
sudo rm -r /etc/apt/sources.list.d/*

请在终端中再次运行以下命令来更新您的存储库列表:
sudo apt update

问题是,当我运行更新时,出现的链接与/etc/apt/sources.list中的链接不一样。 我会在我的问题中提供更多细节。 - singrium
@singrium 请查看更新后的答案。 - Raffa
我按照你说的做了,然后运行了更新,但是什么都没起作用。我换了WiFi(连接到我的手机数据),一切都正常工作。 谢谢你的帮助。 - singrium
你认为更改/etc/apt/sources.list文件的一些内容是否可以吗?这似乎有点敏感。 - Boris Valderrama
1@Elborito 只要你遵循正确的格式,避免混合不同版本的来源,并且不添加第三方来源,就没问题。 - Raffa
如果你有另一个版本的Ubuntu,你必须使用这个sources.list中的sources.list文件。 - Azade

我认为这并不完全是因为你的连接国家发生了变化。 而是因为新的连接有任何代理服务器或系统来阻止或重定向Ubuntu服务器...(可能是政府或机构)
我在大学的“计算机房”也遇到了类似的问题。
我认为我可以使用一些VPN或服务器配置(DNS)来解决这个问题...

没错。我记得我得使用一些代理才能进行更新。 - singrium


请检查我的问题更新。 - singrium

我只是在/etc/apt/sources.list中注释掉了导致问题的服务器名称。

对于新手而言,有一种更简单的方法,无需使用命令行:

  • 打开软件更新器
  • 设置
  • Ubuntu软件
  • 从以下位置下载:
  • 其他...
  • mirrors.ubuntu.com(向上滚动至第一个条目)
  • 选择服务器
  • (如果提示,请输入密码)
  • 关闭
  • 重新加载(当提示“软件已过期”时)

更新应该正常工作。


  • 相关问题