Termux 环境配置与应用部署教学说明
本文档为Termux 换国内源、系统更新、SSH 远程连接、Ubuntu 22 部署、OpenClaw 皇朝安装/卸载、Ubuntu 软重置的完整操作指南,所有命令可直接复制执行,适用于 Android 手机 Termux 环境(无需 Root)。
一、Termux 换国内源 + 系统更新(必做)
1. 更换清华大学镜像源(国内高速)
执行以下命令,一键替换官方源为清华源(含主源、游戏源、科学源):
1 2 3
| sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-games games stable@' $PREFIX/etc/apt/sources.list.d/game.list sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-science science stable@' $PREFIX/etc/apt/sources.list.d/science.list
|
2. 更新软件源与系统
说明:pkg update 同步仓库索引,pkg upgrade 升级所有可更新包,换源后速度大幅提升。
二、Termux 安装 SSH + 远程连接
1. 安装并配置 OpenSSH
1 2 3 4 5
| pkg install openssh -y passwd sshd whoami ifconfig
|
2. 电脑远程连接 Termux
在电脑终端(Windows CMD/PowerShell、Mac/Linux 终端)执行:
提示:首次连接输入 yes 确认,再输入之前设置的密码即可登录。
三、Termux 部署 Ubuntu 22.04(Proot 方式,无需 Root)
1. 安装依赖与启动脚本
1 2 3 4
| su cd /data/local/ubuntu22 chmod +x start.sh ./start.sh
|
补充:Ubuntu 22 一键安装脚本(可选,用于全新部署):
1 2 3 4 5 6
| pkg install git proot -y cd ~ git clone --depth=1 -b ubuntu22.04 https://gitee.com/KudouShinnyan/ubuntu-in-termux.git cd ubuntu-in-termux chmod +x ubuntu.sh ./ubuntu.sh -y
|
2. 远程连接 Ubuntu 22(Termux 内)
启动 Ubuntu 后,在 Ubuntu 终端执行:
1 2 3
| apt update && apt install openssh-server -y passwd ifconfig
|
电脑端连接:ssh ubuntu用户名@UbuntuIP -p 22
四、一键安装 OpenClaw 皇朝(飞书单 Bot 模式)
1
| bash <(curl -fsSL https://raw.githubusercontent.com/wanikua/boluobobo-ai-court-tutorial/main/install.sh)
|
执行后按提示选择 模式 2:飞书单 Bot 模式,等待安装完成即可。
五、Ubuntu 系统软重置(保留家目录,重置软件/配置)
1. 一键重置脚本(保存为 reset-ubuntu.sh)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #!/bin/bash
echo "[1/5] 修复中断的安装..." sudo dpkg --configure -a sudo apt --fix-broken install -y
echo "[2/5] 清理无用包与缓存..." sudo apt autoremove --purge -y sudo apt autoclean sudo apt clean
echo "[3/5] 重装核心桌面组件(服务器版可注释)..."
echo "[4/5] 重置所有包配置为默认..." sudo apt --reinstall install $(dpkg --get-selections | grep install | cut -f1) -y
echo "[5/5] 更新系统..." sudo apt update && sudo apt upgrade -y
echo "重置完成!建议执行:sudo reboot 重启"
|
2. 执行脚本
1 2
| chmod +x reset-ubuntu.sh ./reset-ubuntu.sh
|
六、彻底卸载 OpenClaw 皇朝
1. 卸载 npm 全局包 + 清理缓存
1 2 3
| npm list -g npm uninstall -g openclaw openclaw-cn npm cache clean --force
|
2. 清理残留文件(关键)
1 2 3 4
| find / -name "*openclaw*" 2>/dev/null | grep -v "node_modules" | sort
rm -rf ~/.openclaw ~/.clawdbot ~/.moltbot ~/.molthub
|
3. 验证卸载
1 2
| npm list -g --depth=0 openclaw --version
|
七、常见问题与注意事项
- 换源后 pkg update 失败:检查网络,或替换为阿里云源(命令见参考)。
- SSH 连接失败:确认手机与电脑在同一局域网,关闭手机防火墙,sshd 已启动。
- Ubuntu 启动报错:重新执行
./start.sh,或删除目录后重新部署。
- OpenClaw 安装失败:先执行
pkg update && pkg upgrade,确保 Node.js 已安装(pkg install nodejs -y)。