在Ubuntu中更换软件包管理器的镜像源可以提高下载速度并且确保安全性。
1、打开终端(Ctrl+Alt+T)。
2、编辑/etc/apt/sources.list文件,使用任何文本编辑器进行修改。比如,我们将默认的官方源更换为清华大学的源:
sudo nano /etc/apt/sources.list
3、注释或删除原有的源地址,添加新的源地址。对于清华大学的源,可以参考以下内容:
Ubuntu 20.04 LTS (Focal Fossa):
# 默认源
deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
# 清华大学源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
Ubuntu 18.04 LTS (Bionic Beaver):
# 默认源
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
# 清华大学源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
这里只列了部分常用版本的源地址,其他版本也类似。根据自己的需求选择合适的源地址。
4、按下"Ctrl + X"组合键来保存并关闭文件。
5、运行以下命令来更新软件包索引:
sudo apt update
6、完成后,系统会从新的源获取最新的软件包信息。
7、现在你就可以通过
sudo apt upgrade
等命令来更新、安装或移除
版权归原作者 tu头cai狗 所有, 如有侵权,请联系我们删除。