在 Ubuntu 24.04 上执行更新时,可能会遇到卡在 “0% [Waiting for headers]” 的情况,例如:
Get:61 https://mirrors.ustc.edu.cn/ubuntu noble-security/multiverse Translation-en [4,288 B]
Get:62 https://mirrors.ustc.edu.cn/ubuntu noble-security/multiverse amd64 Components [208 B]
Get:63 https://mirrors.ustc.edu.cn/ubuntu noble-security/multiverse amd64 c-n-f Metadata [380 B]
Ign:64 http://security.ubuntu.com/ubuntu noble-security InRelease
Ign:65 http://cn.archive.ubuntu.com/ubuntu noble InRelease
0% [Waiting for headers] [Waiting for headers]
^C
这个问题通常是由无效源 / 第三方源挂起导致的。以下步骤可彻底解决问题。
✔ 解决步骤:彻底清理并重建 APT 源
1. 删除 /etc/apt/sources.list.d 中的第三方源
查看已有源:
ls /etc/apt/sources.list.d/
你可能会看到类似:
docker.list ← Docker 第三方源,常导致卡顿
ubuntu-security.list ← Ubuntu 24.04 新格式源
ubuntu.sources.curtin.orig ← 安装器生成的备份,不影响
创建备份、移除所有源:
sudo mkdir -p /etc/apt/sources.list.d/backup
sudo mv /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/backup/
移除 Ubuntu 新格式源(随后再恢复):
sudo mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/backup/
恢复官方源(可选):
sudo mv /etc/apt/sources.list.d/backup/ubuntu.sources /etc/apt/sources.list.d/
2. 重写主系统源 /etc/apt/sources.list
使用中科大源(适用于 Ubuntu 24.04 noble):
sudo bash -c 'cat > /etc/apt/sources.list' <<EOF
deb https://mirrors.ustc.edu.cn/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ noble-security main restricted universe multiverse
EOF
3. 清理缓存并重新更新
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
🎉 完成
到这里,APT 的所有无效缓存和源都已被清理,你的 apt update 应该会恢复正常速度。








