![在 ubuntu server 14.04 LTS 中更新和安装包时出错](https://linux22.com/image/990486/%E5%9C%A8%20ubuntu%20server%2014.04%20LTS%20%E4%B8%AD%E6%9B%B4%E6%96%B0%E5%92%8C%E5%AE%89%E8%A3%85%E5%8C%85%E6%97%B6%E5%87%BA%E9%94%99.png)
我是 Linux 新手。我尝试在 Ubuntu Server 14.04 LTS 中更新和安装一些软件包,但显示错误。我在这个网站上看到了很多相同的问题,但无法解决问题,为什么问这个问题。
更新时出错:
$ sudo apt-get update
Err http://security.ubuntu.com trusty-security InRelease
Err http://archive.canonical.com trusty InRelease
Err http://extras.ubuntu.com trusty InRelease
Err http://archive.canonical.com trusty Release.gpg
Could not resolve 'archive.canonical.com'
Err http://extras.ubuntu.com trusty Release.gpg
Could not resolve 'extras.ubuntu.com'
Err http://security.ubuntu.com trusty-security Release.gpg
Could not resolve 'security.ubuntu.com'
Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty-backports InRelease
Err http://archive.ubuntu.com trusty Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-backports Release.gpg
Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'archive.canonical.com'
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'extras.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
安装包时出错
$ apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package apache2
答案1
请在终端中运行以下命令。nslookup。然后,运行以下命令查看服务器 DNS 是否能够解析
服务器
如果服务器 DNS 解析正确,则说明存在其他问题。
退出 nslookup
或者,也许是另一个问题。
清理缓存:
sudo apt-cache gencache
man apt-cache
gencaches 创建 APT 的软件包缓存。如果缓存缺失或过期,所有需要此缓存的命令都会隐式执行此操作。