当执行sudo apt-get update或者sudo apt-get install命令时,出现以下两个问题:
“apt-get 404 Not Found Package Repository Errors” 和 “E: Some index files failed to download They have been ignored, or old ones used”
解决方法:
首先,我们将现在出问题的 /etc/apt/sources.list 文件备份一份(只是一个好习惯而已!)
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup注: /etc/apt/sources.list 文件 里面存放的是 Linux系统需要的软件源的网站。
接着,我们重新编写一个 /etc/apt/sources.list 文件:
sudo gedit /etc/apt/sources.list
将下面的模板内容,复制粘贴到 /etc/apt/sources.list 文件(此时保证该文件是空的!!!)里面,然后保存。(我们使用的Ubuntu 16.04)
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse deb http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse ##测试版源 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse # 源码 deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse ##测试版源 deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
此时可以打开系统设置System Settings来更换源了。
现在再执行:sudo apt-get update,就不会报错了。
必须注意:如要用于其他版本,把 xenial 换成相应版本代号就好。可自行在网上搜索其他版本的模板!
参考链接:https://blog.csdn.net/github_35160620/article/details/52115542
原文地址:https://www.cnblogs.com/skzxc/p/10817362.html
时间: 2024-10-09 20:46:25