Ubuntu之apt源sources.list
備份官方的預設源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
第三方源
- 清華源:
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
- 中科大源:
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted deb http://mirrors.ustc.edu.cn/ubuntu/ precise universe deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise universe deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe deb http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu precise-security main restricted deb-src http://security.ubuntu.com/ubuntu precise-security main restricted deb http://security.ubuntu.com/ubuntu precise-security universe deb-src http://security.ubuntu.com/ubuntu precise-security universe deb http://security.ubuntu.com/ubuntu precise-security multiverse deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
- 搜狐源
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted deb http://mirrors.sohu.com/ubuntu/ precise universe deb-src http://mirrors.sohu.com/ubuntu/ precise universe deb http://mirrors.sohu.com/ubuntu/ precise-updates universe deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe deb http://mirrors.sohu.com/ubuntu/ precise multiverse deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
- 網易源
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted deb http://mirrors.163.com/ubuntu/ precise universe deb-src http://mirrors.163.com/ubuntu/ precise universe deb http://mirrors.163.com/ubuntu/ precise-updates universe deb-src http://mirrors.163.com/ubuntu/ precise-updates universe deb http://mirrors.163.com/ubuntu/ precise multiverse deb-src http://mirrors.163.com/ubuntu/ precise multiverse deb http://mirrors.163.com/ubuntu/ precise-updates multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
- 阿里雲
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
附加ubuntu源:
deb http://cn.archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-proposed main multiverse restricted universe
替換
cp sources.list.qinghua sources.list
檢視新版本資訊
其實Ubuntu18.04版之前的任一版更改apt源為國內源方法早就有了,內容大同小異,我們應當掌握其規律了,其實每一版內容不同的地方就是版本號(或者官方一點的說:系統代號),所以我們先了解下新版本的系統代號:
使用如下命令:
lsb_release -c
得到本系統的系統代號,如下圖所示:
我們可以看到新版本的Ubuntu系統代號為bionic
apt安裝源時用的系統各異
同樣的我們也可以得到之前任意版本的系統代號:
Ubuntu 12.04 (LTS)代號為precise。
Ubuntu 14.04 (LTS)代號為trusty。
Ubuntu 15.04 代號為vivid。
Ubuntu 15.10 代號為wily。
Ubuntu 16.04 (LTS)代號為xenial。
所以這也就解釋了為什麼我們百度出來的那麼多方案裡面內容不盡相同的原因,因為他們更改apt安裝源時用的系統不一樣。
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
值得注意的是sources.list檔案的條目都是有格式的(通過上面的內容大家也看的出來),一般有如下形式
deb http://site.example.com/debian distribution component1 component2 component3
deb-src http://site.example.com/debian distribution component1 component2 component3
所以後面幾個引數是對軟體包的分類(Ubuntu下是main, restricted,universe ,multiverse這四個)
所以你把內容寫成
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse
之類的也是可以的,之前我有這個疑惑,所以在這裡一併告知和我有一樣疑惑的朋友。
更新軟體列表
執行如下命令:
sudo apt-get update
更新軟體包
執行如下命令:
sudo apt-get upgrade
關於sudo apt-get update與sudo apt-get upgrade有什麼區別,推薦一篇博文,一看就懂
https://blog.csdn.net/beckeyloveyou/article/details/51352426
同時我借鑑了博友少部分博文,地址如下
https://blog.csdn.net/zhangjiahao14/article/details/80554616