ubuntu sudo apt-get update 失敗 解決方法


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 **指令了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM