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

相关推荐
ylmzfun1 小时前
基于Ansible的自动化运维实战:从入门到企业级应用
运维·架构·ansible
轻颂呀1 小时前
TCP协议
linux·网络·网络协议·tcp/ip
知识分享小能手1 小时前
CentOS Stream 9入门学习教程,从入门到精通,CentOS Stream 9 用户和组管理 —语法详解与实战案例(6)
linux·学习·centos
未来之窗软件服务1 小时前
服务器运维(十八)国产化数据库服务漏洞安全——东方仙盟炼气期
运维·服务器·数据库·服务器运维
松涛和鸣1 小时前
25、数据结构:树与二叉树的概念、特性及递归实现
linux·开发语言·网络·数据结构·算法
Deng8723473481 小时前
自动化极验3点选验证码的识别与验证方案
运维·python·自动化
runfarther2 小时前
mysql_mcp_server部署及应用案例
linux·mysql·centos·mcp
爱吃番茄鼠骗2 小时前
Linux操作系统———信号量
linux
灰勒塔德2 小时前
jetson orin nano super开发指南
linux·服务器·python