網上有各種換源的方法,但很少提到一些必須要注意的細節,例如到底是哪個版本的源,這裡進行補充說明,并給出具體執行方法以供參考學習。
1、注意事項
ubuntu至今已經釋出30多個版本,目前常見的大部分都是16.04版本和18.04版本。16、18是版本号碼,每個版本又有以動物命名的别稱,而換源時的網址也主要是根據這個别稱決定下載下傳分支的,如下述換源語句中的紅色部分。是以換源,必須要仔細檢查這個别稱,比對自己的Ubuntu版本,否則肯定會出錯誤。
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse --【16.04】
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse --【18.04】
部分版本号與别稱如下(參考了https://blog.csdn.net/zhengmx100/article/details/78352773):

2、換源
國内的源有阿裡雲、中科大、清華、163...的。經過實踐,這裡隻提供阿裡雲的,也避免選擇困難。
-
16.04(即xenial)換源
将/etc/apt中的sources.list檔案中内容全部換為以下内容。并執行 sudo apt-get update ,則換源結束。
另:sudo apt-get update這個指令是将本地的軟體和源網址的軟體版本進行核對;sudo apt-get upgrade是将本地的軟體版本更新為源網站上的最新版本,如果不想對軟體更新隻想換源不用執行該指令。
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-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports 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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
-
18.04(即bionic)換源
将/etc/apt中的sources.list檔案中内容全部換為以下内容。并執行 sudo apt-get update ,則換源結束。
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse