1. 程式人生 > 其它 >Linux(Ubuntu 18)之更改apt源為阿里雲源(二)

Linux(Ubuntu 18)之更改apt源為阿里雲源(二)

技術標籤:linuxlinux

Ubuntu 18 更換源

1. 複製原始檔備份,以防萬一

sources.list是包管理工具apt所用的記錄軟體包倉庫位置的配置檔案,同樣型別的還有位於 同目錄下sources.list.d檔案下的各種.list字尾的各檔案。

我們要修改的檔案是sources.list,它在目錄/etc/apt/下,

命令如下:

1、進入對應目錄

cd /etc/apt/

2、先進行檔案的拷貝,以訪萬一

sudo cp sources.list sources.list.bak

2、檢視版本資訊

Ubuntu18.04版之前的任一版更改apt源為國內源方法早就有了,內容大同小異,主要就是不同版本的系統程式碼不同導致增加的東西不同,所以我們需要檢視一下版本的資訊,然後直接套規律即可

使用如下命令:

lsb_release -c

得到本系統的系統代號,如下圖所示:
在這裡插入圖片描述
我們可以看到新版本的Ubuntu系統代號為bionic

Ubuntu不同版本的系統代號如下:

Ubuntu 12.04 (LTS)代號為precise。

Ubuntu 14.04 (LTS)代號為trusty。

Ubuntu 15.04 代號為vivid。

Ubuntu 15.10 代號為wily。

Ubuntu 16.04 (LTS)代號為xenial。

3、更改內容

1、編輯該檔案

sudo vim source.list

2、若沒有vim,安裝即可

sudo apt-get install vim 

3.將原有的內容註釋掉,新增以下內容(或者你把裡面內容修改成下面的就可以,但是不能有除了以下內容的有效內容)

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這四個)