hoochrel

debain13更改软件源为清华源

原创  linux 2026年09月25日 12:46:35 hoochrel 0评论 9

在 Debian 13 (Trixie) 中将软件源更换为清华源,需要注意配置文件格式可能已经变化。从 Debian 12 开始,新的 DEB822 格式 逐渐成为默认,你需要先确认系统实际使用的是哪个配置文件。

📂 第一步:确认配置文件

Debian 13 可能使用以下两种配置之一,请先查看:

bash

# 查看传统格式文件
cat /etc/apt/sources.list
# 查看新的 DEB822 格式文件
cat /etc/apt/sources.list.d/debian.sources

如果第二个文件存在且内容不为空,说明系统正在使用 DEB822 格式;如果它不存在或为空,则使用 传统格式。

🚀 第二步:更换为清华源

操作前强烈建议先备份原文件:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak(如果使用 DEB822 格式,则备份 /etc/apt/sources.list.d/debian.sources)。

情况 A:使用传统格式(/etc/apt/sources.list)

编辑该文件,用以下内容替换原有源:

bash

sudo nano /etc/apt/sources.list

填入以下内容(trixie 是 Debian 13 的代号):

text

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

说明:安全更新源(security)建议保留官方地址,因为镜像站同步可能存在延迟,官方源能更快获得安全更新。保存后(Ctrl+X,按 Y,再回车)执行 sudo apt update 即可。

情况 B:使用 DEB822 格式(/etc/apt/sources.list.d/debian.sources)

如果你的系统使用这种新格式,需要编辑 .sources 文件:

bash

sudo nano /etc/apt/sources.list.d/debian.sources

将其中的 URIs 字段替换为清华镜像地址。一个完整的示例如下:

yaml

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian/
Suites: trixie trixie-updates trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://security.debian.org/debian-security/
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

如果你希望全部(包括安全更新)都走清华源,可以把第二个 URIs 也改为 https://mirrors.tuna.tsinghua.edu.cn/debian-security/。

💡 几点提醒

  1. 确认版本代号:执行 lsb_release -cs 可以查看你系统的确切代号,确保是 trixie。

  2. 处理 HTTPS 问题:如果更新时提示证书或连接错误,可以尝试将 https:// 临时改为 http:// 测试,或者确保已安装 ca-certificates 包。

  3. 源码仓库(deb-src):上面的配置默认注释了源码仓库以加快 apt update 速度。如果你有编译软件的需求,需要取消注释或手动添加 deb-src 行


评论区

face
😀 😃 😄 😁 😆 😅 🤣 😂 🙂 🙃 😉 😊 😇 🥰 😍 🤩 😘 😗 😙 😋 😛 😜 🤪 😝 🤑 🤗 🤭 🤫 🤔 🤐 🤨 😐 😑 😶 😏 😒 🙄 😬 🤥 😌 😔 😪 🤤 😴 😷 🤒 🤕 🤢 🤮 🤧 🥵 🥶 🥴 😵 🤯 🤠 🥳 😎 🤓 🧐 😕 😟 🙁 ☹️ 😮 😯 😲 😳 🥺 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 😤 😡 😠 🤬 😈 👿 💀 ☠️ ☠ 💩 🤡 👹 👺 👻 👽 👾 🤖 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙈 🙉 🙊 💋 💌 💘 💝 💖 💗 💓 💞 💕 💟 ❣️ ❣ 💔 ❤️ ❤ 🧡 💛 💚 💙 💜 🖤 💯 💢 💥 💫 💦 💨 🕳️ 🕳 💣 💬 👁️‍🗨️ 👁‍🗨️ 👁️‍🗨 👁‍🗨 🗨️ 🗨 🗯️ 🗯 💭 💤 👋
笑脸icon


选择主题