Ubuntu 使用 apt-get命令失效,Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease
阿新 • • 發佈:2019-02-05
樓主的是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命令成功。
如果更換源後沒有成功的小夥伴們可以試試上面這個方法~