Table of Contents
The Codex CLI is OpenAI's open-source coding agent that runs directly in your terminal. Built in Rust for speed, it can read your repository, edit files, run commands, and execute your test suite — all from the command line. It's fully supported on macOS and Linux, making it a natural fit for developers working on a Linux VPS or a local Mac. This guide walks you through the full setup using the official instructions from developers.openai.com/codex/cli.
Codex CLI is included with every ChatGPT plan — Plus, Pro, Business, Edu, and Enterprise. You can also use it with an OpenAI API key.
ChatGPT Codex CLI — Official Docs
View the official Codex CLI setup guide and full reference from OpenAI.
View Official Docs →Step 1: Choose Your Install Method
The Codex CLI offers two installation methods on macOS and Linux:
- npm — works on both macOS and Linux. Recommended if you already have Node.js installed.
- Homebrew — macOS only. Preferred if you use Homebrew to manage your packages.
Pick the one that fits your setup. Both install the same CLI with the same features.
Step 2a: Install via npm (macOS and Linux)
Make sure you have Node.js installed. You can check by running:
node -v
If Node.js is not installed, get it from nodejs.org or install it via your package manager:
# Ubuntu / Debian
sudo apt install nodejs npm -y
# macOS (via Homebrew)
brew install node
Once Node.js is ready, install the Codex CLI globally with npm:
npm i -g @openai/codex
The -g flag installs Codex globally so you can run it from any directory.
Step 2b: Install via Homebrew (macOS only)
If you're on macOS and prefer Homebrew, you can install the Codex CLI without needing Node.js separately. Make sure Homebrew is installed, then run:
brew install codex
Homebrew will handle all dependencies automatically.
Step 3: Run Codex for the First Time
Navigate to your project directory in the terminal, then launch Codex:
codex
On first launch, Codex will prompt you to sign in. You can authenticate using either:
- Your ChatGPT account — covers Plus, Pro, Business, Edu, and Enterprise plans.
- An OpenAI API key — for API-based usage billed per token.
Follow the on-screen prompt to complete authentication. Once signed in, Codex opens an interactive terminal UI (TUI) session inside your current directory.
Step 4: Send Your First Task
With Codex running, type a task in plain language and press Enter. For example:
Tell me about this project
Or something more specific:
Find and fix bugs in my codebase with minimal, high-confidence changes
Codex will read your repository structure, propose file edits, and can run commands and tests — all within the directory you launched it from.
Step 5: Keep Codex Up to Date
OpenAI releases updates to the Codex CLI regularly. To upgrade to the latest version via npm:
npm i -g @openai/codex@latest
If you installed via Homebrew:
brew upgrade codex
Check the official changelog to see what's new in each release.
Related Guide
Linux VPS Hosting — High-Performance Ubuntu & Debian ServersRun the Codex CLI on a fast Linux VPS and keep your AI coding agent active around the clock.
The Codex CLI is now installed and ready to use on macOS or Linux. Once authenticated, you can point it at any project directory and start delegating coding tasks directly from your terminal.
Need a Linux Server for This?
Run Debian, Ubuntu, or any Linux distro on DropVPS — fast NVMe SSD, full root access, and 24/7 support. Perfect for everything you just read.
- Full Root Access
- Debian & Ubuntu Ready
- 99.99% Uptime
- 24/7 Support
No commitment · Cancel anytime
