sudo apt-get update
返回一些错误:
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/trusty/Release 无法在 Release 文件中找到预期条目“restricted/source/Sources”(错误的 sources.list 条目或格式错误的文件)
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/trusty-security/main/binary-amd64/Packages 哈希值总和不匹配
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/trusty-security/universe/binary-amd64/Packages 哈希值总和不匹配
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/trusty-security/main/binary-i386/Packages 哈希值总和不匹配
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/trusty-security/main/i18n/Translation-en 哈希值不匹配
E:部分索引文件下载失败。它们已被忽略或使用旧文件代替。
这似乎发生在 ubuntu 官方 repo 中。知道原因吗?
供参考,我的 sources.list 如下:
#----------------------------------------------------------#
# OFFICIAL UBUNTU REPO #
#----------------------------------------------------------#
###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
###### Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
###### Ubuntu Extras Repo
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main
#------------------------------------------------------------------------------#
# UNOFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### 3rd Party Binary Repos
#### MongoDB - http://www.mongodb.org/
## Run this command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
答案1
问题可能出在你的 /etc/resolv.conf 文件中,请检查nameserver
它上面是否有一些指令,然后尝试 ping archive.ubuntu.com
这是我的 resolv.conf:
domain local
search local
nameserver 8.8.8.8
nameserver 8.8.4.4
我使用 Google 的公共 DNS(https://developers.google.com/speed/public-dns/)
然后尝试 apt-get update
答案2
它检测到它获取的一些文件已过期或损坏,因此无法使用。删除缓存文件并重rm -rf /var/lib/apt/lists/*
试apt-get update.
如果问题仍然存在,也许某个地方的缓存代理仍然保存着旧的或损坏的内容。apt-get update -o Acquire::http::No-Cache=True
在这种情况下可能会有所帮助。
答案3
尝试本地/最近的 Ubuntu 镜像。我测试了美国 DE FR 镜像,但都失败了。更改为本地镜像解决了问题。
答案4
我遇到了同样的问题,但对我来说,解决这个问题的唯一方法是:
备份你的源列表 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
打开源文件 /etc/apt/sources.list 并将 us.archive 的所有实例重命名为
http://us.archive.ubuntu.com/ubuntu/
到
http://old-releases.ubuntu.com/ubuntu/
然后运行 sudo apt-get update。