OpenClaw / OpenCode 运维与使用手册(完整版)
openclaw status
# 看总状态(最常用):Gateway、模型、通道、session、安全摘要
openclaw status --deep
# 深度检查:包含更多探测与诊断信息
openclaw gateway status
# 只看 Gateway 服务状态(是否可连、是否在运行)
openclaw gateway start
# 启动 Gateway 服务
openclaw gateway stop
# 停止 Gateway 服务
openclaw gateway restart
# 重启 Gateway(改配置后常用)
openclaw logs --follow
# 实时追踪日志(等价 tail -f 的体验)
openclaw onboard
# 使用默认交互式初始化(推荐)
openclaw configure
# 进入交互式配置流程(首次部署或调整设置)
openclaw configure --section gateway
# 只配置 gateway 区块(token、bind 等)
openclaw configure --section web
# 只配置 web_search 区块(例如 Brave API key)
openclaw security audit
# 安全检查(快速版)
openclaw security audit --deep
# 安全检查(深入版)
openclaw doctor
# 检查安装/服务异常并给出建议
openclaw doctor --repair
# 自动修复常见问题(服务文件、环境等)
openclaw doctor --fix
# 与 --repair 同义
openclaw gateway install
# 安装/确保 user-level systemd 服务(openclaw-gateway.service)
openclaw gateway install --force
# 强制重装 Gateway 服务
openclaw gateway uninstall
# 卸载 Gateway 服务
openclaw gateway probe
# 网关可达性与健康探测(本地/远程)
openclaw gateway health
# 拉取 Gateway health 信息
systemctl --user enable openclaw-gateway.service
# 设为用户层开机自启
systemctl --user start openclaw-gateway.service
# 启动服务
systemctl --user restart openclaw-gateway.service
# 重启服务
systemctl --user stop openclaw-gateway.service
# 停止服务
systemctl --user status openclaw-gateway.service --no-pager
# 查看服务状态(不分页)
journalctl --user -u openclaw-gateway.service -n 200 --no-pager
# 查看最近 200 行服务日志
journalctl --user -u openclaw-gateway.service -f
# 实时追踪服务日志
systemctl --user is-enabled openclaw-gateway.service
# 检查是否开机自启
systemctl --user is-active openclaw-gateway.service
# 检查是否正在运行
curl -fsSL https://opencode.ai/install | bash
# 安装 OpenCode(官方脚本)
opencode --version
# 查看版本,确认可用
opencode upgrade
# 升级 OpenCode
opencode uninstall
# 卸载 OpenCode
opencode auth list
# 查看已登录的供应商凭证
opencode auth login
# 新增供应商登录(OpenAI/Anthropic/...)
opencode auth logout
# 登出已配置供应商
opencode models openai
# 只列 OpenAI 提供商模型(若支持)
opencode run " 你的任务描述"
# 一次性执行任务(CLI 模式)
opencode run " 只回复当前使用的模型ID"
# 快速检查当前默认模型
opencode -m openai/gpt-5.3-codex
# 临时指定模型启动
opencode serve
# 启动 headless opencode server
opencode web
# 启动服务并打开 Web 界面
opencode session list
# 查看现有会话列表
opencode session delete < sessionID>
# 删除指定会话
opencode stats
# 查看 token/cost 统计
opencode export
# 导出 session 数据(JSON)
opencode export < sessionID>
# 导出指定会话
opencode import < file_or_url>
# 导入 session 数据