ubuntu sudo apt-get update 失败 解决方法
时间:2016-05-15 21:21:34
收藏:0
阅读:1154
sudo apt-get update
报了一堆错误:
Err http://cn.archive.ubuntu.com trusty InRelease Err http://cn.archive.ubuntu.com trusty-updates InRelease Err http://cn.archive.ubuntu.com trusty-backports InRelease Err http://cn.archive.ubuntu.com trusty Release.gpg W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/trusty/InRelease
错误显示了源有问题,好像是被墙了。
查找解决办法,修改/etc/apt/source.list文件。将源改成163的或者阿里的:
deb http://mirrors.163.com/ubuntu/ vivid main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-backports main restricted universe multiverse
但是source.list文件是只读的,修改不了。
要使用sudo gedit /etc/apt/source.list修改,但是gedit 指令没有装,使用sudo apt-get install gedit又安装不了。
解决办法:(修改DNS)
修改dns:
sudo vi /etc/resolvconf/resolv.conf.d/base
在里面插入:
nameserver 8.8.8.8
nameserver 8.8.4.4
修改好保存!wq,
然后执行
sudo resolvconf -u
再看/etc/resolv.conf,最下面就多了2行:
cat /etc/resolv.conf
显示
# 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
此时执行
sudo apt-get update
可以运行,然后就可以使用sudo apt-get install **指令了。
评论(0)