当它在 ubuntu 上不起作用时如何修复 apt cmd

How to fix apt cmd when it doesn't work on ubuntu

我是一个 ubuntu 用户,在我的 etc/apt/sources.list 中添加了几次外部源的危险之后,软件存储库文件似乎已损坏。我不能再没有错误地更新。我想知道如何解决这样的问题。

这是我的 etc/apt/soure.list 文件,我有 uubuntu 20.10

deb http://it.archive.ubuntu.com/ubuntu/ groovy main universe restricted multiverse
deb-src http://it.archive.ubuntu.com/ubuntu/ groovy main universe restricted multiverse

deb http://security.ubuntu.com/ubuntu groovy-security main universe restricted multiverse
deb-src http://security.ubuntu.com/ubuntu groovy-security main universe restricted multiverse

deb http://it.archive.ubuntu.com/ubuntu/ groovy-updates main universe restricted multiverse
deb-src http://it.archive.ubuntu.com/ubuntu/ groovy-updates main universe restricted multiverse

deb http://it.archive.ubuntu.com/ubuntu groovy-backports main restricted universe multiverse
deb-src http://it.archive.ubuntu.com/ubuntu groovy-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu groovy partner
deb-src http://archive.canonical.com/ubuntu groovy partner

当我 运行 sudo apt-get update 我得到了这个。

Ign :1 http://it.archive.ubuntu.com/ubuntu groovy InRelease                                             
Ign :2 http://security.ubuntu.com/ubuntu groovy-security InRelease                                      
Atteint :3 http://archive.canonical.com/ubuntu groovy InRelease       
Ign :4 http://it.archive.ubuntu.com/ubuntu groovy-updates InRelease   
Err :5 http://security.ubuntu.com/ubuntu groovy-security Release      
  404  Not Found [IP : 91.189.91.38 80]
Ign :6 http://it.archive.ubuntu.com/ubuntu groovy-backports InRelease
Err :7 http://it.archive.ubuntu.com/ubuntu groovy Release
  404  Not Found [IP : 90.147.160.70 80]
Err :8 http://it.archive.ubuntu.com/ubuntu groovy-updates Release
  404  Not Found [IP : 90.147.160.70 80]
Err :9 http://it.archive.ubuntu.com/ubuntu groovy-backports Release
  404  Not Found [IP : 90.147.160.70 80]
Lecture des listes de paquets... Fait
E: Le dépôt http://security.ubuntu.com/ubuntu groovy-security Release n'a pas de fichier Release.
N: Les mises à jour depuis un tel dépôt ne peuvent s'effectuer de manière sécurisée, et sont donc désactivées par défaut.
N: Voir les pages de manuel d'apt-secure(8) pour la création des dépôts et les détails de configuration d'un utilisateur.
E: Le dépôt http://it.archive.ubuntu.com/ubuntu groovy Release n'a pas de fichier Release.
N: Les mises à jour depuis un tel dépôt ne peuvent s'effectuer de manière sécurisée, et sont donc désactivées par défaut.
N: Voir les pages de manuel d'apt-secure(8) pour la création des dépôts et les détails de configuration d'un utilisateur.
E: Le dépôt http://it.archive.ubuntu.com/ubuntu groovy-updates Release n'a pas de fichier Release.
N: Les mises à jour depuis un tel dépôt ne peuvent s'effectuer de manière sécurisée, et sont donc désactivées par défaut.
N: Voir les pages de manuel d'apt-secure(8) pour la création des dépôts et les détails de configuration d'un utilisateur.
E: Le dépôt http://it.archive.ubuntu.com/ubuntu groovy-backports Release n'a pas de fichier Release.
N: Les mises à jour depuis un tel dépôt ne peuvent s'effectuer de manière sécurisée, et sont donc désactivées par défaut.
N: Voir les pages de manuel d'apt-secure(8) pour la création des dépôts et les détails de configuration d'un utilisateur.

我必须进行配置,我的 apt 必须运行良好。这几天一直在阻止我。我希望有人能帮助我。谢谢。

Ubuntu 20.10 has been deprecated for nearly a year。您应该将 it.archive.ubuntu.com 替换为 old-releases.ubuntu.com

root@fd8c537092b2:/# grep VERSION /etc/os-release
VERSION="20.10 (Groovy Gorilla)"
VERSION_ID="20.10"
VERSION_CODENAME=groovy

root@fd8c537092b2:/# grep '^deb' /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ groovy main restricted
deb http://archive.ubuntu.com/ubuntu/ groovy-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ groovy universe
deb http://archive.ubuntu.com/ubuntu/ groovy-updates universe
deb http://archive.ubuntu.com/ubuntu/ groovy multiverse
deb http://archive.ubuntu.com/ubuntu/ groovy-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ groovy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ groovy-security main restricted
deb http://security.ubuntu.com/ubuntu/ groovy-security universe
deb http://security.ubuntu.com/ubuntu/ groovy-security multiverse

root@fd8c537092b2:/# apt-get update
Ign:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Ign:2 http://security.ubuntu.com/ubuntu groovy-security InRelease
Err:3 http://security.ubuntu.com/ubuntu groovy-security Release
  404  Not Found [IP: 91.189.91.38 80]
Ign:4 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Ign:5 http://archive.ubuntu.com/ubuntu groovy-backports InRelease
Err:6 http://archive.ubuntu.com/ubuntu groovy Release
  404  Not Found [IP: 185.125.190.36 80]
Err:7 http://archive.ubuntu.com/ubuntu groovy-updates Release
  404  Not Found [IP: 185.125.190.36 80]
Err:8 http://archive.ubuntu.com/ubuntu groovy-backports Release
  404  Not Found [IP: 185.125.190.36 80]
Reading package lists... Done
E: The repository 'http://security.ubuntu.com/ubuntu groovy-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.
E: The repository 'http://archive.ubuntu.com/ubuntu groovy 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 groovy-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 groovy-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.

root@fd8c537092b2:/# sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

root@fd8c537092b2:/# grep '^deb' /etc/apt/sources.list
deb http://old-releases.ubuntu.com/ubuntu/ groovy main restricted
deb http://old-releases.ubuntu.com/ubuntu/ groovy-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ groovy universe
deb http://old-releases.ubuntu.com/ubuntu/ groovy-updates universe
deb http://old-releases.ubuntu.com/ubuntu/ groovy multiverse
deb http://old-releases.ubuntu.com/ubuntu/ groovy-updates multiverse
deb http://old-releases.ubuntu.com/ubuntu/ groovy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ groovy-security main restricted
deb http://security.ubuntu.com/ubuntu/ groovy-security universe
deb http://security.ubuntu.com/ubuntu/ groovy-security multiverse

root@fd8c537092b2:/# apt-get update
Get:1 http://old-releases.ubuntu.com/ubuntu groovy InRelease [267 kB]
Ign:2 http://security.ubuntu.com/ubuntu groovy-security InRelease
Err:3 http://security.ubuntu.com/ubuntu groovy-security Release
  404  Not Found [IP: 185.125.190.36 80]
Get:4 http://old-releases.ubuntu.com/ubuntu groovy-updates InRelease [115 kB]
Get:5 http://old-releases.ubuntu.com/ubuntu groovy-backports InRelease [101 kB]
Get:6 http://old-releases.ubuntu.com/ubuntu groovy/restricted amd64 Packages [87.5 kB]
Get:7 http://old-releases.ubuntu.com/ubuntu groovy/main amd64 Packages [1768 kB]
Get:8 http://old-releases.ubuntu.com/ubuntu groovy/universe amd64 Packages [16.1 MB]
Get:9 http://old-releases.ubuntu.com/ubuntu groovy/multiverse amd64 Packages [247 kB]
Get:10 http://old-releases.ubuntu.com/ubuntu groovy-updates/universe amd64 Packages [559 kB]
Get:11 http://old-releases.ubuntu.com/ubuntu groovy-updates/restricted amd64 Packages [110 kB]
Get:12 http://old-releases.ubuntu.com/ubuntu groovy-updates/main amd64 Packages [453 kB]
Get:13 http://old-releases.ubuntu.com/ubuntu groovy-updates/multiverse amd64 Packages [20.1 kB]
Get:14 http://old-releases.ubuntu.com/ubuntu groovy-backports/main amd64 Packages [2681 B]
Get:15 http://old-releases.ubuntu.com/ubuntu groovy-backports/universe amd64 Packages [6237 B]
Reading package lists... Done
E: The repository 'http://security.ubuntu.com/ubuntu groovy-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.

完成后,您应该回到受支持的版本。不幸的是,ubuntu 20.10:

无法再这样做了
root@fd8c537092b2:/# apt-get install -y ubuntu-release-upgrader-core
...stuff...
root@fd8c537092b2:/# do-release-upgrade
...stuff...
An upgrade from 'groovy' to 'impish' is not supported with this tool.

这里有一个更长的升级方法:https://help.ubuntu.com/community/EOLUpgrades/

为避免将来出现这种情况,如果您不打算每 6 个月升级一次 ubuntu OS,则应继续使用 LTS 版本。否则一定要在下一个版本发布后尽快升级,这样你就不会最终 运行 一个升级路径困难的不受支持的版本。