1. 查看系统版本信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
root@VM-16-16-debian:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

root@VM-16-16-debian:~# cat /etc/debian_version
12.0

root@VM-16-16-debian:~# hostnamectl
Static hostname: VM-16-16-debian
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: 3217963d28984783b71a0eecc3f3f89d
Boot ID: 9937def658c5426ba053af84a215a22b
Virtualization: kvm
Operating System: Debian GNU/Linux 12 (bookworm)
Kernel: Linux 6.1.0-13-amd64
Architecture: x86-64
Firmware Version: seabios-1.9.1-qemu-project.org

root@VM-16-16-debian:~# uname -a
Linux VM-16-16-debian 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux

image.png

1.1 安装vim编辑器

1
apt install vim

1.2 Root用户连接SSH

系统默认是不能使用Root用户去使用SSH连接到VPS的,我们需要修改配置。

1
2
3
4
sudo vim /etc/ssh/ssh_config
#修改或增加 PermitRootLogin yes 配置

sudo systemctl restart ssh #重启SSH服务生效

安装sudo命令,创建管理员用户,后面都以此用户进行系统管理而不是root用户。

1
2
root@debian:~# useradd -m -s /bin/bash -G sudo test 
root@debian:~# passwd test

让我们创建的用户和root有同等的权限

1
2
3
4
5
6
7
8
9
#1.添加用户,首先用 adduser 命令添加一个普通用户,命令如下:
#2.新增一个test账号
adduser test
#修改密码
passwd test
#3修改 /etc/sudoers 文件,找到 root 一行,在 root 下面添加一行,如下所示:
#Allow root to run any commands anywhere root ALL=(ALL) ALL
test ALL=(ALL) ALL
#修改完毕,现在可以用 yzgxhwj 帐号登录,然后用命令 sudo su—, 即可获得 root 权限进行操作。

这样我们就不用去操作root用户了,可以直接操作我们和root用户有同等权限的用户。

1.3 为了提高软件下载速度,建立更换为国内镜像源

先备份sources.list,然后拷贝到用户目录,用编辑器进行编辑,最后再拷回去覆盖院配置。

1
2
3
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
cp /etc/apt/sources.list /home/scilogyhunter/sources.list
sudo cp /home/scilogyhunter/sources.list /etc/apt/sources.list

image.png

我使用的是腾讯云的

1
2
3
4
5
6
deb http://mirrors.tencentyun.com/debian bookworm main contrib non-free non-free-firmware
#deb-src http://mirrors.tencentyun.com/debian bookworm main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian bookworm-updates main contrib non-free non-free-firmware
#deb-src http://mirrors.tencentyun.com/debian bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian-security/ bookworm-security main contrib non-free-firmware
#deb-src http://mirrors.tencentyun.com/debian-security/ bookworm-security main contrib non-free-firmware