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 -

不加-,会有问题。。

相关推荐
乘云数字DATABUFF2 天前
5分钟部署开源APM Databuff:OpenTelemetry全链路追踪入门实战
运维·后端
荣--4 天前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森4 天前
动手实战学 Docker — 从零到集群编排完全指南
运维
Avan_菜菜5 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
SelectDB6 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
XIAOHEZIcode7 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220708 天前
如何搭建本地yum源(上)
运维
大树8811 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠11 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质11 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务