Ubuntu20.04更换软件源
一、参考网址:
https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.52901b11Xsy9XH
二、具体步骤
1:lsb_release -a,获取codename
2:进入/etc/apt目录下
3:备份sources.list
cp sources.list sources.lis.bak
4:修改系统源
sudo vi sources.list
清除原文件所有内容并添加以下内容:注意,每一行的trusty应该用第一步查看得到的Codename来代替,如我的系统查到的是focal
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
5: 保存并且sudo apt update,更新成功
三、快速更换系统源
新建脚本并添加以下内容:
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 apt-get update
sudo运行该脚本即可(注意运行之前最好备份之前的sources.list)