Install Codex CLI on Mac, Windows and Linux: a step-by-step guide
To install the Codex CLI, run OpenAI's one-line installer: curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS or Linux, or the PowerShell command below on Windows. You can also install it with npm install -g @openai/codex or brew install --cask codex. Then open a project folder, run codex, and sign in with your ChatGPT account or an API key.

Codex CLI install commands
| Method | Install | Update |
|---|---|---|
| Installer, macOS and Linux | curl -fsSL https://chatgpt.com/codex/install.sh | sh | Run the same command again |
| Installer, Windows PowerShell | powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" | Run the same command again |
| npm | npm install -g @openai/codex | npm install -g @openai/codex |
| Homebrew | brew install --cask codex | brew upgrade --cask codex |
All four give you the same Codex CLI. The standalone installer is OpenAI's first suggestion for each system; npm suits people who already manage tools with Node.js, and Homebrew suits Mac users who keep everything in brew.
Source: Codex CLI, OpenAI
Before you install
- A ChatGPT plan that includes Codex in the CLI, such as Plus, Pro, Business or Enterprise, or an OpenAI API key. Free and Go list Codex in the desktop app, subject to rollout.
- A project in a Git repository. Codex needs one by default to protect against destructive changes, and Git checkpoints let you undo its edits.
- For the npm method, Node.js and npm already installed. For Homebrew, Homebrew installed.
- On Windows, a new PowerShell window for the installer, or WSL2 if you want Codex to run inside Linux.
Source: Pricing, OpenAI
Install the Codex CLI on macOS
- Open Terminal.
- Run the installer: curl -fsSL https://chatgpt.com/codex/install.sh | sh. Or, with Homebrew, run brew install --cask codex.
- Open a new Terminal window so your shell picks up the new command.
- Go to a project folder with cd, and run codex.
- Choose Sign in with ChatGPT and finish the sign-in in your browser.
curl -fsSL https://chatgpt.com/codex/install.sh | shcd ~/code/my-projectcodex
On macOS, Codex uses the system's built-in Seatbelt sandbox to limit what its commands can touch.
Source: Codex CLI, OpenAI
Install the Codex CLI on Windows
You have two good options on Windows: run Codex natively in PowerShell, where it uses a Windows sandbox, or run it inside WSL2, where it behaves like it does on Linux.
Native Windows with PowerShell
- Open a new PowerShell window.
- Run: powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
- Open a new PowerShell window, go to your project folder, and run codex.
- Sign in with ChatGPT in the browser window that opens.
- If Codex asks to set up its sandbox, follow the prompt.
Codex supports three Windows sandboxes. mxc is the recommended one on compatible devices and needs no administrator setup, extra Windows accounts or firewall rules. elevated is the fallback when mxc is not available and needs administrator-approved setup once; the /setup-default-sandbox slash command sets it up. unelevated is a last resort with weaker network isolation.
Source: Windows sandbox, OpenAI
Windows with WSL2
Choose WSL2 when you need Linux tools, when your repositories already live in WSL, or when the Windows sandboxes do not suit you. Inside WSL2, Codex uses the Linux sandbox instead of the Windows one. WSL1 is no longer supported: from Codex 0.115 the Linux sandbox moved to bubblewrap, which needs WSL2.
- Install WSL: open PowerShell as an administrator and run wsl --install. Ubuntu is a common choice.
- Open your WSL terminal and run the Linux installer: curl -fsSL https://chatgpt.com/codex/install.sh | sh
- Keep your projects inside the Linux file system, such as ~/code, then run codex there.
- To edit in VS Code, install the WSL extension and run code . from your WSL terminal, so VS Code's terminals also run in Linux.
Source: WSL, OpenAI
Install the Codex CLI on Linux
- Open a terminal.
- Run: curl -fsSL https://chatgpt.com/codex/install.sh | sh
- Open a new terminal, go to your project and run codex.
- Sign in. On a server without a browser, use device code sign-in, below.
On Linux, Codex sandboxes its commands with bubblewrap. The npm method works on Linux too, if you prefer it.
Source: Codex CLI, OpenAI
Install the Codex CLI with npm
If you already use Node.js, one command installs Codex globally on any system:
npm install -g @openai/codexRun the same command to update.
Sign in after installing
The first time you run codex, it asks how to sign in. You have three main choices:
| Sign-in | How | Best for |
|---|---|---|
| ChatGPT account | Run codex or codex login and finish in the browser | Using the Codex allowance in your ChatGPT plan |
| API key | printenv OPENAI_API_KEY | codex login --with-api-key | Pay-as-you-go usage, scripts and CI |
| Device code (beta) | codex login --device-auth, then enter the code on any device | Servers, SSH sessions and networks that block the browser callback |
Device code sign-in must be turned on first in your ChatGPT security settings, or by your workspace admin. If it is not available, OpenAI's fallback is to sign in on a computer with a browser, then copy the saved login file at ~/.codex/auth.json to the same place on the headless machine. Treat that file like a password. codex login status tells you whether you are signed in, and codex logout removes saved credentials.
Source: Authentication, OpenAI
Check that the Codex CLI works
- Run codex in a project folder. The interactive screen should open.
- Type "Tell me about this project". Codex should read some files and describe the project.
- Run /status to see the model, the permission settings and which folders Codex can write to.
- If anything looks wrong, run codex doctor in your shell. It writes a report checking installation, configuration, sign-in, Git and terminal health.
Source: Developer commands, OpenAI
Choose your first permission settings
When Codex starts in a folder under Git, it suggests the Auto preset: it can read, edit and run commands in that folder, and asks before editing outside it or using the network. In a folder without Git it suggests read-only. You can start read-only to ask questions and plan, then switch with /permissions when you want edits.
| Preset | Command | Use it for |
|---|---|---|
| Auto | codex (in a Git folder) | Everyday coding |
| Read-only | codex --sandbox read-only --ask-for-approval on-request | Questions, reviews and planning |
| Full access | codex --yolo | Only inside a disposable sandbox machine |
Source: Agent approvals and security, OpenAI
Set up Codex after installing
A few minutes of setup makes the first week smoother.
Create an AGENTS.md for your project
Run /init in your project folder. Codex writes an AGENTS.md scaffold with instructions it reads at the start of every session. Review it, add the commands to build and test, edit anything that does not match how your project works, and commit it so every future session, and every teammate's Codex, starts with the same rules.
Bring in your Claude Code or Cursor setup
If you already use Claude Code or Cursor, type /import, choose which one, and pick the setup, project files or recent chats to bring across. Codex looks for up to 50 chats from the last 30 days. Wait until any current task finishes before you start an import.
Turn on shell completions
codex completion prints a completion script for Bash, the Z shell, Fish or PowerShell. For the Z shell, add eval "$(codex completion zsh)" to your shell configuration; if it reports command not found: compdef, put autoload -Uz compinit && compinit before it. Restart the shell, type codex and press Tab to check.
eval "$(codex completion zsh)"Pick a theme and an editor for long prompts
Run /theme to preview syntax-highlighting themes and save one. For long prompts, press Ctrl+G in the prompt box to open the editor set in your VISUAL or EDITOR variable; save and close it to send the text back to Codex.
Source: CLI customization, OpenAI
Connect an MCP server
MCP servers give Codex extra tools, such as documentation search or access to your issue tracker. Add one from your shell with codex mcp add, giving it a name and the command that starts the server. OpenAI's example adds Context7, a free MCP server for developer documentation:
codex mcp add context7 -- npx -y @upstash/context7-mcpcodex mcp list
For a server that signs in with OAuth, run codex mcp login and the server name; on a machine without a browser, add --no-browser, open the printed link elsewhere and paste the full redirect address back into the terminal. Inside a session, /mcp shows the servers that are active.
Source: Connect Codex to MCP servers, OpenAI
Where Codex keeps its files
Codex stores its settings and state in a folder called CODEX_HOME, which is ~/.codex unless you change it. Inside are config.toml with your settings, auth.json with your login when credentials are stored in a file rather than your system keychain, history.jsonl when history is turned on, and logs and caches. A global AGENTS.md here applies to every project. Back up config.toml if you customise it, and never share auth.json.
Source: Advanced configuration, OpenAI
Keep the Codex CLI up to date
Re-run the installer, run npm install -g @openai/codex, or brew upgrade --cask codex, depending on how you installed it. codex update checks for and applies an update when your release supports self-update.
Source: Developer commands, OpenAI
Install the Codex CLI in CI and GitHub Actions
On a build server you can install Codex with npm or the installer like anywhere else, sign in with an API key piped into codex login --with-api-key, and run tasks with codex exec, which runs read-only unless you add --sandbox workspace-write. On GitHub, OpenAI's Codex GitHub Action, openai/codex-action@v1, does the install for you: it installs the Codex CLI and runs codex exec under the permissions you set. You store your OpenAI key as a GitHub secret, run the job on a Linux or macOS runner, check out the code first, and give the prompt inline or as a file in the repository.
Source: Codex GitHub Action, OpenAI
Prefer an editor or a window? Install those instead
The CLI is one of three ways to use Codex locally, and all three share your sign-in. If you would rather work inside your editor, install the Codex IDE extension: in VS Code, Cursor or Windsurf, install the extension named openai.chatgpt, then choose the Codex icon, or run Codex: Open Codex Sidebar from the Command Palette. Xcode and JetBrains IDEs have their own Codex integrations. If you want a window with several chats side by side, install the ChatGPT desktop app for macOS, Windows or Linux and choose Codex from its menu. Many people install the CLI and one of these, then move a session between them: /app in the CLI continues the current session in the desktop app.
Source: Codex IDE extension, OpenAI
Codex CLI install problems and fixes
codex: command not found
Your shell has not picked up the new command yet. Open a new terminal window. If it still fails with npm, check that npm's global folder is on your PATH; with the installer, re-run it and read the last lines it prints.
The browser sign-in never finishes
The sign-in returns your login to the CLI through a local callback, which remote machines and some networks block. Use codex login --device-auth instead, or copy ~/.codex/auth.json from a computer where sign-in works.
Codex will not run outside a Git repository
Codex requires a Git repository by default to prevent destructive changes. Run git init in the folder, or for codex exec only, add --skip-git-repo-check when you are sure the folder is safe.
Codex fails in WSL1
WSL1 was supported only up to Codex 0.114. Convert your distribution to WSL2, or run Codex natively in PowerShell.
Commands are blocked on Windows
If the recommended mxc sandbox is not available on your device, run /setup-default-sandbox to set up the elevated sandbox, which needs an administrator to approve it once.
After installing: run more than one agent
Once the Codex CLI works, the next step for many people is running several Codex sessions at once, each in its own Git worktree, often alongside Claude Code. 10u is an AI coding agent dashboard that shows every Codex and Claude Code session side by side, each in its real terminal, marked Needs you, Working, Waiting or Parked, so a session waiting for your approval never sits unseen. It runs on the subscriptions you already have. They do the building. You decide what gets built.

Questions people ask
- Does the Codex CLI work without internet access?
- Codex needs to reach OpenAI to run its models, but by default the commands it runs on your computer have no network access. It asks before running anything that needs the network.
- Should I install the Codex CLI or the IDE extension?
- Install the CLI for terminal work and scripts, and the IDE extension to work beside your open files in VS Code, Cursor or Windsurf. They share your sign-in, so you can use both.
- Where does the Codex CLI store its settings?
- In CODEX_HOME, which is ~/.codex by default: config.toml holds your settings, and auth.json holds your login when it is stored in a file rather than your keychain.
- How do I install the Codex CLI?
- On macOS or Linux run curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows run the PowerShell installer from OpenAI. Or use npm install -g @openai/codex or brew install --cask codex on any supported system.
- Can I install the Codex CLI on Windows?
- Yes. Install it natively from a new PowerShell window, where it uses a Windows sandbox, or install the Linux version inside WSL2. WSL1 is not supported from Codex 0.115.
- Do I need Node.js to install Codex?
- No. The standalone installers and Homebrew do not need Node.js. Only the npm method does.
- How do I sign in to the Codex CLI on a server?
- Run codex login --device-auth, open the link on any device, sign in and enter the one-time code. Turn on device code login in your ChatGPT security settings first.
- How do I update the Codex CLI?
- Run your install command again, or use npm install -g @openai/codex or brew upgrade --cask codex. codex update works when your release supports self-update.