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 -

不加-,会有问题。。

相关推荐
RisunJan5 小时前
Linux命令-nologin(用于系统账户或需要禁止交互式登录的场景)
linux·运维
倔强的石头1065 小时前
【Linux指南】Linux快捷键与系统实用技巧
linux·运维·服务器
番茄地瓜5 小时前
Linux 配置静态 IP 步骤
linux·运维·服务器
.千余6 小时前
【Linux】 传输层协议UDP:从端口号到传输机制
linux·运维·udp
囚~徒~7 小时前
轻量化的虚拟机
linux·运维·服务器
SteveSenna8 小时前
Ubuntu 20.04 安装 Isaac Sim 4.5 + Isaac Lab
linux·运维·服务器
开开心心就好8 小时前
支持多显示器的Windows高效分屏工具
运维·python·科技·游戏·计算机外设·ocr·powerpoint
lizhihai_998 小时前
股市学习心得-A股服务器/算力服务器龙头
大数据·运维·服务器·人工智能·科技·学习
鼎讯信通8 小时前
守护风电场 “无线神经”:LN-090A 宽频高速手持式频谱分析仪
运维·信息与通信
超级赛博搬砖工8 小时前
静态网页内容与动态网页内容:网页抓取指南
运维·服务器