On this pageFirst, choose the right Codex product

How to Install Codex CLI on Windows, macOS and Linux

GauravXtrusio12 min read

Short answer

To install Codex CLI, use OpenAI's standalone installer for your operating system or the documented npm package, then open a project directory and run codex. On first launch, choose a supported sign-in method and give it one small task. Windows PowerShell and WSL are different environments: install the CLI in the one where you will work.

How to Install Codex CLI on Windows, macOS and Linux

Disclosure: Xtrusio is our product and is named once, near the end.

First, choose the right Codex product

Use OpenAI’s shell installer on macOS or Linux. Use its PowerShell installer for native Windows, or run the Linux installer inside WSL2 if that’s where your project and tools live.

Your project runs inChoose this installation routeDefault command locationVerify in that environment
macOScurl -fsSL https://chatgpt.com/codex/install.sh | sh~/.local/bin/codexcommand -v codex
Linuxcurl -fsSL https://chatgpt.com/codex/install.sh | sh~/.local/bin/codexcommand -v codex
Windows PowerShellpowershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exeGet-Command codex
Windows with WSL2Run the Linux installer inside the WSL shell.~/.local/bin/codex inside the distributioncommand -v codex inside WSL
macOS
Choose this installation route
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Default command location
~/.local/bin/codex
Verify in that environment
command -v codex
Linux
Choose this installation route
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Default command location
~/.local/bin/codex
Verify in that environment
command -v codex
Windows PowerShell
Choose this installation route
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Default command location
%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe
Verify in that environment
Get-Command codex
Windows with WSL2
Choose this installation route
Run the Linux installer inside the WSL shell.
Default command location
~/.local/bin/codex inside the distribution
Verify in that environment
command -v codex inside WSL

The Codex CLI guide, read on 29 November 2026, offers 4 install choices in its quickstart. The standalone installers cover the first two. If you already use a package manager, run npm install -g @openai/codex or brew install --cask codex where supported. On Windows, the community WinGet package is another option. Inspect its OpenAI.Codex ID and release source first.

The Codex README, read on 29 November 2026, lists the source under Apache-2.0. The CLI runs in a project folder. It can read files, edit code and run commands within the permissions you choose. The separate OpenAI API CLI uses openai for REST API calls. The desktop app has its own installer. For the terminal agent, use the installer that provides the codex command.

Use a terminal, a project folder and an account with Codex access or an OpenAI API key. PowerShell and WSL have separate command search paths, so check the command in the shell where you will use it.

Check: Run Get-Command codex in PowerShell or command -v codex in your macOS, Linux or WSL shell after installing. Pass if the path belongs to the install method you chose. Red flag: The path points to a different package manager or across the Windows and WSL boundary.

Install on macOS or Linux

MethodInstall commandWhere the command goesNeeds Node.js
OpenAI standalone installercurl -fsSL https://chatgpt.com/codex/install.sh | sh~/.local/bin/codex by defaultNo
npm global packagenpm install -g @openai/codexbin under the directory printed by npm prefix -gYes
Homebrew caskbrew install --cask codex$HOMEBREW_PREFIX/bin/codexNo
OpenAI standalone installer
Install command
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Where the command goes
~/.local/bin/codex by default
Needs Node.js
No
npm global package
Install command
npm install -g @openai/codex
Where the command goes
bin under the directory printed by npm prefix -g
Needs Node.js
Yes
Homebrew cask
Install command
brew install --cask codex
Where the command goes
$HOMEBREW_PREFIX/bin/codex
Needs Node.js
No

Choose the standalone installer for a machine without Node.js or Homebrew. It downloads and runs OpenAI’s shell script, which installs a prebuilt binary. The script stores managed releases under ~/.codex/packages/standalone/releases by default. Set CODEX_INSTALL_DIR to choose a different command directory. If the directory is missing from your shell’s command search path, reopen the terminal or use the path instruction the installer prints. OpenAI install.sh

For npm, use the full name @openai/codex. The @openai/ prefix identifies OpenAI’s package. Avoid npm install -g codex. For Homebrew, use the --cask form so your install, upgrade and removal commands all target the cask. An older formula may leave a second codex command on your path. Codex README

OpenAI’s npm package manifest, read on 29 November 2026, declares Node.js 16 or newer. The Homebrew Formulae Codex cask page, read on 29 November 2026, listed version 0.172.0 and builds for macOS and Linux. OpenAI’s Codex README, read on 29 November 2026, lists 4 macOS and Linux release archives across Apple silicon, Intel Mac, Linux x86-64 and Linux ARM64.

On a managed device, review the script and follow your approved software process. If that process calls for a release archive, download the asset for your operating system and processor. Extract it, rename the executable to codex and put it in a directory on your command search path. OpenAI Codex releases

After installation, open a new terminal and replace the example path with your project folder.

cd path/to/your-project
codex --version
codex

Check: Run which -a codex and codex --version in a new terminal. Pass if your chosen install is first in the path list and the version command prints codex-cli followed by a version. Red flag: An older install appears first, or the global npm command directory is missing from your path.

Install on Windows PowerShell

To install OpenAI Codex CLI on Windows without WSL, open PowerShell as the user who will run Codex and use OpenAI’s native installer. It installs codex.exe and adds its directory to that user’s path. Codex README

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
StepWhat to check
Install as the intended userThe standalone installer normally exposes codex.exe under %LOCALAPPDATA%\Programs\OpenAI\Codex\bin.
Open a fresh PowerShell window(Get-Command codex).Source shows the command file your shell will run.
Open the projectcodex --version prints the installed version. Run codex to start.

OpenAI’s install.ps1, read on 29 November 2026, supports 64-bit Windows on x64 and ARM64. OpenAI’s Windows sandbox guide, read on 29 November 2026, recommends Windows 11. The same guide describes Windows 10 as best effort and gives version 1809 as the practical minimum for console support.

The one-line command downloads and executes the installer. On a managed PC, have IT review the script and pin the approved release with -Release. Running the default installer as SYSTEM writes to the system profile. To install for an employee, run it in that employee’s user context. Deploy the Windows app and Codex CLI

If your team already manages Node.js on Windows, npm install -g @openai/codex is also documented by OpenAI. Use your approved package version. For the community WinGet route, inspect the package ID, version and release source before running winget install OpenAI.Codex. That manifest points to OpenAI release assets. The PowerShell script above is OpenAI’s standalone installer. Community WinGet manifests for OpenAI.Codex

After you confirm the command path, substitute your project folder and start Codex.

Set-Location 'C:\path\to\your-project'
codex

Check: Run (Get-Command codex).Source and codex --version in a fresh PowerShell window. Pass if the standalone command points to the expected user directory and prints a version. Red flag: PowerShell picks up an older npm shim or can’t find the command in your user’s path.

Install inside WSL2

Use Windows Subsystem for Linux when your project and its development tools live in Linux. Open the distribution with wsl from PowerShell. Then install Codex from that Linux shell.

WhereActionWhat you should see
PowerShellRun wsl -l -v.The intended distribution shows version 2.
Linux shellRun cd ~/code/your-project with your project’s real path.pwd shows your Linux project under /home.
Same Linux shellRun the shell installer below. Reopen the distribution and start codex from the project.The command resolves inside the distribution.
curl -fsSL https://chatgpt.com/codex/install.sh | sh

If WSL is absent, follow your organization’s software policy and Microsoft’s setup instructions. On an approved machine, run wsl --install from an elevated PowerShell window and restart when prompted. Microsoft’s Install WSL guide, read on 29 November 2026, lists Windows 10 build 19041 as the minimum Windows 10 build for that command. It also says new distributions installed with wsl --install use WSL 2 by default.

OpenAI’s WSL guide, read on 29 November 2026, says Codex 0.114 was the last version to support WSL1. At 0.115, the Linux sandbox moved to Bubblewrap and dropped WSL1 support. OpenAI recommends keeping active WSL projects under the Linux home directory for better file-system performance.

PowerShell and WSL resolve commands separately. If Codex runs in PowerShell and the Linux shell can’t find it, install and check it inside the distribution.

Check: Run wsl -l -v in PowerShell, then command -v codex and codex --version inside the distribution. Pass if the distribution uses WSL2 and the expected Linux command prints a version. Red flag: The distribution shows version 1 or the resolved command points into a Windows-mounted directory.

Sign in and give Codex its first task

ChatGPT sign-in or API key?

Run codex login to start ChatGPT sign-in in your browser. You can also run codex in your project and select Sign in with ChatGPT. For local automation billed to your API account, send the API key to codex login --with-api-key through standard input. Authentication

Choose this routeRun thisWhat happens
ChatGPT account in a local terminalcodex loginComplete sign-in in your browser. CLI usage draws on your ChatGPT plan. Use this route for Codex cloud.
ChatGPT account on a remote machine without a browsercodex login --device-authOpen the displayed link on a device with a browser and enter the one-time code. Enable beta device-code login in personal security settings or have a workspace admin enable it.
OpenAI API key for a local workflow or trusted CI jobprintenv OPENAI_API_KEY | codex login --with-api-key in macOS, Linux or WSL. In PowerShell use $env:OPENAI_API_KEY | codex login --with-api-key.The CLI reads the key from your environment through the pipe. Local usage is billed at standard API rates. Use ChatGPT sign-in for Codex cloud.

Set OPENAI_API_KEY through your approved secret store before using the pipe. Keep the key out of project files, public issues and screenshots. A workspace administrator can restrict which sign-in method you use. To clear cached credentials, run codex logout. Authentication

OpenAI’s Authentication guide, read on 29 November 2026, lists 4 settings for cli_auth_credentials_store. If you use file storage, the default location is ~/.codex/auth.json. Treat that file like a password. Choose keyring to use your operating system’s credential store. The same guide gives port 1455 for the default browser callback if you need to forward it over SSH. OpenAI’s Developer commands reference, read on 29 November 2026, says codex login status exits with code 0 when credentials are present.

Once signed in, start in your project with a small read-only question. Ask Codex to explain how the project runs its tests and point to the configuration files. Review the files it inspected and check its permissions before asking for an edit. Keep a Git checkpoint so you can revert changes. Codex CLI guide

On 19 October 2026, PowerShell resolved an existing codex.exe and printed codex-cli 0.163.0-alpha.10.2 after the app’s CLI directory was added to that session’s path. This was a command and version check on one machine.

Check: Run codex login status and ask your read-only question from the project directory. Pass if the status shows your chosen sign-in method and the answer points to real files in the project. Red flag: The method is unexpected or the browser login stalls before returning to the terminal.

Four setup problems and the next check

The terminal says codex is not recognized. Open a new terminal and run Get-Command codex in PowerShell or command -v codex on macOS, Linux or WSL. If neither finds it, check whether the installer completed under a different user and whether its command directory is on that user's path. OpenAI's Windows deployment guide specifically warns that a system-context installer targets the system profile, not every employee.

The wrong Codex version starts. Use the same command-location check to find competing installs. If both a standalone installer and npm placed a codex command on the machine, path order decides which one runs. Remove or update the unintended installation through its own method after you identify it. Do not delete an unknown executable just because its filename matches.

PowerShell works, but WSL does not. Check inside WSL, not in PowerShell. Install within WSL if that is where the repository and tools live. OpenAI's WSL troubleshooting guide covers command-path and project-location issues.

Sign-in does not finish. Check that you are using the intended account and method, then follow OpenAI's authentication guide. Managed organizations may constrain sign-in or require a particular account. Treat an authentication failure separately from a missing command. Do not put credentials in a troubleshooting screenshot.

Update or uninstall without losing project data

Run codex --version before and after an update. On macOS, Linux or WSL, use which -a codex to list copies on your path. In PowerShell, use Get-Command codex -All. Then update or remove the copy you identified using its original install method.

How you installedUpdateUninstall
Standalone on macOS, Linux or WSLRerun the shell installer.Remove the verified command link at ~/.local/bin/codex, any companion link from that install and the managed install tree at ~/.codex/packages/standalone.
Standalone on WindowsRerun the PowerShell installer.Remove the verified standalone command files from %LOCALAPPDATA%\Programs\OpenAI\Codex\bin and the managed install tree at %USERPROFILE%\.codex\packages\standalone. Remove the User PATH entry if it served only that install.
npmnpm install -g @openai/codex@latest or install your approved version.npm uninstall -g @openai/codex
Homebrew caskbrew upgrade --cask codexbrew uninstall --cask codex
GitHub release archiveReplace the files with the release asset for your platform.Remove the executable and any other files that you placed for that archive.

For manual removal, close running Codex sessions and confirm the paths first. CODEX_INSTALL_DIR can change where the command sits. CODEX_HOME can change where the managed package lives. Remove only files belonging to that install. Keep the repository and the rest of the Codex home so you retain your settings and sessions. On macOS and Linux, remove the installer’s shell-profile block only if nothing else uses that directory on your path. OpenAI install.sh and OpenAI install.ps1

The OpenAI 0.166.0 release notes, read on 29 November 2026, record the macOS standalone cleanup fix in change #57503. The same notes record a fix for reporting Unix installer download failures in change #57208. The npm CLI v11 uninstall reference, read on 29 November 2026, documents the -g option for removing a global package. Homebrew documents upgrades and removal in its brew manual.

For a managed installation, use IT’s approved rollout or uninstall process. After an update, reopen the terminal and confirm the intended executable and sign-in method. After removal, reopen it and make sure the old path is gone. A different path can mean another copy is still installed. Deploy the Windows app and Codex CLI and Developer commands

Check: Run which -a codex or Get-Command codex -All again in a new terminal, then run codex --version if you updated. Pass if the intended path prints the target version after an update or the removed path is absent after uninstalling. Red flag: A different copy takes over and prints an older version.

Codex CLI or Claude Code?

Both are terminal coding agents that can read a codebase, propose edits and run local development tools. OpenAI's Codex CLI guide and Anthropic's Claude Code overview describe those core workflows. Choose based on the account and permissions your team supports, the project environment, and which agent's output you can review and test well. Do not choose from a social clip that shows only a fast prompt and no diff, command history or failure path.

If you already use Claude Code, try Codex CLI on the same small, nonproduction task and compare the proposed plan, changed files, test command and final result. That is a fair local comparison. We did not run a head-to-head benchmark for this guide, so no winner or speed claim follows from it.

Frequently asked questions

Is the OpenAI CLI the same as Codex CLI?

No. Codex CLI runs the coding agent with the `codex` command. OpenAI's separate API CLI uses `openai` to make API requests. Check the Codex CLI guide and the OpenAI API CLI guide before installing.

Can I install Codex CLI with WinGet?

Yes, Microsoft's community WinGet repository lists `OpenAI.Codex` for the CLI. Verify that exact package ID and its release source before using `winget install OpenAI.Codex`. OpenAI's own Codex Windows CLI instructions document the standalone installer; their WinGet instruction for the ChatGPT desktop app refers to a different product.

Do I need WSL on Windows?

No. Use PowerShell for a native Windows project. Use WSL2 when your repository and development tools are in Linux. The CLI must be installed in the environment from which you plan to run it. See OpenAI's WSL guide.

Can I sign in with ChatGPT instead of an API key?

Yes, where your account has Codex access. The Codex README and authentication guide explain the routes. Do not assume that an API key and a ChatGPT plan have the same billing or access controls.

What should I check before accepting Codex's first edit?

Read the file diff, the command it ran, and the test result in your own project. A plausible summary does not replace reviewing the changed code. Keep a Git checkpoint so you can revert an unwanted change.

Measure whether your setup guide becomes a cited source

Before publishing a setup guide, save the exact reader question, the dated AI answer and its cited URLs. After publishing, ask the same question again and check for a citation to your guide, as described in Xtrusio's AI visibility explainer.

Questions people ask

Is the OpenAI CLI the same as Codex CLI?

No. Codex CLI runs the coding agent with the codex command. OpenAI's separate API CLI uses openai to make API requests. Check the Codex CLI guide and the OpenAI API CLI guide before installing.

Can I install Codex CLI with WinGet?

Yes, Microsoft's community WinGet repository lists OpenAI.Codex for the CLI. Verify that exact package ID and its release source before using winget install OpenAI.Codex. OpenAI's own Codex Windows CLI instructions document the standalone installer; their WinGet instruction for the ChatGPT desktop app refers to a different product.

Do I need WSL on Windows?

No. Use PowerShell for a native Windows project. Use WSL2 when your repository and development tools are in Linux. The CLI must be installed in the environment from which you plan to run it. See OpenAI's WSL guide.

Can I sign in with ChatGPT instead of an API key?

Yes, where your account has Codex access. The Codex README and authentication guide explain the routes. Do not assume that an API key and a ChatGPT plan have the same billing or access controls.

What should I check before accepting Codex's first edit?

Read the file diff, the command it ran, and the test result in your own project. A plausible summary does not replace reviewing the changed code. Keep a Git checkpoint so you can revert an unwanted change.

Method

Install commands and sign-in behavior were re-read on 29 November 2026. The version check shown was run on 19 October 2026 on one machine and shows only the command and version there.

Sources checked on 29 November 2026

Each page below was read on 29 November 2026.

  1. OpenAI, Codex CLI repository README: https://github.com/openai/codex (read 29 November 2026)
  2. OpenAI, Codex authentication: https://developers.openai.com/codex/auth (read 29 November 2026)
  3. OpenAI, Codex CLI guide: https://developers.openai.com/codex/cli (read 29 November 2026)

Topics

  • How to Install Codex CLI on Windows, macOS and Linux

Gaurav

AI visibility research at Xtrusio, Xtrusio

Xtrusio is the Perception Engine for B2B brands.

Free check

See how AI engines answer about you

Get your free AI visibility check

Talk to us about the managed plan (free trial)