一、备份现有apt源配置
cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
二、替换为其他apt源
Debian11
1、清华源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main contrib non-free
EOF
2、中科大源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-freedeb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
EOF
3、腾讯云源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.tencent.com/debian bullseye main contrib non-free
# deb-src http://mirrors.tencent.com/debian bullseye main contrib non-freedeb http://mirrors.tencent.com/debian bullseye-updates main contrib non-free
# deb-src http://mirrors.tencent.com/debian bullseye-updates main contrib non-freedeb http://mirrors.tencent.com/debian bullseye-backports main contrib non-free
# deb-src http://mirrors.tencent.com/debian bullseye-backports main contrib non-freedeb http://mirrors.tencent.com/debian-security bullseye-security main contrib non-free
# deb-src http://mirrors.tencent.com/debian-security bullseye-security main contrib non-free
EOF
4、阿里云源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.aliyun.com/debian/ bullseye main contrib non-free
# deb-src https://mirrors.aliyun.com/debian/ bullseye main contrib non-freedeb https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-freedeb https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-freedeb https://mirrors.aliyun.com/debian-security/ bullseye-security main contrib non-free
# deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main contrib non-free
EOF
5、华为源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.huaweicloud.com/debian/ bullseye main contrib non-free
# deb-src https://mirrors.huaweicloud.com/debian/ bullseye main contrib non-freedeb https://mirrors.huaweicloud.com/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main contrib non-freedeb https://mirrors.huaweicloud.com/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main contrib non-freedeb https://mirrors.huaweicloud.com/debian-security/ bullseye-security main contrib non-free
# deb-src https://mirrors.huaweicloud.com/debian-security/ bullseye-security main contrib non-free
EOF
6、网易源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.163.com/debian/ bullseye main non-free contrib
# deb-src https://mirrors.163.com/debian/ bullseye main non-free contribdeb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
# deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contribdeb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib
# deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contribdeb https://mirrors.163.com/debian-security/ bullseye-security main contrib non-free
# deb-src https://mirrors.163.com/debian-security/ bullseye-security main contrib non-free
EOF
Debian12
1、清华源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmwaredeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmwaredeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmwaredeb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
2、中科大源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmwaredeb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmwaredeb http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmwaredeb http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
EOF
3、腾讯云源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
# deb-src https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contribdeb https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
# deb-src https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contribdeb https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
# deb-src https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contribdeb https://mirrors.tencent.com/debian-security/ bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tencent.com/debian-security/ bookworm-security main contrib non-free non-free-firmware
EOF
4、阿里云源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
# deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contribdeb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
# deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contribdeb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
# deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contribdeb https://mirrors.aliyun.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
# deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
EOF
5、华为源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
# deb-src https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contribdeb https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
# deb-src https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contribdeb https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
# deb-src https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contribdeb https://mirrors.huaweicloud.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
# deb-src https://mirrors.huaweicloud.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
EOF
6、网易源
这是一条命令,全部复制后,直接粘贴然后一起执行。
cat > /etc/apt/sources.list << EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
# deb-src https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contribdeb https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
# deb-src https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contribdeb https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
# deb-src https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contribdeb https://mirrors.163.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
# deb-src https://mirrors.163.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
EOF
三、更新apt索引
sudo apt update