这是目前大多数现代 Linux 发行版(使用 systemd 的系统)的标准方法。它会显示名称、版本号和 ID。PRETTY_NAME="Debian GNU/Linux 13 (trixie)"NAME="Debian GNU/Linux"VERSION_ID="13"VERSION="13 (trixie)"VERSION_CODENAME=trixieDEBIAN_VERSION_FULL=13.4ID=debianHOME_URL="https://www.debian.org/"SUPPORT_URL="https://www.debian.org/support"BUG_REPORT_URL="https://bugs.debian.org/
注意了,这里是Debian,和ubuntu还是有点区别的。虽然 Ubuntu 是基于 Debian 构建的,且两者都使用同样的 .deb 软件包格式和 apt 包管理器,但它们在定位、更新节奏和使用体验上有非常显著的区别。1. 核心哲学与稳定性
2. 更新节奏 (Release Cycle)
3. 软件包与版本
4. 目标用户与场景
| 特性 | Debian | Ubuntu |
|---|
| 服务器 | 首选,因为占用资源极低且极稳 | 流行,由于有大量云服务支持 |
| 生物信息/科学计算 | 很多实验室的选择,系统环境非常纯净 | 非常流行,因为大多数软件教程以 Ubuntu 为准 |
| 新手友好度 | 较低(需要更多手动配置) | 极高(自动安装驱动,图形界面丰富) |
| 驱动支持 | 需要手动解决(尤其是 NVIDIA 显卡) | 自动检测并提示安装 |
总结:你该如何选择?
这是一个常见的“纯净版”或容器版 Linux 系统的状态。在没有 nano 或 vim,且已经准备好了更改镜像源,我们可以利用 Linux 自带的 重定向符 (>) 和 cat 命令来直接覆写配置文件。更新前一定要先备份一下。
请按以下步骤操作:
1. 确认配置文件名
先看看目录里那个文件的准确名字:
Bash
ls /etc/apt/sources.list.d/
通常它叫 debian.sources。
2. 使用 cat 覆写内容
我们将使用 cat <<EOF 命令。这个命令会把你接下来输入的所有内容直接写入文件,直到遇到 EOF 为止。
请直接复制并粘贴整段代码到你的终端:
sudo cat > /etc/apt/sources.list.d/debian.sources <<EOF
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://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
3. 更新系统并安装编辑器
换好源后,建议你立刻安装一个编辑器,方便以后操作:
# 1. 更新索引
sudo apt update
# 2. 安装 nano (比 vim 更容易上手)
sudo apt install nano -y
技巧提示:
为什么这样做? 在没有文本编辑器的情况下,cat > 文件名 是最直接的写文件方式。
如果报错权限不足: 如果 sudo cat > ... 提示权限错误(因为重定向符 > 有时不会继承 sudo 权限),请尝试使用这个“强力版”命令:
Bash
cat <<EOF | sudo tee /etc/apt/sources.list.d/debian.sources
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://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
安装好 nano 之后,你以后就可以直接用 sudo nano /文件路径 来修改任何配置了。