Ubuntu sudo apt get update 404 Not Found问题

我在我的系统上使用的是Ubuntu 20.04.3 LTS。 我遇到了一个错误已经持续了两天。我无法更新升级或安装软件包,我收到以下错误信息:
Hit:1 http://packages.microsoft.com/repos/code stable InRelease                                                                   
Hit:2 http://archive.canonical.com/ubuntu focal InRelease                                                                         
Hit:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease                                                              
Hit:4 http://dl.google.com/linux/chrome/deb stable InRelease                                                                      
Ign:5 http://old-releases.ubuntu.com/ubuntu focal InRelease                                                                       
Ign:6 http://old-releases.ubuntu.com/ubuntu focal-updates InRelease                                                               
Hit:7 http://ppa.launchpad.net/kicad/kicad-5.1-releases/ubuntu focal InRelease                                                    
Hit:8 https://deb.opera.com/opera-stable stable InRelease                                                                         
Hit:9 https://packages.microsoft.com/repos/vscode stable InRelease                                                                
Ign:10 http://old-releases.ubuntu.com/ubuntu focal-backports InRelease                                                            
Ign:11 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu focal InRelease                                           
Ign:12 http://old-releases.ubuntu.com/ubuntu focal-security InRelease                                                      
Err:14 http://old-releases.ubuntu.com/ubuntu focal Release                                                                        
  404  Not Found [IP: 91.189.88.247 80]
Err:15 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu focal Release                                                    
  404  Not Found [IP: 91.189.95.85 80]
Err:16 http://old-releases.ubuntu.com/ubuntu focal-updates Release                                                           
  404  Not Found [IP: 91.189.88.247 80]
Hit:17 https://linux-clients.seafile.com/seafile-deb/focal stable InRelease                
Err:18 http://old-releases.ubuntu.com/ubuntu focal-backports Release 
  404  Not Found [IP: 91.189.88.247 80]
Err:19 http://old-releases.ubuntu.com/ubuntu focal-security Release  
  404  Not Found [IP: 91.189.88.247 80]
Ign:13 https://launchpad.net/~terry.guo/+archive/gcc-arm-embedded focal InRelease
Err:20 https://launchpad.net/~terry.guo/+archive/gcc-arm-embedded focal Release
  404  Not Found [IP: 91.189.89.222 443]
Reading package lists... Done

怎么解决这个问题?

4为什么你的源中有old-releases?Focal根本不是一个"旧版本"啊... - matigo
这个回答解决了你的问题吗?如何恢复默认软件源? 你的 sources.list 文件出了问题。只需重置它们,然后在需要的情况下重新添加任何必要的软件源,比如 VS Code。 - cocomac
@cocomac 不,我尝试了每一步,但是还是不起作用。 - gogogo
@matigo 我不知道 :/ 我该怎么解决这个问题呢? - gogogo
1如果@cocomac的解决方案没有起作用,那么您需要手动打开/etc/apt/sources.list文件并修复问题。Focal Fossa根本不是“旧版本”,因此URL自然会出现404错误。您需要将old-releases.ubuntu.com替换为逻辑上的内容,例如archive.ubuntu.com(或适用于您所在地区的内容)。 - matigo
这个回答解决了你的问题吗?*在Ubuntu 20.04上使用Sudo apt-get update时出现错误* - N0rbert
你还记得是谁以及为什么将“archive”更改为“old-releases”来支持20.04 LTS(focal)版本吗?无论是team-gcc-arm-embedded还是~terry.guo都没有为20.04提供软件包,你需要禁用它们。 - N0rbert
@N0rbert 很明显他们使用了sed命令,从旧版本升级到了20.04。所以,可能他们之前使用的是17.04,并在他们的sources.list中将代号替换为focal。 - Error404
我不知道,但我的朋友们也遇到了同样的问题,尽管他们使用的是不同版本的Ubuntu(16.04、18.04、20.04)。这个问题是由地区引起的吗? - gogogo
@gogogo 你试过我的答案了吗?现在apt update的结果是什么? - Error404
1我执行了以下命令,得到了以下输出结果: 命中:1 http://archive.ubuntu.com/ubuntu focal InRelease 命中:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease 命中:3 http://archive.ubuntu.com/ubuntu focal-security InRelease 命中:4 http://archive.canonical.com/ubuntu focal InRelease 命中:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease 正在读取软件包列表... 完成 - gogogo
1@gogogo 太好了!问题似乎已经解决了。你可以运行 sudo apt update 来查找可升级的软件包。 - Error404
5这个回答解决了您的问题吗?如何在使用PPA或更新软件包列表时修复404错误? - muru
你可以使用http://old-releases.ubuntu.com/ubuntu来获取旧版本。 - Ajouve
1个回答

大部分在您的sources.list中的存储库和PPA已不再可用,并且会出现错误。我建议您恢复默认的存储库。
首先,使用以下命令恢复默认软件源:
``` mkdir ~/solution cd ~/solution/
cat << EOF > ~/solution/sources.list deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb http://archive.canonical.com/ubuntu focal partner deb-src http://archive.canonical.com/ubuntu focal partner EOF
sudo sed -i "s/focal/$(lsb_release -c -s)/" ~/solution/sources.list sudo rm /etc/apt/sources.list sudo cp ~/solution/sources.list /etc/apt/sources.list ```
然后,删除系统中的所有PPA:
``` sudo mv /etc/apt/sources.list.d/* ~/solution ```
更新软件源:
``` sudo apt update ```
现在不应该有任何错误。

2太棒了!终于在尝试了将近两个小时后解决了问题。非常感谢你! - supersan
1愿上帝保佑你:)) - Farhad