Claude Code is a command-line tool by Anthropic that lets you work with Claude directly from your terminal. You can use it for code reviews, debugging, generating scripts, and working with project files. This guide walks you through installing Claude Code CLI on WSL2 Ubuntu.
WSL2 is the better environment for Claude Code on Windows: it has full Bash support, native Linux paths, and plays nicely with tools like Docker and Terraform. If you’d rather install on PowerShell directly, see How to Install and Configure Claude Code CLI on Windows PowerShell.
Prerequisites
- Windows 10 or 11 with WSL2 enabled and Ubuntu installed: see How to Install Ubuntu 20.04 or 22.04 in WSL 2 on Windows 10 if you need to set this up
- An account eligible for Claude Code: a supported Claude subscription, Console API billing, or a supported cloud provider. Check Anthropic’s authentication documentation; do not assume a free chat account includes CLI usage.
Step 1: Install the Native CLI
Run Anthropic’s recommended native installer inside Ubuntu, without sudo. It does not require Node.js:
curl -fsSL https://claude.ai/install.sh | bash
Step 2: Verify the Installation
Open a new Ubuntu terminal, then check the version and installation health:
claude --version
claude doctor
Optional npm route: use Linux Node.js 22 or later, then run npm install -g @anthropic-ai/claude-code@latest without sudo. Choose one installation method to avoid multiple copies on PATH. The native installer is simpler when Node.js is not otherwise needed.
Step 3: Authenticate
Run claude to start the authentication flow:
claude
Available authentication routes depend on your account and configuration:
- Claude account (subscription): uses an eligible Claude subscription, including Pro, Max, Ultra, Team, or Enterprise, subject to plan limits.
- Anthropic Console (API billing): uses API credits from your Anthropic account.
- Third-party platform: connects through AWS Bedrock, Google Cloud, Microsoft Foundry, or another supported provider; these require provider configuration.
Pick one and follow the browser prompt to log in. WSL2 will open the URL in your Windows default browser. Once you approve, you’re authenticated.

Basic Usage
Claude Code reads files in your current directory, so cd into your project first. To connect external tools, follow the MCP server configuration guide.
Start an interactive session:
cd ~/projects/my-app
claude
Ask a one-off question with -p (print mode):
claude -p "review this terraform code and suggest improvements"
Pipe output from another command:
cat error.log | claude -p "explain this error and suggest a fix"
Update Claude Code
Native installations update automatically. To check manually, run the command below. For the optional npm route, use npm install -g @anthropic-ai/claude-code@latest; avoid npm update -g.
claude update
Troubleshooting
claude: command not found
For the native install, ensure ~/.local/bin is on PATH. Try this in the current shell, then add it once to ~/.bashrc if needed:
export PATH="$HOME/.local/bin:$PATH"
command -v claude
claude doctor
EACCES permission error during install
Use the native installer without sudo rather than recursively changing ownership of npm directories. If retaining npm, follow Anthropic’s permission troubleshooting and verify it uses Linux Node.js inside WSL.
Slow file performance
If Claude Code feels slow when reading files, make sure your project is in the Linux file system (/home/yourname/) and not on the Windows mount (/mnt/c/). WSL2 file access across the mount boundary is significantly slower.
Security Tips
- Don’t paste real credentials, API keys, or secrets into prompts.
- If using API billing, set the key as an environment variable (
export ANTHROPIC_API_KEY="your-key"in~/.bashrc) instead of passing it inline. - Review any generated infrastructure code or IAM policies before applying them.
Conclusion
That covers installing Claude Code CLI on WSL2 Ubuntu. The native installer handles the CLI directly; verify it with claude doctor before starting a project.
If you’re also setting up your WSL environment, you might find How to Connect Visual Studio Code with WSL 2 for Linux Ubuntu useful for connecting VS Code to your WSL instance.


