备份原始源文件source.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak
一般情况下,将 /etc/apt/sources.list 文件中 Ubuntu 默认的源地址 http://archive.ubuntu.com/ 替换为 http://mirrors.ustc.edu.cn/ 即可。
可以使用如下命令:
sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sed -i 's/http:/https:/g' /etc/apt/sources.list
如果换源后出现错误 Certificate verification failed: The certificate is NOT trusted.
# 将其中的 https 暂时改成http
sed -i 's/https:/http:/g' /etc/apt/sources.list
#重新安装两个组件
apt-get reinstall apt-transport-https ca-certificates
再次修改回HTTPS方式