How to Install Codex CLI

To install OpenAI's Codex CLI, run curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS or Linux, or the PowerShell installer on Windows (npm install -g @openai/codex and brew install --cask codex also work), then run codex in a project folder and sign in with ChatGPT. Steps for every system, WSL, updating, removing and fixing common problems, as of Nov 6, 2026.

To install Codex CLI on a Mac or Linux, run curl -fsSL https://chatgpt.com/codex/install.sh | sh in a terminal; on Windows, open a new PowerShell window and run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". Then type codex in a project folder and choose Sign in with ChatGPT (OpenAI docs). npm (npm install -g @openai/codex) and Homebrew (brew install --cask codex) work too. Every ChatGPT plan includes Codex, Free and Go too, so no extra subscription is needed to try it (Codex Pricing and Limits).

This guide covers each system step by step. What the CLI can do once it runs is on Codex CLI. If you would rather not use a terminal, the Codex App (the Codex view of the ChatGPT desktop app) and the Codex IDE Extension do the same work.

Quick facts

macOS and Linux curl -fsSL https://chatgpt.com/codex/install.sh | sh (docs)
Windows (PowerShell) powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
npm npm install -g @openai/codex
Homebrew brew install --cask codex
Update Run the same installer again; Homebrew: brew upgrade --cask codex
Check the version codex --version (Troubleshooting)
Latest version 0.166.0, Oct 29, 2026
WSL WSL2 only; WSL1 stopped working after 0.114

Install Codex CLI on macOS

  1. Open Terminal.
  2. Run curl -fsSL https://chatgpt.com/codex/install.sh | sh. If you use Homebrew, run brew install --cask codex instead.
  3. Check it worked: codex --version prints the version.
  4. Go to a project: cd ~/code/my-project.
  5. Run codex, choose Sign in with ChatGPT, and finish signing in in the browser window that opens.

Source: Codex CLI, Authentication, OpenAI docs, read Nov 6, 2026. On macOS the sandbox uses Apple's built-in Seatbelt framework, so nothing else needs installing (Sandboxing). Codex may ask for access to protected folders such as Music, Downloads or Desktop if a task reaches into your home folder; macOS shows its own prompt for each (Troubleshooting).

Install Codex CLI on Linux

  1. Open a terminal.
  2. Run curl -fsSL https://chatgpt.com/codex/install.sh | sh, or npm install -g @openai/codex if you prefer npm.
  3. Run codex --version to check, then codex inside a project folder and sign in.

On Linux the sandbox uses bubblewrap (bwrap), with a bundled helper as a fallback (Sandboxing). On a server with no browser, sign in with codex login --device-auth (see Sign in without a browser below).

Install Codex CLI on Windows

  1. Open a new PowerShell window (Windows Terminal works).
  2. Run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex".
  3. Open a project folder in PowerShell and run codex, then sign in.

Source: Codex CLI, read Nov 6, 2026. Codex runs natively on Windows, with a Windows sandbox around its commands. The recommended sandbox, MXC, needs no administrator setup on compatible devices; the older elevated sandbox needs administrator approval once, and /setup-default-sandbox in the CLI sets it up (Windows sandbox, Developer commands). codex doctor checks a broken installation on any system (Developer commands).

Install Codex CLI in WSL

Use WSL2 when your code and tools already live in Linux. In WSL, Codex runs inside Linux and uses the Linux sandbox instead of the Windows one (Windows WSL).

  1. In an administrator PowerShell, run wsl --install (Ubuntu is the usual choice), then wsl to open a Linux shell.
  2. In that shell, run curl -fsSL https://chatgpt.com/codex/install.sh | sh.
  3. Run codex.

Keep repositories under your Linux home folder (~/code/my-app), not under /mnt/c/...: Windows-mounted paths are slower and cause more symlink and permission trouble. WSL1 was supported through Codex 0.114; from 0.115 the Linux sandbox needs bubblewrap, so WSL1 no longer works (Windows WSL).

Install Codex CLI with npm or Homebrew

  • npm, on any system with Node.js: npm install -g @openai/codex. Run the same command to update.
  • Homebrew, on macOS: brew install --cask codex; update with brew upgrade --cask codex.

Source: Codex CLI, read Nov 6, 2026. The CLI's package is @openai/codex; the programming library is a separate package, @openai/codex-sdk (see Codex SDK).

Sign in

Codex offers two kinds of sign-in for local work (Authentication):

  • Sign in with ChatGPT uses your plan's included Codex usage. Run codex (or codex login) and complete the browser flow. Codex Cloud works only this way.
  • API key bills usage at API prices: printenv OPENAI_API_KEY | codex login --with-api-key. Get a key from the OpenAI dashboard. See OpenAI API Pricing.

codex login status exits with 0 when credentials are present, and codex logout removes them (Developer commands). Codex caches the login in ~/.codex/auth.json or in your system's credential store; treat that file like a password (Authentication).

Sign in without a browser

On a remote or headless machine the browser flow may fail. Use device code sign-in (beta): turn on device code login in your ChatGPT security settings (or ask a workspace admin), run codex login --device-auth, open the link on any device and enter the one-time code. If that is not available, sign in on a machine with a browser and copy ~/.codex/auth.json to the same place on the remote machine, or forward the sign-in callback port with ssh -L 1455:localhost:1455 user@remote (Authentication).

Run a first task

In the project folder, run codex and ask something safe first, such as "Tell me about this project". Make a Git commit before and after each task so you can undo changes (Codex CLI). By default Codex can edit files and run commands only inside the folder, with the network off, and asks before doing more (Agent approvals and security). Type /init to have Codex write an AGENTS.md file with your project's rules.

Update Codex CLI

  • Standalone installer (macOS, Linux, Windows): run the install command again.
  • npm: npm install -g @openai/codex.
  • Homebrew: brew upgrade --cask codex.
  • Any install where the release supports self-update: codex update.

Source: Codex CLI, Developer commands, read Nov 6, 2026. Some models need a recent CLI: GPT-6 Astra needs 0.153.0 or newer and GPT-6.1 Terra 0.159.0 or later.

Uninstall Codex CLI

OpenAI's documentation read on Nov 6, 2026 gives no uninstall steps for the standalone installers. For npm and Homebrew installs, remove the package with that package manager (npm uninstall -g @openai/codex, or brew uninstall --cask codex). Your settings, chats and cached login live in the Codex home folder, ~/.codex unless CODEX_HOME points elsewhere (AGENTS.md docs, Authentication); delete it only if you want them gone. On Windows, if you set up the legacy elevated sandbox, codex sandbox uninstall run as administrator removes its machine-wide accounts and network rules (Developer commands).

Troubleshooting

"npm.ps1 cannot be loaded because running scripts is disabled on this system." PowerShell's execution policy is blocking npm's scripts. OpenAI's suggested fix is Set-ExecutionPolicy -ExecutionPolicy RemoteSigned; read Microsoft's guide to execution policies before changing it (Windows app).

codex is not found after an npm install. npm's global folder is not on your PATH. Add it, or open a new terminal after installing. (OpenAI gives the same advice for its codex-security package; Codex Security CLI.)

Sign-in hangs or never returns to the terminal. Your network may block the local callback Codex uses after the browser sign-in. Use codex login --device-auth, or forward port 1455 over SSH (Authentication).

Certificate errors behind a company proxy. Set CODEX_CA_CERTIFICATE to your company's PEM certificate bundle before codex login (Authentication).

A feature works in the CLI but not in the app, or the other way round. The CLI and the ChatGPT desktop app can carry different Codex versions; compare them with codex --version (Troubleshooting).

Slow in WSL. Move the repository out of /mnt/c into your Linux home folder (Windows WSL).

Anything else. Run codex doctor for a report on installation, configuration, sign-in, Git and the terminal, and include it when you ask for help (Developer commands). General ChatGPT outages are covered on ChatGPT Not Working.

Frequently asked questions

How do I install Codex CLI on Windows? Open a new PowerShell window and run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex", then run codex in a project folder and sign in with ChatGPT. You can also install Codex CLI inside WSL2 with the Linux command.

What is the npm package for Codex CLI? The Codex CLI's npm package is @openai/codex: install it with npm install -g @openai/codex and run the same command to update.

Do I need a paid ChatGPT plan to use Codex CLI? No. Codex CLI works with every ChatGPT plan, including Free and Go, though free use is limited; you can also sign in with an OpenAI API key and pay per token.

How do I update Codex CLI? Run the same install command again (curl, PowerShell or npm), use brew upgrade --cask codex with Homebrew, or run codex update where your release supports it.

How do I sign in to Codex CLI on a server without a browser? Run codex login --device-auth and enter the one-time code on another device, after turning on device code login in your ChatGPT security settings. Copying ~/.codex/auth.json from a machine where you already signed in also works.

Does Codex CLI work in WSL1? No. Codex CLI supported WSL1 through version 0.114; from 0.115 it needs WSL2, because its Linux sandbox uses bubblewrap.

Sources

Moments

Using OpenAI Codex CLI with GPT-5-Codex

OpenAI

  1. To install Codex CLI on a Mac or Linux, run curl -fsSL https://chatgpt.com/codex/install.sh | sh in a terminal; on…

OpenAI Codex CLI

OpenAI

  1. In the project folder, run codex and ask something safe first, such as "Tell me about this project". Make a Git commit…

See also

About this page

Last updated Nov 6, 2026 by the Vi.ki team. Page text CC BY-SA 4.0.

Edit History

Hotkeys

/
Jump to the search box
? or Ctrl + /
Open this list
Esc
Close this list, the photo viewer, or the account menu

Video

Space or K
Play or pause
← →
Back or forward 5 seconds
J L
Back or forward 10 seconds
0 to 9
Go to 0% to 90% of the video
, .
Previous or next frame, while paused
M
Mute or unmute
C
Captions on or off
F
Full screen on or off
A D
Previous or next moment

Photo viewer

← → or A D
Previous or next photo
↑ ↓ or W S
Previous or next photo
Home End
First or last photo
I
Show or hide the photo's info
Z
Clickless on or off: a pointer over a thumbnail shows it
N
Compare with the last photo: back to the one shown before this, and N again comes back
Q
Move the thumbnails to the next edge: top, bottom, left and round
, or Ctrl + ,
Open or close the viewer's settings
V
Clickless pan: a zoomed photo follows the pointer, rather than being dragged
Shift
Browse on or off
B
Show or hide the button bar
T
Show or hide the thumbnails
1
100% zoom on or off
0
Rate the photo as no opinion; again takes the answer back
+ -
Rate the photo a step higher or lower
F
Full screen: the photo alone. F again puts everything back.
Back to top