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版本。

相关推荐
码农小白猿12 分钟前
IACheck优化电梯定期检验报告:自动化术语审核提升合规性与效率
大数据·运维·人工智能·ai·自动化·iacheck
huoxingwen13 分钟前
Ubuntu 22.04 上 VMware Workstation 点击虚拟机窗口就消失的解决历程
linux·运维·ubuntu
姚青&32 分钟前
Linux 常用命令之基本命令
linux·运维·服务器
一路往蓝-Anbo34 分钟前
【第05期】数据的微观世界 (五) —— 浮点数 vs 定点数:MCU的数学课
linux·stm32·单片机·嵌入式硬件·物联网
G_H_S_3_36 分钟前
【网络运维】企业级监控平台Zabbix:部署与实践指南
linux·运维·网络·zabbix
小周学学学40 分钟前
Vcenter Auto Deploy安装与使用
linux·运维·服务器
微爱帮监所写信寄信1 小时前
微爱帮监狱写信寄信工具服务器【Linux篇章】再续:TCP协议——用技术隐喻重构网络世界的底层逻辑
linux·服务器·开发语言·网络·网络协议·小程序·监狱寄信
VekiSon1 小时前
Linux网络编程——IO多路复用
linux·运维·网络
wei20231 小时前
Ubuntu24.04 搜狗输入法 闪烁无法输入问题解决
ubuntu·搜索引擎
乐维_lwops2 小时前
IT运维的核心目标和主要工作内容
运维·网络·it运维