How to Install Codex CLI on Linux: A 15-Minute Tutorial
How to Install Codex CLI on Linux: A 15-Minute Tutorial
OpenAI released Codex CLI in 2026 — a terminal-based coding agent like Claude Code. Here’s the full install on Linux, plus 5 real workflows.
Install (Ubuntu/Debian, 15 min)
# 1. Install Node.js 20+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# 2. Install Codex CLI globally
npm install -g @openai/codex
# 3. Authenticate
codex login
# 4. Verify
codex --version
# Should print: 1.x.x
That’s it. Total time: 10-15 min including download.
5 Real Workflows I Tested (1 month)
1. Single-file refactor
codex "Refactor src/auth.js to use async/await"
2. Multi-file feature
codex "Add rate limiting to /api endpoints using express-rate-limit"
3. Test generation
codex "Write Jest tests for src/utils.js"
4. Bug fix
codex "Fix the race condition in src/sync.js"
5. Documentation
codex "Generate JSDoc comments for all functions in src/api/"
Comparison vs Claude Code
| Feature | Codex CLI | Claude Code |
|---|---|---|
| Model | GPT-4o / GPT-5 | Claude 3.5/4 Sonnet |
| Setup time | 15 min | 10 min |
| Cost | Pay-per-token | Pay-per-token |
| Best for | OpenAI ecosystem | Long autonomous tasks |
| Tool ecosystem | Newer, smaller | Mature, larger |
My Verdict
Codex CLI is solid for OpenAI users who want a terminal coding agent. If you’re already paying for OpenAI API, this is the natural choice.
Use Claude Code if: you want the most mature agent with the best tool ecosystem. Use Codex CLI if: you’re on the OpenAI stack and want terminal coding.
FAQ
Q: Does Codex CLI work on macOS?
A: Yes, same npm install -g works.
Q: Can I use GPT-4o with it?
A: Yes, default is GPT-4o. You can switch to GPT-5 with codex config.
Q: Is it free? A: No, pay-per-token like OpenAI API.
Q: Can I use it offline? A: No, requires OpenAI API.
Recommended
If you’re on OpenAI stack: Codex CLI is the natural choice. If you’re on Anthropic stack: Use Claude Code. If you want local + free: Use Aider + MiMo (see other articles).