macOS 卸载教程
⚠️ 删除配置目录会清除所有配置、会话、记忆、飞书连接。卸载前建议备份:
cp -r ~/.openclaw ~/.openclaw.bak
第一步:停止并卸载 Gateway 服务
# 停止网关
openclaw gateway stop
# 卸载守护进程
openclaw gateway uninstall
第二步:卸载全局 npm 包
# 卸载 OpenClaw
npm uninstall -g openclaw
# 清理 npm 缓存
npm cache clean --force
第三步:删除配置文件和数据
# 删除 OpenClaw 配置目录
rm -rf ~/.openclaw
# 删除可能残留的日志
rm -rf ~/.openclaw_logs 2>/dev/null
第四步:清理环境变量
检查并删除 ~/.zshrc 或 ~/.bash_profile 中的 OpenClaw 相关配置:
# 查看是否有残留
grep -i openclaw ~/.zshrc
grep -i openclaw ~/.bash_profile
如果有,编辑删除类似这样的行:
# OpenClaw Completion
source ~/.openclaw/completions/openclaw.bash
保存后重新加载:
source ~/.zshrc
第五步:验证卸载完成
# 确认命令已不存在
which openclaw # 应该输出空或提示 not found
# 确认配置目录已删除
ls ~/.openclaw # 应该提示 No such file or directory
卸载完成。如需重装,请参考 OpenClaw macOS 安装与配置完全指南。
Windows 卸载教程
⚠️ 删除配置目录会清除所有配置、会话、记忆、飞书连接。卸载前建议备份:
cp -r ~/.openclaw ~/.openclaw.bak
第一步:停止并卸载 Gateway 服务
# 停止网关
openclaw gateway stop
# 卸载守护进程
openclaw gateway uninstall
第二步:卸载全局 npm 包
# 卸载 OpenClaw
npm uninstall -g openclaw
# 清理 npm 缓存
npm cache clean --force
第三步:删除配置文件和数据
# 删除 OpenClaw 配置目录
Remove-Item -Recurse -Force "$env:USERPROFILE\.openclaw"
# 删除可能残留的日志
Remove-Item -Recurse -Force "$env:USERPROFILE\.openclaw_logs" -ErrorAction SilentlyContinue
第四步:清理环境变量
- 按
Win + R,输入sysdm.cpl,回车 - 点击 高级 → 环境变量
- 在 用户变量 中检查是否有 OpenClaw 相关的 PATH 条目
- 如果有,选中并删除
- 点击确定保存
第五步:验证卸载完成
# 确认命令已不存在
where openclaw # 应该提示找不到文件
# 确认配置目录已删除
Test-Path "$env:USERPROFILE\.openclaw" # 应该输出 False
卸载完成。如需重装,请参考 OpenClaw Windows 安装与配置完全指南。
Linux 卸载教程(Ubuntu / Debian)
⚠️ 删除配置目录会清除所有配置、会话、记忆、飞书连接。卸载前建议备份:
cp -r ~/.openclaw ~/.openclaw.bak
第一步:停止 OpenClaw 网关进程
# 优雅停止网关(推荐)
npx openclaw gateway stop 2>&1 || true
# 等待 2 秒让进程完全停止
sleep 2
# 验证进程已停止
ps aux | grep -i openclaw | grep -v grep
# 如果没有输出,表示进程已停止
如果 gateway stop 命令卡住或失败,强制终止:
pkill -9 -f "openclaw" 2>&1 || true
sleep 1
第二步:卸载 npm 全局包
# 卸载飞书插件
npm uninstall -g @openclaw/feishu 2>&1
# 输出: removed xx packages
# 卸载 OpenClaw main package
npm uninstall -g openclaw 2>&1
# 输出: removed xxx packages
# 验证卸载
npm list -g openclaw 2>&1
npm list -g @openclaw/feishu 2>&1
预期输出:
/home/your-username/.npm-global/lib └── (empty)
第三步:验证命令已删除
# 检查命令是否还存在
which openclaw
# 尝试执行命令
openclaw --version 2>/dev/null
# 检查二进制文件
ls -la ~/.npm-global/bin/openclaw 2>/dev/null
预期输出:
(无输出,表示命令已不存在)
第四步:禁用并删除 systemd 服务
# 禁用用户级 systemd 服务
systemctl --user disable openclaw-gateway.service 2>&1
# 输出: Removed ...wants/openclaw-gateway.service
# 停止服务(如果还在运行)
systemctl --user stop openclaw-gateway.service 2>&1 || true
# 删除 systemd 服务文件
rm -f ~/.config/systemd/user/openclaw-gateway.service
# 删除可能存在的覆盖配置
rm -rf ~/.config/systemd/user/openclaw-gateway.service.d/ 2>/dev/null
# 重新加载 systemd
systemctl --user daemon-reload 2>&1
# 验证服务已清理
systemctl --user list-unit-files | grep -i openclaw
第五步:删除配置目录
# 查看配置目录大小
du -sh ~/.openclaw/ 2>&1
# 通常 50-100MB
# 删除配置目录
rm -rf ~/.openclaw/
# 验证删除
ls -la ~/.openclaw 2>/dev/null
预期输出:
ls: 无法访问 '/home/your-username/.openclaw': 没有那个文件或目录
第六步:最终全面检查
运行以下命令验证卸载是否完整:
# 1. 检查命令
command -v openclaw &>/dev/null && echo "FAIL: openclaw command still exists" || echo "OK: openclaw command removed"
# 2. 检查 npm 全局包
npm list -g openclaw 2>&1 | grep -q "openclaw" && echo "FAIL: openclaw still in npm global" || echo "OK: openclaw removed from npm global"
# 3. 检查配置目录
[ -d ~/.openclaw ] && echo "FAIL: ~/.openclaw directory still exists" || echo "OK: ~/.openclaw directory removed"
# 4. 检查 systemd 服务
[ -f ~/.config/systemd/user/openclaw-gateway.service ] && echo "FAIL: systemd service file still exists" || echo "OK: systemd service file removed"
# 5. 检查运行进程
ps aux | grep "[o]penclaw" | grep -v grep > /dev/null && echo "FAIL: OpenClaw process still running" || echo "OK: no OpenClaw process running"
# 6. 检查端口
ss -tlnp | grep -q "18789" && echo "FAIL: port 18789 still in use" || echo "OK: port 18789 released"
预期输出:
OK: openclaw command removed OK: openclaw removed from npm global OK: ~/.openclaw directory removed OK: systemd service file removed OK: no OpenClaw process running OK: port 18789 released
全部显示 OK 表示已完全卸载。
📚 常用管理命令
| 命令 | 作用 |
|---|---|
openclaw gateway stop |
停止 Gateway |
openclaw gateway uninstall |
卸载守护进程 |
openclaw status |
查看运行状态 |
openclaw logs --follow |
查看实时日志 |
评论 (0)