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

Ubuntu 24.04更换清华源教程

Ubuntu 24.04更换清华源教程

小白也能轻松学会的国内镜像配置方法

对于使用Ubuntu 24.04的用户来说,默认的软件源服务器在国外,下载速度往往不理想。将系统源更换为清华源(国内镜像之一)可以大幅提升软件包下载速度。本文将手把手教你如何为Ubuntu 24.04更换清华源,即使你是完全不懂命令行的新手也能轻松完成。

Ubuntu 24.04更换清华源教程 24.04  清华源 国内镜像 更换软件源 第1张

第一步:备份原始源列表

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

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

这条命令会将当前的源列表文件复制一份并命名为sources.list.bak,以便日后需要时恢复。

第二步:编辑源列表文件

接下来,我们需要编辑/etc/apt/sources.list文件。使用你喜欢的文本编辑器,例如nano:

    sudo nano /etc/apt/sources.list  

由于该文件需要管理员权限,所以必须加上sudo

第三步:替换为清华源镜像

在打开的编辑器中,删除原有内容,然后复制粘贴以下清华源配置(适用于Ubuntu 24.04 LTS 版本):

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

如果你需要源码包(deb-src),可以将对应行前面的“#”去掉。保存文件(nano中按Ctrl+O,回车,然后Ctrl+X退出)。

第四步:更新软件包列表

源更换完成后,需要运行更新命令使配置生效:

    sudo apt update  

该命令会从新的国内镜像拉取软件包信息,如果速度明显提升,说明更换软件源成功。

第五步:可选升级软件

如果你想将所有已安装的软件升级到最新版本,可以执行:

    sudo apt upgrade  

至此,你已经成功为Ubuntu 24.04配置了清华源。今后安装软件将享受飞一般的下载速度!如果在操作中遇到任何问题,欢迎在评论区留言交流。