Linux Ubuntu更换阿里源
Linux版本:Ubuntu 20.04
1、在同路径下备份源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bat
2、查看版本代号
lsb_release -c
每个版本的代号是不一样的,比如:
Ubuntu 15.04 代号为:vivid
Ubuntu 16.04代号为:xenial
Ubuntu 17.04代号为:zesty
Ubuntu 18.04代号为:bionic
Ubuntu 19.04代号为:disco
Ubuntu 20.04代号为:focal
3、打开sources.list
sudo vim /etc/apt/sources.list
如果提示:sudu vim: command not found,说明未安装vim编辑器,使用如下命令安装:
sudo vim apt-get install vim
开始编辑文件,先把原有内容注释,添加如下内容:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
保存,并退出。
第二种编辑方式:
在终端输入sudo gedit /etc/apt/sources.list
4、更新软件列表
sudo apt-get update
5、更新软件包
sudo apt-get upgrade
更新完后apt源已经成功修改为阿里源了。