Debian 12安装配置手册

本文适用于Debian 11、12系统安装完毕后进行初始化配置时使用。

允许root远程登录

编辑ssh配置文件:nano /etc/ssh/sshd_config

找到PermitRootLogin修改yes

PermitRootLogin yes

重启ssh:systemctl restart sshd

修改root终端配置文件

此项修改以后可为root用户的终端命令添加上颜色

复制普通用户配置文件:cp /home/fm/.bashrc /root/.bashrc

编辑root用户配置文件:nano /root/.bashrc

export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin

修改为静态IP

nano /etc/network/interfaces

auto enp0s3
iface enp0s3 inet static
    address 192.168.1.99
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 119.29.29.29 223.5.5.5

119.29.29.29为腾讯旗下DNSPod Public DNS
223.5.5.5为阿里公共DNS

修改镜像源

编辑镜像文件:nano /etc/apt/sources.list

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

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

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

安装基础软件

apt install openssh-server sudo tree wget gnupg gnupg1 gnupg2 apt-transport-https ca-certificates net-tools unzip curl git screen vim sysstat btop ranger iftop -y

btop为服务器资源占用可视化查看工具
ranger为快速文件管理工具

修改内存配置

此项配置目的为优先使用物理内存而不是swap

nano /etc/sysctl.conf

vm.swappiness=0

使配置生效:sysctl -p

作者:ossdate  创建时间:2024-10-25 15:44
最后编辑:ossdate  更新时间:2024-10-29 21:38