Edit Commands.md
Deploy / deploy (push) Successful in 38s

This commit is contained in:
2026-03-28 00:13:52 +08:00
parent fff2caef1c
commit 933b29fb07
@@ -1,14 +1,71 @@
# 服务器运行与维护常用命令 # 服务器运行与维护常用命令
## 物理机
### Proxmox 9
[安装与配置 Proxmox 9](https://blog.cattom.site/tech/Proxmox-9/)
### 硬盘
``` bash
sudo df ah # 磁盘空间使用情况
sudo fdisk -l # 列出所有分区
sudo cfdisk /dev/sda # 管理某块硬盘
sudo sgdisk -p /dev/sda # 列出所有分区 (GPT 硬盘)
sudo sgdisk -e /dev/sda # 修复 GPT 分区表
```
``` bash title="Proxmox"
# 块设备
lsblk
# LVM 物理卷
pvs
# LVM 卷组
vgs
# LVM 逻辑卷
lvs
```
### 网络 (Debian 13 Server)
``` bash
sudo nano /etc/network/interfaces # 网络接口配置
sudo resolvectl status # DNS 管理
ls -al /etc/resolv.conf # 确认 DNS 配置托管情况
```
### APT 镜像源 - 清华源 (Debian 13 Server)
``` bash
sudo nano /etc/apt/sources.list
# Or
sudo nano /etc/apt/sources.list.d/debian.sources
```
``` title="/etc/apt/sources.list.d/debian.sources"
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: trixie trixie-updates trixie-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: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
```
## 创建虚拟机 ## 创建虚拟机
[创建基于定制 Debian 13 镜像的虚拟机](https://blog.cattom.site/tech/Customize-Debian-13-Image) [创建基于定制 Debian 13 镜像的虚拟机](https://blog.cattom.site/tech/Customize-Debian-13-Image)
## 初始化 ## 服务初始化
### Maria ### Maria
**推送 GitHub 私钥**: **推送 GitHub 私钥**
``` bash ``` bash
# 在 CatTomServer1 处执行 # 在 CatTomServer1 处执行
@@ -19,7 +76,7 @@ rsync -avP /home/cattom/.ssh/cattomgithub root@[server_ip]:/root/.ssh/
rsync -avP -e 'ssh -p 25800 -i /home/cattom/.ssh/Maria' /home/cattom/.ssh/cattomgithub root@[server_ip]:/root/.ssh/ rsync -avP -e 'ssh -p 25800 -i /home/cattom/.ssh/Maria' /home/cattom/.ssh/cattomgithub root@[server_ip]:/root/.ssh/
``` ```
**编辑 SSH 客户端配置**: **编辑 SSH 客户端配置**
``` bash ``` bash
sudo nano ~/.ssh/config sudo nano ~/.ssh/config
@@ -36,7 +93,7 @@ IdentityFile "~/.ssh/cattomgithub"
测试能否正常连接: `ssh -T git@github.com` 测试能否正常连接: `ssh -T git@github.com`
**克隆 Maria 仓库**: **克隆 Maria 仓库**
``` bash ``` bash
git clone git@github.com:cattomgithub/maria.git git clone git@github.com:cattomgithub/maria.git
@@ -46,7 +103,7 @@ cd maria/script && chmod +x *.sh && ./maria.sh
### HomeLab ### HomeLab
**推送 Gitea 私钥**: **推送 Gitea 私钥**
``` bash ``` bash
# 在 CatTomServer1 处执行 # 在 CatTomServer1 处执行
@@ -57,7 +114,7 @@ rsync -avP /home/cattom/.ssh/cattom-gitea root@[server_ip]:/home/cattom/.ssh/
rsync -avP -e 'ssh -p 25800 -i /home/cattom/.ssh/CatTomServer' /home/cattom/.ssh/cattom-gitea root@[server_ip]:/home/cattom/.ssh/ rsync -avP -e 'ssh -p 25800 -i /home/cattom/.ssh/CatTomServer' /home/cattom/.ssh/cattom-gitea root@[server_ip]:/home/cattom/.ssh/
``` ```
**编辑 SSH 客户端配置**: **编辑 SSH 客户端配置**
``` bash ``` bash
sudo nano ~/.ssh/config sudo nano ~/.ssh/config
@@ -74,17 +131,17 @@ IdentityFile "~/.ssh/cattom-gitea"
测试能否正常连接: `ssh -T git@gitea.cattom.site` 测试能否正常连接: `ssh -T git@gitea.cattom.site`
**克隆 HomeLab 仓库**: **克隆 HomeLab 仓库**
``` bash ``` bash
git clone git@gitea.cattom.site:cattom/HomeLab.git git clone git@gitea.cattom.site:cattom/HomeLab.git
cd HomeLab && chmod +x *.sh && ./Ini.sh cd HomeLab/script && chmod +x *.sh && ./init.sh
``` ```
## 修改 SSH 配置 ## 修改 SSH 配置
**启动 SSH 服务**: **启动 SSH 服务**
``` bash ``` bash
sudo systemctl enable ssh && sudo systemctl restart ssh && sudo systemctl status ssh sudo systemctl enable ssh && sudo systemctl restart ssh && sudo systemctl status ssh
@@ -101,7 +158,9 @@ ssh-copy-id -i /home/cattom/.ssh/CatTomServer.pub cattom@[server_ip]
ssh-copy-id -p 25800 ... ssh-copy-id -p 25800 ...
``` ```
**修改 SSH 配置**: 若 `ssh-copy-id` 执行不成功,可将对应公钥添加至 `$HOME/.ssh/authorized_keys` 文件的末尾。
**修改 SSH 配置**
``` bash ``` bash
sudo nano /etc/ssh/sshd_config sudo nano /etc/ssh/sshd_config
@@ -161,7 +220,7 @@ aliyun ossutil sync /root/blog/site oss://cattom-blog --force --update --delete
### Flexget ### Flexget
安装 Flexget: 安装 Flexget
``` bash ``` bash
cd /root || exit cd /root || exit
@@ -171,7 +230,7 @@ python3 -m venv /root/flexget/
/root/flexget/bin/pip install flexget /root/flexget/bin/pip install flexget
``` ```
测试配置并启动后台进程: 测试配置并启动后台进程
``` bash ``` bash
sudo ln -s /root/maria/config/flexget/config.yml /root/flexget/config.yml sudo ln -s /root/maria/config/flexget/config.yml /root/flexget/config.yml
@@ -179,7 +238,7 @@ sudo ln -s /root/maria/config/flexget/config.yml /root/flexget/config.yml
/root/flexget/bin/flexget -c /root/flexget/config.yml daemon start -d --autoreload-config /root/flexget/bin/flexget -c /root/flexget/config.yml daemon start -d --autoreload-config
``` ```
设置开机自启动: 设置开机自启动
``` bash ``` bash
( (
@@ -188,7 +247,7 @@ sudo ln -s /root/maria/config/flexget/config.yml /root/flexget/config.yml
) | crontab -u $(whoami) - ) | crontab -u $(whoami) -
``` ```
配置 alias: 配置 alias
``` bash ``` bash
echo 'alias flexget="/root/flexget/bin/flexget -c /root/flexget/config.yml"' >> /root/.bashrc echo 'alias flexget="/root/flexget/bin/flexget -c /root/flexget/config.yml"' >> /root/.bashrc
@@ -286,13 +345,13 @@ net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_slow_start_after_idle = 0 net.ipv4.tcp_slow_start_after_idle = 0
``` ```
刷新配置: 刷新配置
``` bash ``` bash
sysctl -p sysctl -p
``` ```
验证是否成功启动 BBR 验证是否成功启动 BBR
``` bash ``` bash
lsmod | grep bbr lsmod | grep bbr
@@ -312,6 +371,14 @@ lsmod | grep bbr
### Gitea Actions ### Gitea Actions
## SSH 隧道
``` bash
ssh -L [local-port]:[lan-ip]:[lan-port] [username]@[remote-ip]
# Example:
ssh -L 8007:192.168.1.6:8007 cattom@100.116.56.77
```
## NFS 配置 ## NFS 配置
``` bash ``` bash