How to Install Codex CLI on Fedora 44

Last updated Monday, May 18, 2026 5:30 pm Joshua James 7 min read

Fedora’s versioned Node.js packages make npm the cleanest default way to install Codex CLI on Fedora, because Fedora can provide the runtime while npm installs OpenAI’s terminal coding agent under your account. Homebrew is also a supported upstream package-manager option when Linuxbrew already belongs to your developer-tool workflow.

OpenAI’s current Codex CLI setup documents npm and Homebrew package-manager paths. Fedora’s default repositories do not provide an OpenAI codex package, so sudo dnf install codex is not the right install path. Use npm for a clean Fedora-managed Node.js base, or use Homebrew when brew is already configured from the Fedora Homebrew workflow.

Install Codex CLI on Fedora

Choose a Codex CLI Installation Method

Pick one package manager for Codex CLI so your shell does not switch between two different codex launchers as PATH order changes.

MethodSource or ChannelUpdate BehaviorBest ForTrade-offs
npmOpenAI npm package @openai/codexCodex updates through npm; Node.js updates through DNFFresh Fedora systems, SSH sessions, minimal installs, and users who do not already run HomebrewRequires Node.js and npm; use a user-owned prefix instead of sudo npm install -g
HomebrewHomebrew cask codexCodex updates through HomebrewExisting Linuxbrew users who already manage developer tools with brewAdds or relies on the separate /home/linuxbrew/.linuxbrew prefix

For most Fedora readers, npm is the lighter default because it needs only Fedora’s Node.js packages plus a user-owned npm prefix. Homebrew is useful when the brew prefix is already part of your shell and you want Codex managed with the same toolchain.

Use only one Codex CLI install method at a time. If npm and Homebrew both install codex, the command your shell runs depends on which binary directory appears first in PATH.

Install Codex CLI with npm

The npm method keeps Fedora in charge of the Node.js runtime while OpenAI’s npm package stays under your home directory.

Install Node.js for npm

Fedora packages recent Node.js branches by major version with names such as nodejs24 and nodejs22. The current npm package for Codex CLI declares a Node.js engine of >=16, so Fedora’s nodejs24 package is a good default on Fedora 44.

Install the Fedora-managed Node.js 24 package. The matching npm package is pulled in automatically:

sudo dnf install nodejs24

These commands use sudo for package-management tasks. If your account cannot run sudo yet, add the account to Fedora’s wheel group with the guide on how to add a user to sudoers on Fedora.

Verify the Node.js runtime, npm command, and Fedora package names:

node --version
npm --version
rpm -q nodejs24 nodejs24-npm

Example output pattern on Fedora 44:

v24.x.x
11.x.x
nodejs24-24.x.x-1.fc44.x86_64
nodejs24-npm-11.x.x-1.24.x.x.1.fc44.noarch

If your project needs another Node.js branch or an NVM-managed runtime, use the Fedora Node.js installation guide first, then return after node --version and npm --version both work.

Prepare a User-Owned npm Prefix

Fedora’s npm package reports a global prefix such as /usr/local. A normal user usually cannot write there, and using sudo npm install -g leaves root-owned package files outside DNF’s package tracking. Put Codex CLI under ~/.local instead:

mkdir -p ~/.local/bin
touch ~/.bashrc
grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' ~/.bashrc || printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"

Zsh users can add the same export line to ~/.zshrc instead. Opening a new terminal also loads the persistent PATH entry after it is saved.

Install the npm Package

Install OpenAI’s Codex CLI npm package, @openai/codex, into the user-owned prefix:

npm install -g @openai/codex --prefix "$HOME/.local"

Confirm that Fedora resolves the command from your home directory and that Codex CLI prints a version:

hash -r
command -v codex
codex --version
/home/username/.local/bin/codex
codex-cli 0.x.x

Avoid sudo npm install -g @openai/codex for the normal Fedora workflow. The user-owned prefix keeps installs, updates, and removals tied to your account and avoids root-owned npm files that DNF does not manage.

Install Codex CLI with Homebrew

Use the Homebrew method only when Linuxbrew is already installed or you deliberately want that separate package manager. If brew is not available yet, install Homebrew on Fedora first, then return after brew doctor reports a healthy setup.

Load Homebrew’s Linux environment for the current shell and verify that the brew command resolves from the Linuxbrew prefix:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
command -v brew
brew --version
/home/linuxbrew/.linuxbrew/bin/brew
Homebrew 5.x.x

Install Codex CLI with Homebrew. On Fedora 44, this command resolves to the Homebrew codex cask and links the Linux release binary into the brew prefix:

brew install codex

Confirm that your shell now finds the Homebrew-managed command and that the cask is installed:

hash -r
command -v codex
codex --version
brew list --cask codex
/home/linuxbrew/.linuxbrew/bin/codex
codex-cli 0.x.x
/home/linuxbrew/.linuxbrew/Caskroom/codex/0.x.x/codex-x86_64-unknown-linux-musl

Authenticate Codex CLI on Fedora

Codex CLI needs OpenAI authentication before it can send prompts and repository context. OpenAI’s Codex CLI documentation prompts for sign-in on first launch, and the official Codex authentication documentation covers ChatGPT sign-in for subscription access and API-key sign-in for usage-based access.

Sign In with ChatGPT

Start Codex from a project directory:

cd ~/your-project
codex

Choose the ChatGPT sign-in option when prompted. Codex opens a browser-based login flow and keeps local configuration and session data under ~/.codex/. Cached credentials may live in ~/.codex/auth.json or an operating system credential store, depending on configuration.

On a remote or headless Fedora session where the browser callback cannot complete, use device-code authentication when it is available for your account or workspace:

codex login --device-auth

Check or reset the current login state from the terminal:

codex login status
codex logout
codex login

Sign In with an API Key

For API-account workflows or sessions where you intentionally want usage billed through OpenAI Platform, read the key without saving it in shell history and pipe it to Codex:

read -rsp "OpenAI API key: " OPENAI_API_KEY
printf '\n'
printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key
unset OPENAI_API_KEY

If the key is already exported by a secrets manager or shell profile, use the existing environment variable without printing the value:

printenv OPENAI_API_KEY | codex login --with-api-key

Use Codex CLI on Fedora

Codex works best from the repository where it should inspect files, propose edits, run commands, or review changes. Start with read-only or review-oriented tasks until you understand how approvals and sandboxing behave on your system.

Start an Interactive Session

Launch Codex in a repository:

cd ~/your-project
codex

Start with a prompt when you already know the first task:

codex "explain the authentication flow in this repository"

Run Non-Interactive Codex Tasks

The exec subcommand handles one-shot tasks from the shell:

codex exec "summarize this repository and list risky files"

Attach a screenshot or design image when visual context matters:

codex exec -i screenshot.png "describe the UI changes needed"

Review Local Changes

Use Codex as a local code-review pass before committing:

codex review --uncommitted
codex review --base main
codex review --commit HEAD~1

Add a prompt when the review should focus on a specific risk area:

codex review --uncommitted "focus on authentication and file-permission risks"

Choose a Sandbox Mode

Sandbox modes control what Codex can do while it works:

  • read-only: lets Codex inspect files without writing changes.
  • workspace-write: allows edits in the selected workspace while keeping broader filesystem access limited.
  • danger-full-access: removes filesystem restrictions and should be reserved for trusted, intentional local work.
codex --sandbox read-only
codex --sandbox workspace-write
codex --sandbox danger-full-access

Use --dangerously-bypass-approvals-and-sandbox only inside an externally hardened environment, such as an isolated CI runner or container. That flag disables the safety controls that normally stop Codex before high-impact actions.

Update Codex CLI on Fedora

Update Codex CLI with the package manager that installed it. Do not run both update paths unless you intentionally installed both methods and have checked which codex command appears first in PATH.

Update npm Install

Update the Codex npm package with the same user-owned prefix used during installation:

export PATH="$HOME/.local/bin:$PATH"
npm install -g @openai/codex@latest --prefix "$HOME/.local"
codex --version

Fedora’s Node.js and npm packages update separately through DNF. Use a package-specific upgrade when you want to refresh only the runtime packages installed for this workflow:

sudo dnf upgrade --refresh nodejs24 nodejs24-npm

If nodejs24 is not installed because you use NVM, NodeSource, or Homebrew instead, update that runtime with its own manager rather than forcing the Fedora package command.

Update Homebrew Install

For a Homebrew-managed Codex install, update the cask through Homebrew. The brew update step refreshes Homebrew metadata, and brew upgrade codex upgrades Codex when a newer cask is available:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
brew update
brew upgrade codex
codex --version

Remove Codex CLI from Fedora

If you want to clear the active Codex login during removal, log out before uninstalling the CLI so the codex command is still available:

codex logout

Then remove the package with the same package manager that installed it.

Remove npm Install

Remove the npm-managed Codex package from the same user-owned prefix:

npm uninstall -g @openai/codex --prefix "$HOME/.local"
hash -r
command -v codex || echo "Codex CLI removed"

Remove Homebrew Install

Remove the Homebrew-managed cask when Codex was installed with brew install codex:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
brew uninstall --cask codex
hash -r
command -v codex || echo "Codex CLI removed"

Codex configuration, session history, and local state live under ~/.codex/. Cached credentials can also use ~/.codex/auth.json or an operating system credential store, depending on configuration.

Deleting ~/.codex/ removes local Codex configuration, session files, and any file-backed credentials for the current account. Back up anything you still need before removing it.

Inspect the directory before deleting it so you do not remove saved sessions or configuration you still need:

if [ -d ~/.codex ]; then
    ls -la ~/.codex
else
    echo "No ~/.codex directory found"
fi

Remove the directory only when you are ready to discard that local state:

rm -rf ~/.codex

If you used the npm method and installed Fedora’s Node.js packages only for Codex CLI, remove the runtime packages after reviewing the DNF transaction. Skip this step for Homebrew, NVM, NodeSource, or any system where other JavaScript tools still need Node.js:

sudo dnf remove nodejs24 nodejs24-npm

Troubleshoot Codex CLI on Fedora

Most Fedora-side Codex problems come from the wrong package manager, a missing PATH entry, npm permissions, Homebrew shell setup, skipped optional packages, or an inactive login.

Fix DNF Package Not Found for Codex

sudo dnf install codex does not install OpenAI Codex CLI from Fedora’s default repositories. Use one of OpenAI’s package-manager paths instead. For npm, reinstall the package into the user-owned prefix:

npm install -g @openai/codex --prefix "$HOME/.local"

Fix npm Codex Command Not Found

Check whether ~/.local/bin is in PATH and whether the npm-installed launcher exists:

printf '%s\n' "$PATH" | tr ':' '\n' | grep -Fx "$HOME/.local/bin"
ls -l ~/.local/bin/codex 2>/dev/null

No PATH output means your current shell has not loaded the user-local binary directory. Add the PATH entry and reload it:

touch ~/.bashrc
grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' ~/.bashrc || printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
command -v codex

Fix Homebrew Codex Command Not Found

For Homebrew installs, load the Linuxbrew shell environment and confirm the cask is installed before reinstalling:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
command -v brew
brew list --cask codex
command -v codex

If brew works but the cask is missing, reinstall Codex through Homebrew:

brew install codex
hash -r
command -v codex

Fix npm Permission Errors

An EACCES error usually means npm tried to write into a system-owned global prefix such as /usr/local. Reinstall Codex into the user-owned prefix instead of using sudo:

mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
npm install -g @openai/codex --prefix "$HOME/.local"

Fix npm Missing Native Binary Errors

The Codex npm package uses platform-specific optional dependencies for Linux, macOS, and Windows builds. If the CLI reports a missing native binary after installation, check for npm settings that skip optional packages, clear those user settings, then reinstall Codex:

npm config get omit
npm config get optional
npm config delete omit
npm config delete optional
npm install -g @openai/codex@latest --prefix "$HOME/.local"

Check Codex Login State

If Codex starts but cannot access the expected account or organization, inspect the login state before reinstalling packages:

codex login status

Reset the stored login when you need to switch accounts:

codex logout
codex login

Conclusion

Codex CLI is ready on Fedora when either the user-owned npm install or Homebrew cask returns a working codex --version and authentication is active. Pair it with install Git on Fedora and install Visual Studio Code on Fedora for a complete local coding setup.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: