Debian 初始设置

一、设置网卡

✅ 方法 2:使用 systemd-networkd(服务器推荐)

Debian 13 更推荐这种方式(比 interfaces 更现代)。

  1. 启用 systemd-networkd

    sudo systemctl enable --now systemd-networkd

    sudo systemctl enable --now systemd-resolved

  2. 创建配置文件

先查网卡:

ip a

假设网卡叫 ens33:

静态 IP 配置

创建文件:

sudo nano /etc/systemd/network/10-ens33.network

写入:

Match

Name=ens33

Network

Address=192.168.1.100/24

Gateway=192.168.1.1

DNS=8.8.8.8

保存后:

sudo systemctl restart systemd-networkd

DHCP 配置

Match

Name=ens33

Network

DHCP=yes

重启:

sudo systemctl restart systemd-networkd

二、设置SSH

  1. 安装 OpenSSH Server

Debian 默认通常未安装 SSH 服务。

sudo apt update

sudo apt install openssh-server -y

✅ 2. 启动 & 设置开机自启

sudo systemctl enable --now ssh

✅ 3. 查看 SSH 状态(确认是否正常工作)

systemctl status ssh

看到 active (running) 就成功。

✅ 4. 查看本机 IP(用于远程连接)

ip a

方案 A:使用传统的 resolvconf

bash

三、安装DNS服务

安装 resolvconf

apt install resolvconf

启用服务

systemctl enable --now resolvconf

配置 DNS

echo "nameserver 8.8.8.8" >> /etc/resolvconf/resolv.conf.d/head

echo "nameserver 8.8.4.4" >> /etc/resolvconf/resolv.conf.d/head

更新配置

resolvconf -u

四、设置更新源

第1步:备份并修改软件源列表

打开终端。

备份您当前的源列表,以防出错时可以恢复。

bash

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

使用文本编辑器(如 nano)编辑源列表文件。

bash

sudo nano /etc/apt/sources.list

xml 复制代码
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware

第2步:更新软件包列表

这个命令会从您新设置的源下载软件包列表信息,但不会安装或更新任何软件。

bash

sudo apt update

第3步:升级已安装的软件包

这个命令会将所有已安装的软件包升级到最新版本。

bash

sudo apt upgrade

第4步(可选):执行完整升级

如果您需要升级那些会改变系统核心依赖关系的软件包(例如,内核升级),请使用这个命令。它比 upgrade 更彻底,但可能会移除一些过时的包。

bash

sudo apt full-upgrade

第5步(可选):清理无用包

升级后,系统可能会残留一些不再需要的依赖包。您可以使用以下命令清理它们以释放空间。

bash

sudo apt autoremove

注意事项:

切换root

xml 复制代码
su -

不加-,会有问题。。

相关推荐
夏日听雨眠1 天前
LInux(逻辑地址与物理地址的区别,文件描述符,lseek函数)
linux·运维·网络
哲霖软件1 天前
ERP 赋能非标自动化行业:破解物料与库存管理难题
运维·自动化
火车叼位1 天前
替代 Tiny Win10 的 Linux 方案:Debian XFCE 精简桌面搭建
linux·运维
syagain_zsx1 天前
Linux指令初识(实用篇)
linux·运维·服务器
OYangxf1 天前
Git Commit Message
运维·git
Alter12301 天前
从“力大砖飞”到“拟态共生”,新华三定义AI基础设施的系统级进化
大数据·运维·人工智能
王木风1 天前
终端里的编程副驾:DeepSeek-TUI-项目深度拆解,实测与原理分析
linux·运维·人工智能·rust·node.js
槑槑紫1 天前
windows系统装轻量版linux开发
linux·运维·服务器
齐潇宇1 天前
k8s-Helm管理器
linux·运维·云原生·容器·kubernetes
小王C语言1 天前
Windows和Linux之间文件互传
linux·运维·服务器