如何在 Linux 上卸载 OpenClaw

分步指南:在 Linux 上彻底卸载 OpenClaw —— 移除 CLI、systemd 服务、配置文件、缓存,并验证清理干净。
2026/03/13

第一步:打开终端

打开你常用的终端模拟器,或在大多数桌面环境下按 Ctrl + Alt + T

第二步:快速卸载(CLI 仍可用)

如果 openclaw 命令还能用,运行:

openclaw uninstall --all --yes
  • uninstall:告诉程序「我要卸载」。
  • --all:彻底删除,包括网关服务、本地数据库、配置文件等所有数据。
  • --yes:全程自动确认,不需要手动按 Y。

完全无交互模式(脚本/CI/npx):

openclaw uninstall --all --yes --non-interactive
npx -y openclaw uninstall --all --yes --non-interactive

第三步:删除命令行工具

上面的指令跑完后,电脑里只剩 OpenClaw 的外壳(CLI 工具)。用你当初安装时的包管理器删除它:

npm rm -g openclaw
# 或者
pnpm remove -g openclaw
# 或者
bun remove -g openclaw

第四步:手动移除服务(CLI 已不在)

如果 openclaw 命令已经不存在,但网关服务还在后台运行:

systemctl --user disable --now openclaw-gateway.service
rm -f ~/.config/systemd/user/openclaw-gateway.service
systemctl --user daemon-reload

如果你用过 profile,unit 名称为 openclaw-gateway-<profile>.service,请对应调整。

第五步:删除状态、配置和工作区

rm -rf "${OPENCLAW_STATE_DIR:-$HOME/.openclaw}"
rm -rf ~/.openclaw/workspace

如果你把 OPENCLAW_CONFIG_PATH 设到了状态目录以外的位置,也需要手动删除。如果你用过 profile,对每个状态目录重复操作(如 ~/.openclaw-<profile>)。

第六步:排查常见 Linux 残留

类别检查位置
配置~/.config/openclaw
本地 share/state~/.local/share/openclaw~/.local/state/openclaw
缓存~/.cache/openclaw
项目目录与安装或运行相关的 repo / workspace
Shell 配置~/.bashrc~/.zshrc~/.profile

第七步:检查服务与启动层

Linux 用户需要逐项确认这些已清理干净:

  • systemd user unit —— systemctl --user list-units | grep openclaw
  • systemd system unit —— systemctl list-units | grep openclaw
  • cron job —— crontab -l | grep openclaw
  • Shell 启动文件 —— 检查是否还有引用 OpenClaw 的 alias、PATH 条目或 source 行。

如果卸载后还有东西不断复活,通常说明 service 层还没处理干净。

第八步:检查 shell 配置改动

请检查并清理:

  • ~/.bashrc
  • ~/.zshrc
  • ~/.profile
  • ~/.bash_profile

移除所有 OPENCLAW_* 环境变量、PATH 条目,以及引用 OpenClaw 的 source 行。

第九步:重启并验证

  1. 重开 shell 或直接重启机器。
  2. 运行:
which openclaw
ps aux | grep openclaw
systemctl --user list-units | grep openclaw

三条命令都应该没有返回结果。

注意事项

  • 建议重启 —— 清理完成后重启机器或至少重新登录,确保所有用户服务已停止。
  • 废弃旧 API Key —— 如果你在 OpenClaw 里绑定过 API Key(如 OpenAI、Claude 的密钥),强烈建议去对应官网废弃旧 Key,生成新的 Key,以防万一。
  • 远程模式 —— 如果你用过远程模式,状态目录在网关主机上,需要在那台机器上也执行清理步骤。
  • 源码安装 —— 如果你是通过 git clone 运行的 OpenClaw,请先卸载网关服务,再删除 repo 目录和状态文件。

如何在 Linux 上卸载 OpenClaw