楼主的是Ubuntu14.04版本,其它版本应该也适用,在使用apt-get update时出现以下错误:
Err http://mirrors.aliyun.com trusty InRelease
Err http://mirrors.aliyun.com trusty-updates InRelease
Err http://mirrors.aliyun.com trusty-backports InRelease
Err http://mirrors.aliyun.com trusty-security InRelease
Err http://mirrors.aliyun.com trusty Release.gpg
Could not resolve 'mirrors.aliyun.com'
Err http://mirrors.aliyun.com trusty-updates Release.gpg
Could not resolve 'mirrors.aliyun.com'
Err http://mirrors.aliyun.com trusty-backports Release.gpg
Could not resolve 'mirrors.aliyun.com'
Err http://mirrors.aliyun.com trusty-security Release.gpg
Could not resolve 'mirrors.aliyun.com'
Reading package lists... Done
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/trusty/InRelease
网上说更换源就好了(sources.list文件),但楼主几乎试了所有的源……依旧不好使。
后来看了一篇博客,有了方向,原来我们需要更新DNS,步骤如下:
sudo vi /etc/resolvconf/resolv.conf.d/base
在里面插入:
nameserver 8.8.8.8
nameserver 8.8.4.4
保存退出
然后执行
sudo resolvconf -u
再看/etc/resolv.conf:
cat /etc/resolv.conf
可以看见最下面就多了2行:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
此时,执行apt-get update命令成功。
如果更换源后没有成功的小伙伴们可以试试上面这个方法~