1.备份原来的sources.list。
源文件。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.修改sources.list文件内容。
sudo nano /etc/apt/sources.list
按CTRL+K删除所有行。
然后粘贴阿里云mirrors官网的对应Ubuntu版本的镜像地址列表
我的版本是Ubuntu 20.04,镜像地址列表是:
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-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed 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
按CTRL+O保存,CTRL+X退出nano。
3.更新源和更新软件
sudo apt-get update #更新源 sudo apt-get upgrade #更新软件
搞定。