当前位置:首页 > 系统教程 > 正文

Ubuntu 20.04 设置国内镜像源教程(阿里源与清华源详细步骤)

Ubuntu 20.04 设置国内镜像源教程(阿里源与清华源详细步骤)

对于使用 Ubuntu 20.04 的用户来说,默认的软件源服务器在国外,下载速度可能很慢。更换为 国内镜像源,如 阿里源清华源,可以显著提升软件包的下载速度。本教程将详细讲解如何为 Ubuntu 20.04 配置这两个常用的国内镜像源,即使是小白也能轻松完成。

Ubuntu 20.04 设置国内镜像源教程(阿里源与清华源详细步骤) 阿里源  清华源 ubuntu20.04 国内镜像源 第1张

一、备份原有软件源列表

在修改任何系统配置文件前,建议先备份。打开终端(Ctrl+Alt+T),执行以下命令:

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup  

如果以后想恢复,可以使用备份文件。

二、编辑 sources.list 文件

使用文本编辑器(如 vim 或 nano)打开 sources.list 文件:

    sudo vim /etc/apt/sources.list  

或者用 gedit:

    sudo gedit /etc/apt/sources.list  

将文件中的原有内容全部删除或注释掉(在每行前面加 #),然后粘贴下方对应的国内镜像源配置。

三、配置阿里源

阿里源 是阿里巴巴开源镜像站,提供高速稳定的服务。对于 Ubuntu 20.04(Focal Fossa),阿里源配置如下:

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse  

四、配置清华源

清华源(清华大学开源软件镜像站)同样非常可靠。Ubuntu 20.04 的清华源配置如下:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse  

五、更新软件源

保存文件并退出编辑器。然后执行以下命令更新软件包列表:

    sudo apt update  

如果看到所有源都成功获取,说明配置成功。接着可以升级已安装的软件包:

    sudo apt upgrade  

总结

通过以上步骤,你已经成功将 Ubuntu 20.04 的软件源更换为 阿里源清华源。使用 国内镜像源 可以大大加快软件下载速度,提升使用体验。如果在操作中遇到问题,欢迎留言交流。

关键词:阿里源、清华源、ubuntu20.04、国内镜像源