[特殊字符] OpenClaw CLI 常用命令速查
在使用 openclaw-cn(中文社区版) 或 openclaw(官方版) 时,CLI 是最核心的操作入口。
两者命令完全一致,唯一差别只是二进制名称:
openclaw-cn # 中文版
openclaw # 官方版
👉 本文统一使用 openclaw-cn
📦 一、安装与初始化
1️⃣ 全局安装
sudo npm i -g openclaw-cn
2️⃣ 安装不同版本
# 稳定版
sudo npm i -g openclaw-cn@latest
# 测试版
sudo npm i -g openclaw-cn@beta
3️⃣ 初始化(强烈推荐)
# 交互式(推荐)
openclaw-cn onboard
# 快速模式
openclaw-cn onboard --flow quickstart
# 自动化(CI/CD)
openclaw-cn onboard --non-interactive \
--auth-choice token \
--token-provider anthropic \
--token "$TOKEN"
⚙️ 二、配置管理(Config)
查询配置
openclaw-cn config get agents.defaults.model.primary
openclaw-cn config get gateway.port
修改配置
openclaw-cn config set agents.defaults.model.primary "doubao-code"
openclaw-cn config set gateway.port 19001 --json
删除配置
openclaw-cn config unset tools.web.search.apiKey
🌐 三、网关(Gateway)
👉 核心组件,所有消息/Agent 都依赖它
启动网关
openclaw-cn gateway run --bind loopback --port 18789
强制启动(端口占用时)
openclaw-cn gateway run --force
后台运行(生产环境)
nohup openclaw-cn gateway run --bind loopback --port 18789 --force \
> /tmp/clawdbot-gateway.log 2>&1 &
服务化管理
openclaw-cn gateway install
openclaw-cn gateway start
openclaw-cn gateway stop
openclaw-cn gateway restart
状态检查
openclaw-cn gateway status
openclaw-cn gateway health
openclaw-cn gateway probe
日志查看
openclaw-cn logs --follow
openclaw-cn logs --limit 200 --json
🤖 四、模型管理(Models)
查看状态
openclaw-cn models status
openclaw-cn models status --probe
列出模型
openclaw-cn models list
设置默认模型
openclaw-cn models set volcengine/doubao-code
Token 管理
openclaw-cn models auth add
openclaw-cn models auth paste-token
自动扫描模型
openclaw-cn models scan --set-default
📡 五、渠道(Channels)
支持:Telegram / Discord / Slack / WhatsApp
添加渠道
openclaw-cn channels add --channel telegram --token "$TOKEN"
查看状态
openclaw-cn channels status --probe
删除渠道
openclaw-cn channels remove --channel telegram
🧠 六、Agent(代理)
创建 Agent
openclaw-cn agents add work --workspace ~/clawd-work
单次调用
openclaw-cn agent --message "你好"
设置身份
openclaw-cn agents set-identity --name "Clawd" --emoji "🦞"
💬 七、消息发送
发消息
openclaw-cn message send \
--channel telegram \
--target "123456" \
--message "你好"
发文件
openclaw-cn message send --media ./photo.jpg
🧪 八、诊断与运维(重点)
一键健康检查
openclaw-cn doctor
openclaw-cn status --deep
openclaw-cn models status --probe
👉 推荐组合:
openclaw-cn doctor && \
openclaw-cn status --deep && \
openclaw-cn models status --probe
🔌 九、插件系统(Plugins)
安装插件
openclaw-cn plugins install <plugin>
启用 / 禁用
openclaw-cn plugins enable <plugin-id>
openclaw-cn plugins disable <plugin-id>
🧩 十、Hooks(自动化关键)
openclaw-cn hooks enable session-memory
openclaw-cn hooks enable command-logger
👉 常用:
| Hook | 作用 |
|---|---|
| session-memory | 自动记忆 |
| boot-md | 启动执行脚本 |
| command-logger | 审计日志 |
⏰ 十一、定时任务(Cron)
# 每天执行
openclaw-cn cron add --every 24h --system-event "生成日报"
# 指定时间
openclaw-cn cron add --at "2026-03-03T09:00:00" --message "开会提醒"
🧠 十二、语义记忆(Memory)
openclaw-cn memory index
openclaw-cn memory search "发布流程"
👉 本质:RAG(向量检索)
🧱 十三、沙盒(Sandbox)
openclaw-cn sandbox list
openclaw-cn sandbox recreate --all
👉 用于安全执行代码
🌍 十四、浏览器自动化
openclaw-cn browser open https://example.com
openclaw-cn browser screenshot --full-page
🖥️ 十五、远程节点(Nodes)
openclaw-cn nodes list
openclaw-cn nodes run --node <id> -- ls -la
👉 类似远程 Agent 执行器
🔄 十六、更新与重置
# 更新
openclaw-cn update
# 重置配置
openclaw-cn reset --scope config
# 完全重置
openclaw-cn reset --scope full --yes
🧰 十七、实用工具
openclaw-cn dashboard # Web UI
openclaw-cn tui # 终端 UI
openclaw-cn docs "Telegram"
🧨 十八、常见运维操作(高频)
✅ 重启网关
pkill -9 -f clawdbot-gateway || true
nohup openclaw-cn gateway run \
--bind loopback --port 18789 --force \
> /tmp/clawdbot-gateway.log 2>&1 &
✅ 验证运行状态
openclaw-cn channels status --probe
ss -ltnp | grep 18789
tail -n 120 /tmp/clawdbot-gateway.log
✅ 一键安装
sudo npm i -g openclaw-cn && openclaw-cn onboard
📁 配置路径说明
| 类型 | 路径 |
|---|---|
| 配置文件 | ~/.openclaw/openclaw.json |
| 凭证 | ~/.openclaw/credentials/ |
| 会话 | ~/.openclaw/sessions/ |
| 工作区 | ~/clawd |
| 日志 | /tmp/clawdbot-gateway.log |
🧭 总结
OpenClaw CLI 的核心可以抽象为 5 层:
模型(Models)
↓
Agent(智能体)
↓
Gateway(网关)
↓
Channels(渠道)
↓
用户
再叠加:
- Plugins(扩展能力)
- Hooks(自动化)
- Memory(记忆 / RAG)
- Nodes(远程执行)
👉 本质就是一个 本地 AI 操作系统(AI OS)
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)