Post

服务器准备工作

服务器准备工作

查看配置信息

CPU

配置信息

  • 一键查看 lscpu
  • 核数 nproc
  • 主频 lscpu | grep "Model name"

使用情况

  • 查看CPU使用率 htop
  • 负载情况 uptime

终端配置

重启终端 source .bashrc
. ~/.bashrc

bash 插件

  • bash-completion tab补全
  • ble.sh 自动补全提示
  • fzf 文件搜索
  • atuin 提供更强的历史搜索、去重、统计、跨机器同步等功能。 跨终端
  • zoxide 更聪明的cd

ble.sh 和 fzf 都有 ctrl + r 的快捷键绑定
按下面写入 .bashrc 文件结尾,使用 fzf 的快捷键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# ble.sh
if [ -f ~/.local/share/blesh/ble.sh ]; then
  source ~/.local/share/blesh/ble.sh
fi

# fzf
if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
  source /usr/share/doc/fzf/examples/key-bindings.bash
fi

if [ -f /usr/share/doc/fzf/examples/completion.bash ]; then
  source /usr/share/doc/fzf/examples/completion.bash
fi

eval "$(zoxide init bash)"  # zxoide  用 z 替代 cd

终端美化插件

starship starship_guide

字体安装

curl -fL "你的URL" -o FiraCode.zip unzip FiraCode.zip -d FiraCode mkdir -p ~/.local/share/fonts (全局安装:sudo mkdir -p /usr/local/share/fonts/FiraCodefind FiraCode -type f \( -name "*.ttf" -o -name "*.otf" \) -exec cp {} ~/.local/share/fonts/ \; —— 复制字体 fc-cache -fv ———— 刷新字体缓存 fc-list | grep -i "Fira" ———— 检查是否安装成功

代理配置

安装mihomo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl -L -o mihomo.gz "https://github.com/MetaCubeX/mihomo/releases/download/v1.19.24/mihomo-linux-amd64-v1.19.24.gz"
gzip -d mihomo.gz
chmod +x mihomo

sudo mv mihomo /usr/local/bin/mihomo

mihomo -v  # 检查

# 配置文件:
sudo mkdir -p /etc/mihomo
sudo vim /etc/mihomo/config.yaml

# 手动测试:
mihomo -d /etc/mihomo

bash代理配置:

1
2
3
4
5
6
cat >> ~/.bashrc <<'EOF'

# mihomo proxy
alias proxy_on='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890'
alias proxy_off='unset http_proxy https_proxy all_proxy'
EOF

配置 systemd

sudo vim /etc/systemd/system/mihomo.service

写入:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=mihomo proxy service
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/mihomo -d /etc/mihomo
Restart=on-failure
RestartSec=5
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target

启动并启用

1
2
3
4
5
6
7
sudo systemctl daemon-reload
sudo systemctl enable --now mihomo

#查看 状态
systemctl status mihomo
#查看日志
journalctl -u mihomo -f

面板

1
2
3
4
5
sudo mkdir -p /etc/mihomo

sudo git clone https://github.com/MetaCubeX/metacubexd.git \
  -b gh-pages \
  /etc/mihomo/ui

若已存在面板,更新命令:
sudo git -C /etc/mihomo/ui pull -r

修改mihomo配置,加入:

1
2
3
external-controller: 0.0.0.0:9090
external-ui: /etc/mihomo/ui
secret: "自己设置一个密码"

重启 sudo systemctl restart mihomo

防火墙配置

Agent

GenericAgent

启动环境

source GenericAgent/env.sh

常用命令

ga list

This post is licensed under CC BY 4.0 by the author.