OpenClaw 终端命令详解
3/23/2026 / 19 minutes to read / Tags: openclaw, cli
OpenClaw 提供了丰富的命令行工具,让你管理 Gateway、配置消息通道、控制 Agent 等。本文详细介绍所有主要命令。
基本用法
openclaw [options] [command]全局选项
| 选项 | 说明 |
|---|---|
--dev | 开发模式:状态隔离到 ~/.openclaw-dev,默认端口改为 19001 |
--profile <name> | 使用命名配置,状态隔离到 ~/.openclaw-<name> |
--no-color | 禁用 ANSI 颜色输出 |
--log-level <level> | 日志级别:silent/fatal/error/warn/info/debug/trace |
-h, --help | 显示帮助 |
-V, --version | 显示版本号 |
初始化命令
openclaw setup
初始化配置和工作空间。
openclaw setup # 交互式初始化openclaw setup --wizard # 启动向导openclaw setup --workspace <dir> # 指定工作空间路径openclaw onboard
交互式初始化向导,设置 Gateway、工作空间和技能。
openclaw onboard # 交互式向导openclaw onboard --install-daemon # 安装并启动守护服务openclaw onboard --reset # 重置后重新配置openclaw configure
交互式配置向导(模型、通道、技能、Gateway)。
openclaw config
非交互式配置操作。
openclaw config get <path> # 获取配置值openclaw config set <path> <value> # 设置配置值openclaw config unset <path> # 删除配置值openclaw config file # 显示配置文件路径openclaw config validate # 验证配置Gateway 管理
openclaw gateway
管理 WebSocket Gateway 服务。
# 服务管理openclaw gateway status # 查看状态openclaw gateway start # 启动服务openclaw gateway stop # 停止服务openclaw gateway restart # 重启服务openclaw gateway install # 安装系统服务openclaw gateway uninstall # 卸载系统服务
# 运行选项openclaw gateway --port 18789 # 指定端口openclaw gateway --bind lan # 绑定地址:loopback/lan/tailnet/autoopenclaw gateway --token <token> # 访问令牌openclaw gateway --force # 强制杀死占用端口的进程openclaw logs
查看 Gateway 日志。
openclaw logs --follow # 实时跟踪openclaw logs --limit 200 # 限制行数openclaw logs --json # JSON 格式输出openclaw status
查看会话健康状态和最近收件人。
openclaw status # 基本状态openclaw status --deep # 深度检查(包含通道探测)openclaw status --usage # 显示模型用量配额openclaw health
从运行中的 Gateway 获取健康状态。
openclaw health --jsonopenclaw health --timeout 5000消息通道
openclaw channels
管理聊天通道账号。
# 查看和状态openclaw channels list # 列出已配置通道openclaw channels status # 检查通道健康openclaw channels logs # 查看通道日志
# 添加和移除openclaw channels add --channel telegram --token $TOKENopenclaw channels add --channel discord --token $TOKENopenclaw channels remove --channel discord --account work
# 登录登出openclaw channels login --channel whatsappopenclaw channels logout --channel whatsapp支持的通道:whatsapp、telegram、discord、slack、signal、googlechat、imessage、msteams
消息发送
openclaw message
统一的消息发送接口。
# 发送消息openclaw message send --target +15555550123 --message "Hi"openclaw message send --channel discord --target channel:123 --message "Hello"
# 其他操作openclaw message read --channel whatsappopenclaw message edit --target <id> --message "New text"openclaw message delete --target <id>openclaw message react --target <id> --emoji 👍
# 投票(Discord)openclaw message poll --channel discord --target channel:123 \ --poll-question "Snack?" --poll-option Pizza --poll-option SushiAgent 管理
openclaw agent
运行一次 Agent 对话。
openclaw agent --message "帮我总结今天的新闻"openclaw agent --to +15555550123 --message "Hello" --deliveropenclaw agent --local # 本地模式(不通过 Gateway)openclaw agents
管理隔离的 Agent 实例。
openclaw agents list # 列出所有 Agentopenclaw agents add --workspace ./my-agent --model gpt-4openclaw agents delete <id> # 删除 Agentopenclaw agents bind --agent <id> --bind telegramopenclaw agents unbind --agent <id> --bind telegram模型配置
openclaw models
管理 AI 模型配置。
# 查看模型openclaw models list # 列出可用模型openclaw models status # 模型状态和认证信息openclaw models status --probe # 实时探测模型可用性
# 设置默认模型openclaw models set gpt-4 # 设置默认文本模型openclaw models set-image dall-e-3 # 设置默认图像模型
# 模型别名和回退openclaw models aliases add fast gpt-3.5-turboopenclaw models fallbacks add gpt-3.5-turbo
# 认证配置openclaw models auth add # 交互式添加认证openclaw models auth setup-token --provider anthropic定时任务
openclaw cron
管理计划任务。
# 查看任务openclaw cron statusopenclaw cron list
# 添加任务openclaw cron add --name "daily-report" --every 1d \ --system-event "生成日报"
# 管理任务openclaw cron enable <id>openclaw cron disable <id>openclaw cron rm <id>openclaw cron run <id> --force # 立即执行技能管理
openclaw skills
查看和管理技能。
openclaw skills list # 列出所有技能openclaw skills list --eligible # 只显示可用的技能openclaw skills info <name> # 查看技能详情openclaw skills check # 检查技能依赖状态提示:使用 npx clawhub 搜索和安装更多技能。
浏览器控制
openclaw browser
控制专用浏览器实例。
# 管理浏览器openclaw browser statusopenclaw browser startopenclaw browser stop
# 标签页操作openclaw browser tabsopenclaw browser open https://example.comopenclaw browser close <targetId>
# 截图和快照openclaw browser screenshot --full-pageopenclaw browser snapshot --format ai
# 页面交互openclaw browser click <ref>openclaw browser type <ref> "Hello"openclaw browser navigate https://example.com节点管理
openclaw node
管理无头节点主机服务。
openclaw node run --host gateway-host --port 18789openclaw node statusopenclaw node installopenclaw node uninstallopenclaw nodes
与已配对的节点交互。
openclaw nodes list # 列出已配对节点openclaw nodes pending # 待审批请求openclaw nodes approve <requestId>openclaw nodes run --node <id> ls -la # 在节点上执行命令
# 摄像头和屏幕openclaw nodes camera snap --node <id>openclaw nodes screen record --node <id> --duration 10s
# 通知openclaw nodes notify --node <id> --title "提醒" --body "消息内容"诊断工具
openclaw doctor
健康检查和快速修复。
openclaw doctor # 交互式检查openclaw doctor --deep # 深度扫描openclaw doctor --non-interactive # 非交互模式openclaw security
安全审计工具。
openclaw security audit # 审计配置和状态openclaw security audit --deep # 深度探测openclaw security audit --fix # 自动修复安全问题其他实用命令
openclaw dashboard
打开浏览器控制面板。
openclaw tui
打开终端用户界面。
openclaw tuiopenclaw tui --session <key>openclaw tui --thinking highopenclaw docs
搜索官方文档。
openclaw docs gatewayopenclaw docs "how to setup telegram"openclaw qr
生成 iOS 配对二维码。
openclaw backup
创建和验证备份。
openclaw backup createopenclaw backup verify <archive>openclaw reset
重置本地配置和状态。
openclaw reset --scope config # 只重置配置openclaw reset --scope full # 完全重置openclaw update
更新 OpenClaw。
openclaw updateopenclaw update --check # 检查更新命令速查表
| 类别 | 命令 | 说明 |
|---|---|---|
| 初始化 | setup, onboard, configure | 安装和配置 |
| Gateway | gateway, logs, status, health | 服务管理 |
| 通道 | channels, message | 消息通道 |
| Agent | agent, agents | AI 助手 |
| 模型 | models | AI 模型配置 |
| 定时 | cron | 计划任务 |
| 技能 | skills | 技能管理 |
| 浏览器 | browser | 浏览器控制 |
| 节点 | node, nodes | 远程节点 |
| 诊断 | doctor, security | 健康检查 |
| 其他 | dashboard, tui, docs, qr | 工具 |
更多详情请访问 OpenClaw 官方文档
参考链接
← Back to blog