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 -

不加-,会有问题。。

相关推荐
陕西小伙伴网络科技有限公司21 小时前
CentOS-7 编译glibc-2.29
linux·运维·centos
清风拂山岗 明月照大江21 小时前
MySQL运维
运维·数据库·mysql
米高梅狮子21 小时前
02. 配置DNS服务器
运维·服务器·centos
宴之敖者、1 天前
Linux——指令
linux·运维·服务器
企业对冲系统官1 天前
基差风险管理系统集成说明与接口规范
大数据·运维·python·算法·区块链·github
HIT_Weston1 天前
101、【Ubuntu】【Hugo】搭建私人博客:元信息&翻译(二)
linux·运维·ubuntu
座山雕~1 天前
docker---部署与常用命令
运维·docker·容器
凯丨1 天前
使用 frp 实现内网穿透:让本地服务器安全暴露到公网
运维·服务器·安全
小小福仔1 天前
Linux运维基础篇(二)之用户管理
linux·运维·服务器·增删改查
企业对冲系统官1 天前
大宗商品风险对冲系统统计分析功能的技术实现
运维·python·算法·区块链·github·pygame