侧边栏壁纸
  • 累计撰写 37 篇文章
  • 累计创建 4 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Ubuntu 22.04 换源实用教程:让更新速度起飞!

陳小航
2025-10-30 / 0 评论 / 0 点赞 / 7 阅读 / 0 字 / 正在检测是否收录...
温馨提示:
部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

扫码_搜索联合传播样式-标准色版.png
前言

本教程适用于 Ubuntu 22.04 及之后版本 的系统。

Ubuntu 系统默认使用的官方源(archive.ubuntu.com)通常位于国外,国内访问时延迟高、带宽受限,常常导致软件更新速度极慢,甚至直接失败。

更换为国内镜像源不仅能让 apt updateapt upgrade 的速度提升数倍,还能大幅提升系统更新的稳定性。

国内常用的 Ubuntu 镜像源包括:

  • 🟢 阿里云(Aliyun)

  • 🟣 清华大学(TUNA)

  • 🟠 中国科学技术大学(USTC)

  • 🔵 网易(163)

  • 🟡 华为云(Huawei Cloud)

本文将以 阿里云源 为示例,并提供其他源的配置作为参考。


一、查看系统版本

先确认你当前的 Ubuntu 版本代号(如 jammy、focal):

lsb_release -a

示例输出:

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

⚠️ 注意:
Codename(版本代号)是选择镜像源配置的关键,例如:

  • Ubuntu 22.04 → jammy

  • Ubuntu 20.04 → focal

  • Ubuntu 18.04 → bionic


二、备份旧源文件

在修改前务必备份原有源文件,以防出现问题可快速恢复:

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

三、编辑源列表

使用文本编辑器打开源文件(推荐使用 nano):

sudo nano /etc/apt/sources.list

清空文件内容,然后根据系统版本选择对应的源配置粘贴进去。


国内镜像源配置模板


✅ 阿里云镜像源(推荐)

Ubuntu 22.04(Jammy Jellyfish)

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

Ubuntu 20.04(Focal Fossa)

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

✅ 清华大学镜像源(TUNA)

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

✅ 中国科学技术大学镜像源(USTC)

deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

✅ 网易镜像源(163)

deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
# deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse

✅ 华为云镜像源(Huawei Cloud)

deb https://repo.huaweicloud.com/ubuntu/ jammy main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu/ jammy-updates main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu/ jammy-backports main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu/ jammy-security main restricted universe multiverse
# deb https://repo.huaweicloud.com/ubuntu/ jammy-proposed main restricted universe multiverse

四、更新软件包索引

保存修改并退出编辑器(nano 下为 Ctrl+O → 回车 → Ctrl+X),然后更新软件包索引:

sudo apt update

若要同时更新系统软件,可执行:

sudo apt upgrade -y

五、验证换源结果

若在更新过程中输出中出现 mirrors.aliyun.commirrors.tuna.tsinghua.edu.cn 等字样,且无报错,即表示换源成功。
可以尝试安装一个包来验证下载速度:

sudo apt install htop -y

六、恢复默认源(可选)

若更换后出现问题,可随时恢复官方源:

sudo mv /etc/apt/sources.list.bak /etc/apt/sources.list
sudo apt update

七、附加小技巧

  • 🧠 想切换不同源?只需替换 URL 域名(如 mirrors.aliyun.commirrors.tuna.tsinghua.edu.cn),其他部分保持不变即可。

  • 🚀 如果你有 IPv6 网络,清华源 通常是最快最稳定的。

  • 🧩 对于云服务器(如阿里云、腾讯云),建议优先使用同平台提供的镜像源以获得最佳速度。


✅ 总结

更换国内镜像源是 Ubuntu 优化中最简单且最有效的操作之一。
只需几步,就能让 apt update 速度从几分钟提升到几秒。

换源之后,你的系统更新、软件安装体验都会大幅提升 —— 真正做到 “让更新速度起飞”!

0

评论区