问题
Debian 断网安装后无法通过 APT 安装软件包,原因是没有为包管理器添加网络软件源,可以编辑软件源配置文件进行添加。
如果服务器在国内,官方的 APT 源可能会导致下载软件速度慢,也可以参照下方的方法解决。
操作步骤
1.通过 SSH 客户端连接服务器
建议使用 root 用户登录,使用非 root 用户执行下面的命令需要在前面添加 sudo 提权。
2.修改 apt 软件源配置文件
nano /etc/apt/sources.list
3.删除或注释默认的软件源配置
4.根据系统版本添加软件源配置
# Debian 11(官方软件源)
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://deb.debian.org/debian/ bullseye main contrib non-free
#deb-src https://deb.debian.org/debian/ bullseye main contrib non-free
deb https://deb.debian.org/debian/ bullseye-updates main contrib non-free
#deb-src https://deb.debian.org/debian/ bullseye-updates main contrib non-free
deb https://deb.debian.org/debian/ bullseye-backports main contrib non-free
#deb-src https://deb.debian.org/debian/ bullseye-backports main contrib non-free
deb https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
#deb-src https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
# Debian 11(清华大学开源软件镜像站-服务器在国内使用)
# 默认注释了源码镜像以提高 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-free
deb 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-free
deb 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-free
deb 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
# Debian 12(官方软件源)
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
#deb-src https://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb https://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
#deb-src https://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
#deb-src https://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
#deb-src https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
# Debian 12(清华大学开源软件镜像站-服务器在国内使用)
# 默认注释了源码镜像以提高 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-firmware
deb 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-firmware
deb 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-firmware
deb 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
5.更新软件源列表
apt update
6.新系统建议安装常用工具
apt install -y sudo wget curl unzip bash-completion net-tools dnsutils