先备份原始源,再替换为阿里云源即可。
Ubuntu 26.04(Resolute Raccoon)默认已经使用 .sources 格式,而不是老的 sources.list。
1. 备份原配置
bash
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
2. 编辑镜像源
bash
sudo vim /etc/apt/sources.list.d/ubuntu.sources
将内容替换为:
yaml
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute resolute-updates resolute-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
3. 更新缓存
bash
sudo apt update
4. 验证是否生效
bash
apt policy
或者:
bash
grep -E "mirrors.aliyun.com" /etc/apt/sources.list.d/ubuntu.sources
一键脚本(推荐)
直接执行:
bash
sudo bash -c 'cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute resolute-updates resolute-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF'
sudo apt update