![Apt-get 更新在 Ubuntu 16.04 中不起作用“暂时失败解决”](https://linux22.com/image/891451/Apt-get%20%E6%9B%B4%E6%96%B0%E5%9C%A8%20Ubuntu%2016.04%20%E4%B8%AD%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%E2%80%9C%E6%9A%82%E6%97%B6%E5%A4%B1%E8%B4%A5%E8%A7%A3%E5%86%B3%E2%80%9D.png)
首先,我对 Linux 命令行还不熟悉。我以前从未使用过它。我的问题是该命令apt-get update
只会返回:
Err:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'us.archive.ubuntu.com'
Err:2 http://us.archive.ubuntu.com/ubuntu xenial-security InRelease
Temporary failure resolving 'us.archive.ubuntu.com'
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial/InRelease Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Temporary failure resolving 'us.archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
我的sources.list
文件如下所示:
#------------------------------------------------------------------------------#
# OFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
我的ubuntu版本是:
Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-66-generic x86_64)
答案1
我遇到了同样的问题。问题的核心是无法解析 DNS。我丢失了我的/etc/resolv.conf
文件。
其内容应为:
nameserver 8.8.8.8
nameserver 8.8.4.4
之后,重新启动正确的界面(我的是lo
而不是eth0
)。您可以在文件中找到它/etc/network/interfaces
。
答案2
我遇到了同样的问题,由错误的 DNS 设置引起:
sudo nano /etc/network/interfaces
在此文件中设置正确的 DNS 服务器:dns-nameservers 8.8.8.8
sudo ifdown eth0 && sudo ifup eth0
答案3
我遇到了同样的问题,但错误消息略有不同。这对我有用:
sudo nano /etc/network/interfaces
找到 的行dns-nameserver
。如果没有,请按如下方式添加:
dns-nameserver 208.067.222.222
这是 OpenDNS 的地址。您也可以使用 8.8.8.8,这是 Google Public DNS 的地址。