Skip to content

How to Install Claude Code on Linux, macOS & WSL

· 4 min read

What is Claude Code?

Claude Code is Anthropic’s CLI tool for AI-powered coding directly in your terminal. It reads your codebase, edits files, runs commands, and handles multi-step tasks autonomously.

I’ve been using it daily for a month. The biggest difference from other AI tools: it understands project-wide context. You say “refactor the auth module” and it reads every related file before making changes.

Installation Demo

Full installation recorded on a fresh Ubuntu machine. Scrub the timeline or adjust playback speed:

How to Install Claude Code

Prerequisites

  • Node.js 18+ (for npm method) or any Linux/macOS system (for native installer)
  • A terminal (bash, zsh, fish all work)
  • An Anthropic account

Step 1: Run the Installer

# Recommended: native installer (auto-updates)
curl -fsSL https://claude.ai/install.sh | bash

# Alternative: macOS via Homebrew
brew install --cask claude-code

# Alternative: npm (won't auto-update)
npm install -g @anthropic-ai/claude-code

The native installer is preferred — it handles updates silently in the background.

Done when: claude --version prints a version number.

Step 2: Authenticate

claude

First run opens your browser for OAuth. Authorize, and you’re in.

Done when: You see the Claude Code prompt > in your terminal.

Step 3: Verify It Works

claude "What directory am I in? List the files."

If it responds with your current directory listing, everything is working.

How to Configure a Custom API Endpoint

If you’re using a third-party API service or self-hosted proxy, edit ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key-here",
    "ANTHROPIC_BASE_URL": "https://your-proxy.example.com"
  }
}

This routes all requests through your endpoint. Useful for teams with centralized API management or regional compliance requirements.

What Can Claude Code Actually Do?

TaskExample CommandWhat Happens
Explain codeclaude "Explain the auth flow in this project"Reads relevant files, outputs explanation
Build featuresclaude "Add pagination to the /users endpoint"Edits multiple files, runs tests
Fix bugsclaude "Tests are failing, fix them"Reads error output, patches code
Refactorclaude "Split this 500-line file into modules"Creates new files, updates imports
Code reviewclaude "Review my last commit"Reads git diff, gives feedback

How Does Claude Code Compare to Other Tools?

Claude CodeGitHub CopilotCursorCodex CLI
InterfaceTerminal CLIEditor pluginFull IDETerminal CLI
AutonomyFull (reads/writes/executes)Suggestions onlySemi-autonomousFull
Context200K tokens (whole repo)Single fileProject-wide200K tokens
Open sourceNoNoNoYes (Apache-2.0)
Best forComplex refactoring, automationLine completionsInteractive editingQuick tasks, open ecosystem

Tips From Daily Use

  • Always start from your project root. Claude Code reads the directory tree to understand context. Starting from ~ gives it nothing to work with.
  • Use multi-turn conversations. Don’t restart for follow-ups. Say “now add tests for that” after a feature implementation.
  • Pair with tmux for long tasks. Claude Code can run for minutes on complex refactors. Tmux keeps the session alive if your connection drops.
  • Check the /cost command. It shows token usage for the current session. Useful for budgeting.

Troubleshooting

”Authentication failed” on first run

Your browser might have blocked the OAuth popup. Try:

claude --login

This prints a URL you can manually paste into your browser.

Slow responses or timeouts

Usually a network issue. Test your connection to the API:

curl -I https://api.anthropic.com/v1/messages

If this times out, check your firewall or proxy settings.

”Model not available” error

Your subscription tier may not include the model you’re requesting. Claude Pro gets Sonnet; Claude Max gets Opus. Check your plan at console.anthropic.com.


FAQ

Is Claude Code free?
No. Claude Code requires either an Anthropic API key (pay-per-use) or a Claude Pro/Max subscription at $20-100/month. There is no free tier.
Does Claude Code work on Windows?
Yes, via WSL (Windows Subsystem for Linux). Install WSL first, then follow the Linux steps. Native Windows is not supported.
What's the difference between Claude Code and Cursor?
Claude Code is a terminal CLI — fully agentic, runs commands and edits files autonomously. Cursor is a VS Code fork with AI copilot features. Claude Code is better for automation and refactoring; Cursor is better for interactive editing with a GUI.
How much context can Claude Code handle?
Up to 200K tokens. It can read and understand entire codebases across multiple files in a single session.
Can I use a third-party API key with Claude Code?
Yes. Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json to point to any OpenAI-compatible proxy endpoint.

Related Posts