ubantu学习之更改apt源

1.获取版本codename

sudo lsb_release -a

2.确认阿里源支持

传送门地址
注:该网页提供了阿里云支持的ubuntu系统下各个Codename版本

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
posted @ 2019-04-06 11:37  Alive_2020  阅读(438)  评论(0编辑  收藏  举报