Have you ever wished you could harness the power of OpenAI's latest coding tool without the hassle of dual booting a Linux Distro or cloud dependencies? Well, buckle up, because running Codex on Windows just got a whole lot easier with WSL (Windows Subsystem for Linux). Codex on Windows via WSL is a game-changer for developers who want to leverage the Codex CLI—OpenAI's lightweight, open-source coding agent that lives right in your terminal. Announced in 2025, the Codex CLI brings the smarts of models like GPT-5 to your local setup, helping you generate code, debug bugs, and even execute commands safely. Whether you're building apps, tweaking scripts, or just exploring Codex on WSL, this setup lets you do it all without leaving the comfort of your Windows environment. In this conversational guide, we'll walk through everything from scratching up WSL to firing up the Codex CLI and putting it to work. By the end, you'll be chatting with Codex like an old friend, all while optimizing your workflow for that sweet Codex on Windows experience. Let's dive in!
Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?
Apidog delivers all your demands, and replaces Postman at a much more affordable price!

What is Codex CLI and Why Run It on WSL?
Before we get our hands dirty, let's chat about what Codex actually is. The Codex CLI is OpenAI's open-source command-line tool that acts as a coding agent straight from your terminal. It's designed to understand natural language requests, read your codebase, suggest edits, run commands, and even handle multimodal inputs like screenshots. Powered by advanced models (think GPT-5), it runs locally, meaning your code stays private unless you choose to share it. No more switching between editors or cloud services—Codex integrates seamlessly into your dev flow.
Now, why bother with WSL for Codex on Windows? Windows support for Codex CLI is still experimental as of September 2025, so native installs can be buggy with sandboxing and permissions. WSL, Microsoft's Linux layer on Windows, provides a stable, Linux-like environment where Codex on WSL can thrive. It's perfect for Node.js-based tools like this, avoiding the quirks of Windows paths and shells. Plus, with WSL, you get the best of both worlds: Linux power for coding and Windows familiarity for everything else. If you're into vibe-coding or agentic development, Codex on WSL is your ticket to productivity without the headaches.

Getting Started with WSL on Windows
Alright, let's kick things off by setting up WSL—the foundation for smooth Codex on Windows sailing. WSL lets you run a full Linux distro right inside Windows, complete with terminal access, without needing a virtual machine. As of September 18, 2025, the latest is WSL 2, which uses a lightweight VM for better performance.
Here's how to get rolling:
Enable Windows Features: Hit the Windows Start menu and search for "Turn Windows features on or off" (or just type "features"). In the dialog that pops up, scroll down and check the boxes for "Virtual Machine Platform" and "Windows Subsystem for Linux." These are crucial for WSL 2 support—without them, you'll be stuck in legacy mode. Click OK, and let Windows install the components. You might need to restart your PC.

Check WSL Status: Open a new Command Prompt or PowerShell (search for "cmd" or "powershell" in Start). Type wsl --status
and hit Enter. If everything's good, you'll see something like "Default Version: 2." If it says Version 1 or errors out, don't sweat—proceed to the next step.
Update WSL: Still in your terminal, run wsl --update
. This grabs the latest kernel and fixes for WSL 2. It might take a minute, but once done, run wsl --status
again to confirm. Voila! WSL is primed and ready. Pro tip: If you're on Windows 11, it's even smoother with built-in GUI app support, but Windows 10 works fine too.

With WSL humming, you're set to install a Linux distro and bridge the gap to Codex on WSL.
Installing a Linux Distro in WSL
Now that WSL is enabled, it's time to bring in a Linux flavor—think of this as installing the OS where Codex on WSL will live. Microsoft Store makes it dead simple, no USB sticks required.
For this guide, we'll go with Ubuntu, a popular choice for developers due to its stability and vast package ecosystem. But feel free to pick Kali for security testing or Debian for minimalism.

Head to Microsoft Store: Open the Microsoft Store app (search in Start menu). In the search bar, type "Ubuntu" or your preferred distro like "Kali Linux." You'll see options—grab the latest Ubuntu (say, 22.04 LTS for reliability).

Install and Launch: Hit "Install" and wait for it to download (it's about 500MB). Once done, click "Open" or launch from Start menu. A terminal window will pop up, and Ubuntu will initialize— this might take a few minutes as it sets up the filesystem.

Set Up Your User: You'll be prompted to create a username and password for your Ubuntu user. Keep it simple but secure (the password won't show as you type). This is your Linux identity for running commands, including the Codex CLI.

Test the Waters: In the Ubuntu terminal, try ls
to list files (it should show your home directory). If it works, congrats—your Linux distro is installed in WSL! Run uname -a
to verify it's running under WSL 2. Everything's now primed for Node.js and Codex on WSL.
If you run into issues like "WSL not found," double-check the features were enabled and restart. For advanced tweaks, edit /etc/wsl.conf
inside Ubuntu to set defaults.
Installing Node.js in WSL
Codex CLI is an npm package, so we need Node.js (which bundles npm) installed in your WSL environment. This is straightforward in Ubuntu, but let's do it step by step to avoid pitfalls.
Update Packages: First, refresh your repos: sudo apt update && sudo apt upgrade -y
. Enter your password when prompted—this keeps Ubuntu current.
Install curl: Codex on WSL relies on Node via NVM (Node Version Manager), which needs curl. Run sudo apt install curl -y
.
Install NVM: NVM makes managing Node versions a breeze. Paste this: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
. (Note: Check the latest version on nvm's GitHub if needed.) This downloads and runs the installer.
Activate NVM: Close and reopen your Ubuntu terminal, or run source ~/.bashrc
to load NVM. Verify with command -v nvm
—it should output "nvm" if successful.
Install Node.js: Use NVM to grab the LTS version: nvm install --lts
. This installs Node and npm. For the latest (Node 22+ recommended for Codex CLI), run nvm install node
. Switch versions with nvm use node
if needed.
Verify Installation: Run node --version
(should show v20+ or whatever you installed) and npm --version
. If both work, Node is ready in WSL! This setup ensures Codex on Windows feels native, without Windows Node conflicts.

Troubleshooting? If NVM isn't found, check your .bashrc
for the export lines added by the installer.
Installing and Using Codex CLI on WSL
The moment you've been waiting for: Bringing Codex to life in WSL. With Node set up, installing the Codex CLI is a one-liner, but let's make it a demo project for fun.
Create a Demo Folder: In your Ubuntu home (/home/yourusername
), run mkdir codex-cli-demo
(name it whatever). Then cd codex-cli-demo
to enter it. This keeps things organized for testing Codex on WSL.
Install Globally: Fire up npm install -g @openai/codex
. This pulls the latest from npm—expect it to take a minute as it downloads dependencies. (As of September 2025, version 0.25.0+ is stable.)
Run Codex: Simply type codex
in the terminal. The Codex CLI will launch an interactive UI. For first-time setup, it'll prompt authentication.

Authenticate: You have options—sign in with your ChatGPT account (recommended for Plus/Pro users) or use an API key. For this demo, go with ChatGPT: It'll provide a link. In WSL, browsers will still open automatically unless otherwise (use the provided link). Install WSL utilities first: Back in PowerShell (Windows side), run wsl --install -d Ubuntu
if not done, then in Ubuntu: sudo apt install wslu -y
. Now, when you run codex
, the link opens in your Windows browser. Log in to ChatGPT (you'll need a paid plan for GPT-5 access—free tiers are limited). Authorize, and you're in!

Basic Usage: Once running, chat with Codex like: "Create a simple Python script for hello world." It reads your dir, generates code, and even executes if approved. Use modes like --suggest for ideas or --full-auto for hands-off (use cautiously). Verify with codex --version
.
For API key auth: Export export OPENAI_API_KEY=yourkey
in .bashrc
, then run codex
. Paid plans unlock premium models (gpt-5), so upgrade at openai.com if needed.

Tips and Troubleshooting for Codex on WSL
Running Codex on WSL is mostly smooth, but here's some pro advice:
- Git Integration: Initialize a repo (
git init
) in your demo folder—Codex CLI warns without it for safety. - Modes and Flags: Try
codex --auto-edit
for interactive edits or attach images with--image path/to/screenshot.png
. - Common Issues: If npm fails, run
sudo apt install build-essential -y
. For browser links, ensure WSLU is installed. Update Codex withnpm update -g @openai/codex
. - Performance: WSL 2 uses more RAM, so allocate via
.wslconfig
if needed. For heavy tasks, pair with VS Code's Remote-WSL extension or try with Docker Desktop.
Explore the GitHub repo (github.com/openai/codex) for configs in ~/.codex/config.toml
—tweak models or behaviors.
Conclusion: Why Choose Codex on Windows with WSL?
Embracing Codex on WSL means unlocking AI coding magic on Windows without compromises. It's local, private, and powerful—perfect for Windows devs tired of macOS envy. With WSL, you're future-proofed for Linux tools too. Dive in, experiment, and watch Codex transform your terminal into a coding powerhouse!
