创建工作用户
- 首先创建一个新的用户
adduser {用户名}
- 将该用户名纳入sudo名单内
nano /etc/sudoers
,并在root下方一行编辑{用户名} ALL=(ALL:ALL)ALL
换源
- 换源第一步
nano /etc/apt/source.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-firmwaredeb 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-firmwaredeb 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://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
- 换源第二步
nano /etc/apt/sources.list.d/debian.sources
替换为以下内容
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
# Suites: bookworm bookworm-updates bookworm-backports
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: https://security.debian.org/debian-security
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg# Types: deb-src
# URIs: https://security.debian.org/debian-security
# Suites: bookworm-security
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
注意:先不要更新软件
安装常用软件
- 切换用户
su - {用户名}
- 更新软件列表
sudo apt update
- 安装系统必备软件
sudo apt install net-tools openssh-server sudo curl wget tar unzip zip htop nohup telnet tar iptables pkill [-y]
- 修改ll为ls -al
cd ~ && echo "alias ll='ls -al'" >> .bashrc
- ssh配置并禁止密码登录
# 服务端 stty -echo echo "请手动编辑sshd_config文件,修改\n\Port xxxx\nPubkeyAuthentication yes\nPasswordAuthentication no\nPermitRootLogin no" echo "准备进入文档编辑,等待阅读中...(10秒)" sleep 10 sudo nano /etc/ssh/sshd_config echo "请自行检查是否修改成功" stty echo
# 客户端 sudo apt install openssh-client -yes ssh-keygen -t rsa -f ~/.ssh/ssh_key ssh-copy-id {服务端用户名}@{服务端IP}
这样初始化基本就完成了