什麼是Ubuntu的軟件源?ubuntu
咱們在使用Debian或者Ubuntu的apt-get工具來安裝須要的軟件時,其實就是從服務器獲取須要安裝的軟件並把它安裝在本地計算機的過程。所謂的軟件源,就是咱們獲取軟件的來源,它是定義在/etc/apt/sources.list文件裏的。服務器
官方的默認源是來自美國的us.archive.ubuntu.com和security.ubuntu.com。那麼咱們怎麼樣換成速度更快的國內源呢?很簡單,把/etc/apt/sources.list文件複製備份一下,而後把原來的內容修改爲國內源的網址便可。如下步驟說明以阿里雲的源爲例:工具
一、複製備份原來的配置文件測試
sudo cp /etc/apt/sources.list sources.list.bak
二、替換源阿里雲
阿里雲源的文件spa
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##測試版源 deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse # 源碼 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##測試版源 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse # Canonical 合做夥伴和附加 deb http://archive.canonical.com/ubuntu/ xenial partner deb http://extras.ubuntu.com/ubuntu/ xenial main
也能夠替換爲網易的源rest
deb http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse
執行apt-get update,apt-get upgradecode
若是是添加的網易源,可能會發現會報錯,apt-get: Could not resolve 'mirrors.163.com’的錯誤,這種緣由實際上是由於還缺乏一個步驟,就是將添加的網址和IP進行映射,修改/etc/目錄下的host文件。blog
經過ip.chinaz.com進行查詢網址「mirrors.163.com」,對應的ip地址以下所示,而後將其添加到hosts文件裏。ip
123.58.190.228 mirrors.163.com 123.58.190.236 mirrors.163.com
再執行apt-get update,apt-get upgrade就行了