Netplan、Systemd、SSH、Conda清理 | 原创,AI翻译

Home 2025.02

目录

  1. 尝试Netplan
    • 静态IP配置导致SSH连接丢失
    • 需要物理访问才能恢复
    • 修改了系统的DNS解析器文件
  2. Systemd服务
    • 配置本地LLM推理服务
    • 为LLM模型设置Web界面
    • 建立基于规则的代理工具服务
    • 使用systemctl命令进行服务管理
  3. SSH配置
    • 通过corkscrew代理外部连接
    • 从代理中排除本地网络
    • 通过keychain和agent管理SSH密钥
    • 指定默认私钥位置
  4. 在Linux中删除Conda
    • 删除整个conda安装目录
    • 从bashrc中删除conda初始化代码
    • 更新PATH环境变量
    • 从系统路径中删除conda二进制文件

尝试Netplan

我尝试了以下配置来为一台Ubuntu机器分配静态IP地址。我在那台服务器上运行OpenWebUI和llama.cpp。

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.128/32
      gateway4: 192.168.1.1

运行 sudo netplan apply 后,无法通过 ssh lzw@192.168.1.128 访问该机器。

我使用键盘和鼠标登录到机器,删除了文件并恢复了设置。

/etc/resolv.conf 已更改。


Systemd服务

2025.02.13

LLaMA服务器服务配置

本节解释如何设置systemd服务来运行LLaMA服务器,该服务器提供本地LLM推理功能。

sudo emacs /etc/systemd/system/llama.service
sudo systemctl daemon-reload
sudo systemctl enable llama.service
journalctl -u llama.service
[Unit]
Description=Llama Script

[Service]
ExecStart=/home/lzw/Projects/llama.cpp/build/bin/llama-server -m /home/lzw/Projects/llama.cpp/models/DeepSeek-R1-Distill-Qwen-14B-Q5_K_M.gguf --port 8000  --ctx-size 2048 --batch-size 512 --n-gpu-layers 49 --threads 8 --parallel 1
WorkingDirectory=/home/lzw/Projects/llama.cpp
StandardOutput=append:/home/lzw/llama.log
StandardError=append:/home/lzw/llama.err
Restart=always
User=lzw

[Install]
WantedBy=default.target

Open WebUI服务配置

本节解释如何设置systemd服务来运行Open WebUI,它提供了一个用于与LLM模型交互的Web界面。

[Unit]
Description=Open Web UI Service

[Service]
ExecStart=/home/lzw/.local/bin/open-webui serve
WorkingDirectory=/home/lzw
StandardOutput=append:/home/lzw/open-webui.log
StandardError=append:/home/lzw/open-webui.err
Restart=always
User=lzw

[Install]
WantedBy=default.target
sudo systemctl enable openwebui.service
sudo systemctl daemon-reload
sudo systemctl start  openwebui.service

Clash服务配置

本节解释如何设置systemd服务来运行Clash,一个基于规则的代理工具。

[Unit]
Description=Clash Service

[Service]
ExecStart=/home/lzw/clash-linux-386-v1.17.0/clash-linux-386
WorkingDirectory=/home/lzw/clash-linux-386-v1.17.0
StandardOutput=append:/home/lzw/clash.log
StandardError=append:/home/lzw/clash.err
Restart=always
User=lzw

[Install]
WantedBy=default.target
# Create the service file
sudo emacs /etc/systemd/system/clash.service 

# Reload systemd daemon
sudo systemctl daemon-reload

# Enable and start the service
sudo systemctl enable clash.service
sudo systemctl start clash.service
sudo systemctl restart clash.service

# Check status
sudo systemctl status clash.service

SSH配置

2025.02.09

ssh-config 文件配置SSH客户端行为。让我们分解每个部分:

实质上,此配置为所有SSH连接(本地网络上的连接除外)设置了代理,并为方便起见配置了密钥管理。

Host 192.168.1.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa 
Host * !192.*.*.* !47.*.*.*
    ProxyCommand corkscrew localhost 7890 %h %p
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa    

在Linux中删除Conda

2025.02.07

rm -rf ~/anaconda3

删除 .bashrc 中的以下代码:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/lzw/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/lzw/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/lzw/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/lzw/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

将路径从:

export PATH="/usr/local/cuda-12.2/bin:/home/lzw/.local/share/gem/ruby/3.0.0/bin:/home/lzw/anaconda3/bin:/home/lzw/anaconda3/condabin:/home/lzw/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin"

更改为:

export PATH="/usr/local/cuda-12.2/bin:/home/lzw/.local/share/gem/ruby/3.0.0/bin:/home/lzw/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin"

Back Donate