Linux command
codex 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Launch interactive terminal UI
codex
Start with an initial prompt
codex "[fix the authentication bug]"
Run non-interactively and output results
codex exec "[refactor this function]"
Use a specific model
codex --model [gpt-5.2-codex]
Enable full auto mode for unattended work
codex --full-auto
Continue a previous session
codex resume --last
Attach an image for context
codex -i [screenshot.png] "[fix this UI bug]"
说明
Codex is OpenAI's official terminal-based coding agent. It launches into a full-screen terminal UI that can read your repository, suggest and implement code changes, and execute commands while you iterate conversationally. The tool maintains security through OS-level sandboxing with three safety modes: read-only (consultative, no changes), workspace-write (default, asks before touching files outside workspace), and danger-full-access (unrestricted, use with caution). Model-generated commands run in isolated environments using macOS seatbelt or Linux Landlock. Codex integrates with ChatGPT Plus, Pro, Business, and Enterprise subscriptions, or can be used with API credits. It supports cloud tasks for offloading complex work and provides MCP integration for extended capabilities.
参数
- --model, -m _MODEL_
- Override the default model (e.g., gpt-5.2-codex, codex-mini-latest)
- --sandbox, -s _POLICY_
- Sandbox policy: read-only, workspace-write, or danger-full-access
- --ask-for-approval, -a _MODE_
- Control approval timing: untrusted, on-failure, on-request, or never
- --full-auto
- Enable low-friction mode with on-request approvals and workspace-write sandbox
- --yolo
- Disable approvals and sandboxing (use only in hardened environments)
- --cd, -C _PATH_
- Set working directory before processing
- --add-dir _PATH_
- Grant additional directories write access
- --image, -i _PATH_
- Attach image files to the initial prompt
- --oss
- Use local open-source model via Ollama
- --search
- Enable web search capability
- --profile, -p _NAME_
- Load configuration profile from config.toml
- --help
- Display help information
FAQ
What is the codex command used for?
Codex is OpenAI's official terminal-based coding agent. It launches into a full-screen terminal UI that can read your repository, suggest and implement code changes, and execute commands while you iterate conversationally. The tool maintains security through OS-level sandboxing with three safety modes: read-only (consultative, no changes), workspace-write (default, asks before touching files outside workspace), and danger-full-access (unrestricted, use with caution). Model-generated commands run in isolated environments using macOS seatbelt or Linux Landlock. Codex integrates with ChatGPT Plus, Pro, Business, and Enterprise subscriptions, or can be used with API credits. It supports cloud tasks for offloading complex work and provides MCP integration for extended capabilities.
How do I run a basic codex example?
Run `codex` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --model, -m _MODEL_ do in codex?
Override the default model (e.g., gpt-5.2-codex, codex-mini-latest)