写在前面:安装好ubuntu双系统后,默认的软件更新源是国外的,在国内使用速度很慢,用"apt install xxx"安装软件时可能出现"网络不可达"、"你的网络需要认证吗"、"无法定位软件包"等错误,所以我们需要更换成国内的源,这样才能正常安装和更新软件。
下面这些是国内主要的镜像源网站。
———————————————————————
阿里源 https://developer.aliyun.com/mirror/
清华源 https://mirrors.tuna.tsinghua.edu.cn/
中科大源 http://mirrors.ustc.edu.cn/
网易源 http://mirrors.163.com/
———————————————————————
1.备份原始源文件source.list
打开终端,执行命令:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.修改源文件sources.list
(1)终端执行命令:sudo chmod 777 /etc/apt/sources.list 更改文件权限使其可编辑;
(2)执行命令: sudo gedit /etc/apt/sources.list 打开文件进行编辑;
(3)删除原来的文件内容,根据系统版本复制下面的任意一个到其中并保存(常用的是阿里源和清华源,推荐阿里源);
阿里源:
ubuntu 16
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
unbuntu 18
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
ubuntu 20
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
3.更新源
终端执行命令:
sudo apt update。 更新软件列表,换源完成。update 是同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
复损坏的软件包,尝试卸载出错的包,重新安装正确版本的 sudo apt-get install -f
更新软件 sudo apt-get upgrade。 upgrade 是升级已安装的所有软件包,升级之后的版本就是本地索引里的,因此,在执行 upgrade 之前一定要执行 update, 这样才能是最新的。
二、其他换源方法
还有一种更简单的方法,打开"软件更新器",依次点击"设置","Ubuntu软件",在"下载自"后面的窗口选择 "其它站点"在其中找到清华大学镜像站选择即可。
修改完软件源后,更新软件列表和软件
sudo apt update
sudo apt upgrade
如果在软件更新器里修改源,会自动刷新软件列表并检查更新,依据向导来即可。
参考博文:ubuntu更换国内源_EmbededCoder的博客-CSDN博客_ubuntu换源