Debian 13 系统配置指南 🐧
一份详尽的 Debian 13 系统配置记录,涵盖网络设置、软件安装、服务配置及故障排查。
📋 目录导航
🌟 Debian 13 特点与功能 Debian 13 “Trixie” 是一个稳定、可靠的 Linux 发行版,适合服务器和桌面使用。主要特点包括:
🐧 开源免费 :完全免费且开放源代码
🛡️ 安全稳定 :长期支持版本,提供安全更新
📦 软件丰富 :拥有超过 60,000 个软件包
🔧 高度可定制 :可根据需求灵活配置系统
🌍 多架构支持 :支持 x86、ARM、RISC-V 等多种架构
🐋 容器友好 :改进的容器和虚拟化支持
🛠️ Debian13 安装常用软件 1 2 apt update -y && apt install -y rsync sudo curl wget vim tree samba nfs-common openssh-server zip unzip htop net-tools bpytop
这些工具包含:
📁 文件管理 :rsync, tree, zip, unzip
🌐 网络工具 :curl, wget, net-tools
🔐 远程访问 :openssh-server
💾 共享服务 :samba, nfs-common
📊 系统监控 :htop, bpytop
🌐 Debian13 修改静态 IP 地址 1. 查看当前网络接口
2. 使用 Netplan 修改网络配置 (Debian 13 默认) 1 nano /etc/network/interfaces
interfaces
原文件
1 2 3 4 5 6 7 8 9 10 source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow-hotplug ens18 iface ens18 inet dhcp
修改为以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow-hotplug ens18 iface ens18 inet static address 10.10.10.246 netmask 255.255.255.0 gateway 10.10.10.253
应用网络配置 1 sudo systemctl restart networking
🔐 Debian13 配置 SSH 服务 1. 安装与启用 SSH 1 2 3 4 sudo apt update && \sudo apt install openssh-server && \sudo systemctl start ssh && \sudo systemctl enable ssh
2. 优化 SSH 配置 1 2 3 4 5 6 7 8 9 sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup && \sudo sed -i \ -e 's/#Port 22/Port 22/' \ -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' \ -e 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/' \ -e 's/#UseDNS no/UseDNS no/' \ -e 's/#ClientAliveInterval 0/ClientAliveInterval 10/' \ -e 's/#ClientAliveCountMax 3/ClientAliveCountMax 999/' \ /etc/ssh/sshd_config
3. 查看修改是否成功 1 grep -E 'Port 22|PermitRootLogin|GSSAPIAuthentication|UseDNS|ClientAliveInterval|ClientAliveCountMax' /etc/ssh/sshd_config
4. 重启 SSH 服务 1 2 systemctl restart ssh && \ hostname -I | awk '{print $1}'
🚀 Debian13 换国内源 1. 备份原有源列表 1 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2. 阿里云镜像源 1 2 3 4 5 6 7 8 9 10 sudo tee /etc/apt/sources.list > /dev/null <<EOF deb https://mirrors.aliyun.com/debian/ trixie main non-free non-free-firmware contrib deb-src https://mirrors.aliyun.com/debian/ trixie main non-free non-free-firmware contrib deb https://mirrors.aliyun.com/debian-security/ trixie-security main deb-src https://mirrors.aliyun.com/debian-security/ trixie-security main deb https://mirrors.aliyun.com/debian/ trixie-updates main non-free non-free-firmware contrib deb-src https://mirrors.aliyun.com/debian/ trixie-updates main non-free non-free-firmware contrib deb https://mirrors.aliyun.com/debian/ trixie-backports main non-free non-free-firmware contrib deb-src https://mirrors.aliyun.com/debian/ trixie-backports main non-free non-free-firmware contrib EOF
3. 更新软件包列表 1 sudo apt update && sudo apt full-upgrade -y
💡 提示:也可选择清华大学、网易、腾讯云或中科大镜像源,替换相应URL即可。
📁 Debian13 配置 Samba 服务 1. 安装 Samba 1 2 3 4 sudo apt update && \ sudo apt install samba && \ sudo systemctl enable smb && \ sudo systemctl start smbd
2. 创建 Samba 用户 1 2 sudo useradd -m admin && \sudo smbpasswd -a admin
3. 一键部署 Samba 共享 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 sudo mkdir -pm 777 /mnt/test && \sudo tee -a /etc/samba/smb.conf > /dev/null <<'EOF' [Debian] comment = Debian 13 Samba Share path = /mnt/test browseable = yes read only = no create mask = 0775 directory mask = 0775 valid users = admin force user = admin force group = admin EOF sudo useradd -m admin && \(echo "password" ; echo "password" ) | sudo smbpasswd -a -s admin && \ sudo systemctl restart smbd
🔗 Debian13 配置 NFS 服务
1. 🔧 Debian 为 NFS 服务端配置 安装 NFS 服务器 1 sudo apt update && sudo apt install nfs-kernel-server nfs-common -y
配置 NFS 共享 1 2 3 4 5 sudo mkdir -p /srv/nfs/share && sudo chmod 755 /srv/nfs/sharesudo tee /etc/exports > /dev/null <<EOF /srv/nfs/share *(rw,sync,no_subtree_check,no_root_squash) EOF
应用配置并启动服务 1 2 3 sudo exportfs -rasudo systemctl start nfs-serversudo systemctl enable nfs-server
2. 💻 Debian 为 NFS 客户端配置 查看可用 NFS 共享 1 sudo showmount -e 10.10.10.251
临时挂载 NFS 共享 1 2 sudo mkdir -p /mnt/nfs-sharesudo mount -t nfs -o rw 10.10.10.251:/srv/nfs/share /mnt/nfs-share
永久挂载 NFS 共享 1 2 echo "10.10.10.251:/srv/nfs/share /mnt/nfs-share nfs defaults,_netdev 0 0" | sudo tee -a /etc/fstabsudo mount -a
3. 📊 查看与验证 NFS 共享 查看已挂载的 NFS 共享
取消 NFS 挂载 1 sudo umount /mnt/nfs-share
查看 NFS 日志 1 sudo journalctl -u nfs-server -f
⚠️ Debian13 文件系统只读修复 当文件系统意外变为只读模式时,可按以下步骤修复:
1. 检查文件系统错误 1 sudo dmesg | grep "read-only"
2. 重新挂载为读写模式 1 sudo mount -o remount,rw /
3. 检查并修复文件系统错误
4. 编辑 fstab 文件
确保根分区挂载选项包含 rw
而不是 ro
:1 2 3 4 5 UUID=xxxx-xxxx-xxxx / ext4 defaults,ro 0 1 UUID=xxxx-xxxx-xxxx / ext4 defaults,rw 0 1
5. 验证分区 UUID
6. 重启系统
7. 验证修复结果 1 findmnt -n -o OPTIONS / | grep -q rw && echo "读写模式" || echo "只读模式"
💡 提示:文件系统变为只读通常是系统检测到磁盘错误时的保护机制,修复后建议检查磁盘健康状态:1 sudo smartctl -a /dev/sda
这份配置指南将持续更新,欢迎贡献您的 Debian 使用经验!🐧