ubantu學習之更改apt源

1.獲取版本codename

sudo lsb_release -a

2.確認阿里源支持

傳送門地址
注:該網頁提供了阿里雲支持的ubuntu系統下各個Codename版本shell

3.備份系統源文件

sudo cp /etc/apt/sources.list    /etc/apt/sources.list.bak

4.將阿里雲源提供的源裏的bionic替換成本身版本的codename,下面提供腳本,複製運行便可

Codename=$( (lsb_release -a)|awk '{print $2}'|tail -n 1 )
echo "\
deb http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe " >sources.list

5.更新源索引

sudo  apt-get update

6.更新軟件升級

sudo apt-get upgrade
相關文章
相關標籤/搜索