# How to install and use the Codex CLI

Paste one command in your terminal, type codex in a folder and sign in with ChatGPT. Plus: every install option, the commands to know and safe permissions.

Tool: ChatGPT. By Michel Lieben. Updated 2026-11-29. Source: https://coldiq.com/university/chatgpt/codex-cli

## In short

- The Codex CLI is OpenAI’s coding agent in a terminal (the window where you type commands). Its code is open, under the Apache 2.0 license.
- Install it with OpenAI’s script on Mac, Linux or Windows, with npm, or with Homebrew.
- OpenAI recommends that you sign in with ChatGPT and use your plan. An API key also works and bills per use.
- By default, network access is off, and Codex asks before it leaves the folder you opened.
- Type /status to see your limits, /model to change model, /permissions to change what Codex may do, and /review to check the work.

## Steps

1. Paste the install command for your system.
2. Go to a folder and type codex, then sign in with ChatGPT.
3. Ask a question about the folder before you ask for a change.

## How do you install the Codex CLI?

CLI means command-line interface: a tool you use by typing. You have four official ways to install it. One is enough.

- Mac or Linux: curl -fsSL https://chatgpt.com/codex/install.sh | sh
- Windows, in PowerShell: powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
- With npm (the package manager that comes with Node.js, which you need first): npm install -g @openai/codex
- With Homebrew on a Mac: brew install --cask codex

Tip: Copy install commands only from OpenAI’s page or its GitHub repository, openai/codex. A command from a forum can install something else.


## How do you sign in to Codex?

Open a folder in your terminal and type codex. Choose Sign in with ChatGPT, and your browser opens. OpenAI recommends this route with a Plus, Pro, Business, Edu or Enterprise plan. Your usage then comes from the plan.

You can use an API key instead (a secret code that bills your developer account). It fits scripts and shared automation. It has no cloud features, and you pay for each use.

On a server without a browser, run codex login --device-auth and enter the code on your phone or laptop. You first turn on device code login in your ChatGPT security settings. To see how you are signed in, run codex login status.

Tip: The file ~/.codex/auth.json holds your access tokens. Treat it like a password: never share it, and never put it in a project.


## What should you ask first?

Ask Codex to explain before it changes. You see what it understood, and you catch a wrong idea for free.

Then give one task with a clear end. Say which file to read, what to produce and where to save it.

- Work in a copy, or in a folder that Git tracks. Git keeps the history of your files.
- Say what must not change, for example “never edit the original export”.
- Ask for a check at the end: a row count, a test, a list of changed files.

> Create a script that reads webinar.csv, removes rows without an email, splits the full name into first and last name, and saves webinar-clean.csv. Keep the original untouched. Run it, then show me the number of rows before and after and five sample rows.


## Which Codex CLI commands should you know?

Two families exist. You type the first in the terminal. You type the second, with a slash, inside a Codex chat.

- codex: start a chat in this folder. codex resume: continue a saved one.
- codex exec "your task": run one task without a chat, for scripts.
- codex review: check your uncommitted changes.
- codex update: install the newest version. codex doctor: find an install or login problem.
- codex mcp: add or list MCP servers (connections to other tools).
- /status: model, permissions and limits. /usage: your account usage.
- /model: change model and reasoning level.
- /permissions: change what Codex may do without asking.
- /compact: shorten a long chat to save context. /skills: pick a saved skill.


## How do you keep the Codex CLI safe?

Two settings decide what Codex can do. The sandbox sets the limits (read only, or write in this folder). The approval setting decides when it must ask you.

The preset named Auto lets Codex edit and run commands in your folder, and it asks before it goes outside or uses the network. Read-only lets it look and not touch. OpenAI marks Full access as not recommended.

- Start in Read-only on a folder you do not know.
- Move to Auto when you trust the task.
- Keep network access off unless the task needs it.
- Never use the --yolo flag on your own computer. It removes every check.

Tip: Codex recommends Auto for folders tracked by Git, and Read-only for the others. It may also start in Read-only until you say you trust the folder.


## How do you update or fix the Codex CLI?

Run codex update, or repeat the install command you used. With Homebrew, run brew upgrade --cask codex. Some new models need a recent version: GPT-6.2 needs 0.166.0 or later.

If sign-in fails or a command is missing, run codex doctor. It prints a report on the install, the settings, the login and the connection.

If the terminal does not know the word codex after the install, open a new terminal window and try again.


## What can a sales or marketing team do with it?

The CLI is worth learning for work you repeat. Once a task is right, codex exec can run it again with the same words.

You can also connect data tools with MCP. For example, codex mcp add coldiq --url https://mcp.coldiq.com/mcp, then codex mcp login coldiq, brings leads and verified emails from ColdIQ into Codex.

- Clean every Monday’s lead export with one command.
- Turn a folder of call notes into one table of objections.
- Build a small landing page for an event from a text brief.
- Check a list of links and report the broken ones.


## Command

```
curl -fsSL https://chatgpt.com/codex/install.sh | sh
```

## What to say

> Read this folder and tell me in plain words what it contains, which files matter most, and what you would check before any change. Do not edit anything.

## Sources

- [Codex CLI](https://learn.chatgpt.com/docs/codex/cli)
- [openai/codex on GitHub](https://github.com/openai/codex)
- [Authentication](https://learn.chatgpt.com/docs/auth)
- [Developer commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli)
- [Permissions and approvals](https://learn.chatgpt.com/docs/agent-approvals-security)
- [ChatGPT Work and Codex](https://help.openai.com/en/articles/20001275-chatgpt-work-and-codex)
- [ChatGPT Work and Codex pricing](https://learn.chatgpt.com/docs/pricing)

## Questions

**Is the Codex CLI free?** The tool is free and open source. Running tasks uses your ChatGPT plan or an API key. OpenAI lists the CLI from Plus up, and Codex in the desktop app on Free and Go.

**Does the Codex CLI work on Windows?** Yes. Use the PowerShell installer. Inside WSL2, use the Linux command.

**What is the difference between Codex CLI and the Codex app?** They use the same agent. The CLI runs in a terminal, and the app gives you a window to see files and changes.

**Can I use local models with the Codex CLI?** Yes. The --oss flag uses a local open-source provider, LM Studio or Ollama.

**How do I sign out of Codex?** Run codex logout. It removes the stored credentials from your computer.


## Related

- [What is Codex?](https://coldiq.com/university/chatgpt/what-is-codex)
- [Codex usage limits: how to check and reset them](https://coldiq.com/university/chatgpt/codex-usage-limits)

## Try ColdIQ free

ColdIQ gives new accounts up to 1,450 free credits as they get started, no credit card required.
One subscription covers 40+ B2B data providers for finding, enriching and verifying
contacts and companies, through the web app, the API or the MCP server for AI agents.

1. Create an account: https://coldiq.com/marketplace/sign-up?utm_source=ai-assistant&utm_medium=markdown&utm_content=university
2. Run a first search on your own market with the free credits.
3. Connect the MCP server to Claude, ChatGPT or Cursor: https://coldiq.com/mcp
