Ubuntu 24.04 LTS 使用清华大学的 Ubuntu 镜像源以加速下载和更新操作

Ubuntu 软件仓库地址:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

在 Ubuntu 24.04 之前,Ubuntu 的软件源配置文件使用传统的 One-Line-Style,路径为 /etc/apt/sources.list;从 Ubuntu 24.04 开始,Ubuntu 的软件源配置文件变更为 DEB822 格式,路径为 /etc/apt/sources.list.d/ubuntu.sources

我正在使用什么版本的 Ubuntu?

可以通过以下命令查看当前系统版本:

复制代码
cat /etc/os-release

例如在 Ubuntu 24.04 下,文件内容如下:

复制代码
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

VERSION_ID 后面的版本号即为当前系统版本,VERSION_CODENAME 后面的是代号。代号在软件源配置文件中会被使用。请注意在下面的配置中选择符合你的机器的版本号,在替换配置前确认代号一致,否则之后的更新操作可能导致系统出现问题。

配置内容

将系统自带的对应文件做个备份,然后根据格式的选择下面对应的内容替换,即可使用选择的软件源镜像。

传统格式(/etc/apt/sources.list

Ubuntu 版本 Ubuntu 24.04LTS

复制代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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 multiverse
deb 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 multiverse
deb 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 multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse

DEB822 格式(/etc/apt/sources.list.d/ubuntu.sources

Ubuntu 版本 Ubuntu 24.04LTS

复制代码
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# Suites: noble noble-updates noble-backports
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# Types: deb-src
# URIs: http://security.ubuntu.com/ubuntu/
# Suites: noble-security
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 预发布软件源,不建议启用

# Types: deb
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# Suites: noble-proposed
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# # Types: deb-src
# # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# # Suites: noble-proposed
# # Components: main restricted universe multiverse
# # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

因镜像站同步有延迟,可能会导致生产环境系统不能及时检查、安装上最新的安全更新,不建议替换 security 源。

建议还是去第一行官网查看配置,那里可以选择不同Ubuntu版本。

相关推荐
Sarvartha17 小时前
三目运算符
linux·服务器·前端
liangdabiao17 小时前
乐高摩托车深度报告-致敬张雪夺冠 -基于llm-wiki技术自动化写文章的效果
运维·人工智能·自动化
vortex518 小时前
Kali Linux 安装与使用 Code-OSS / VSCodium :VSCode 轻量替代
linux·运维·编辑器
GuokLiu18 小时前
260502-Clawith-Docker安装过程
运维·docker·容器·claw
.柒宇.18 小时前
AI掘金头条项目部署实践指南
linux·运维·python·fastapi
budingxiaomoli18 小时前
多机部署,负载均衡-LoadBalancer
运维·spring cloud·负载均衡
JesseDev19 小时前
Docker lnmp环境快速搭建开箱即用
运维·docker·容器
zhangrelay19 小时前
Ubuntu 18.04 经典 / 有趣 / 实用 APT 软件清单
linux·笔记·学习·ubuntu
金牛IT19 小时前
Gogs 轻量级 Git 服务器搭建与使用
运维·服务器·git
不做无法实现的梦~19 小时前
linux怎么使用正点原子无线dap烧录器
linux·运维·postgresql