Claude Code is Anthropic’s agentic coding assistant that runs directly in your terminal. It understands your codebase, edits files, runs git commands, debugs, writes docs — all through natural language.

This guide covers every installation method on Ubuntu, from beginner-friendly to advanced.


1. Prerequisites

Before you start, make sure your system meets these requirements:

RequirementMinimum
Ubuntu20.04 or newer
RAM4 GB+
Processorx64 or ARM64
NetworkInternet connection required
ShellBash or Zsh
Node.js18.0+ (npm method only)

Also ensure you’re in an Anthropic-supported country.


2. Installation Methods

This is the official one-liner. It auto-updates in the background so you’re always on the latest version.

curl -fsSL https://claude.ai/install.sh | bash

After the script finishes, you’re done. Start Claude Code:

claude

Tip: Want to check what the script does before running? Pipe it to less:
curl -fsSL https://claude.ai/install.sh | less

Method 2: npm (Universal)

If you already have Node.js set up, npm is the most portable option. This method also works on macOS and WSL.

# Install Node.js 18+ first if needed
# curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# sudo apt install -y nodejs

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version

To upgrade later:

npm install -g @anthropic-ai/claude-code@latest

⚠️ Don’t use npm update -g — it respects the semver range from the original install and may not pull the latest release.

Method 3: APT (Debian/Ubuntu Package Manager)

If you prefer system-level package management, add Anthropic’s official APT repository:

# Add Anthropic's GPG key and repository
curl -fsSL https://apt.anthropic.com/apt.anthropic.com.gpg.key | \
  sudo gpg --dearmor -o /usr/share/keyrings/anthropic.gpg

echo "deb [signed-by=/usr/share/keyrings/anthropic.gpg] https://apt.anthropic.com stable main" | \
  sudo tee /etc/apt/sources.list.d/anthropic.list

# Install
sudo apt update
sudo apt install claude-code

Method 4: Homebrew

If you use Homebrew on Linux:

brew install --cask claude-code

Homebrew offers two tracks:

  • claude-code — stable channel (~1 week behind, skips major regressions)
  • claude-code@latest — latest releases as soon as they ship

3. Authentication

On first run, Claude Code will ask you to authenticate. You have two options:

claude

The CLI will print a one-time code and open a browser. Follow the prompt to link your Anthropic account. After that, subsequent launches are instant.

API Key

If you prefer an API key, set the environment variable:

export ANTHROPIC_API_KEY="sk-ant-..."

# Or persist it in your shell config
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc

Then launch:

claude --dangerously-skip-permissions

4. First Run

Navigate to your project directory and start:

cd ~/my-project
claude

Claude Code will scan your codebase and you can start chatting. Try something like:

>>>SAFudimdnmdaJrSaiDnzodecftcihoximsmaenpnyrtosujnethcoatn'sdsrlces/dturtpuirclotsmu.irjseserejections

5. Upgrade & Update

MethodUpdate Command
NativeAutomatic (background updates)
npmnpm install -g @anthropic-ai/claude-code@latest
APTsudo apt update && sudo apt upgrade
Homebrewbrew upgrade claude-code

6. Uninstall

MethodUninstall Command
Nativesudo rm -f /usr/local/bin/claude ~/.local/bin/claude
npmnpm uninstall -g @anthropic-ai/claude-code
APTsudo apt remove claude-code
Homebrewbrew uninstall claude-code

7. Troubleshooting

“claude: command not found”

  • Native install: Check if ~/.local/bin is in your PATH: echo $PATH. If not, add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc.
  • npm: Run npm list -g --depth=0 to verify the package is installed globally.

Authentication fails

  • Make sure you’re in a supported country.
  • Try claude logout then claude to re-authenticate.

Search not working

  • Claude Code bundles ripgrep, but if search fails, install it: sudo apt install ripgrep.

General debugging

claude doctor

This runs a diagnostic suite covering installation, authentication, networking, and tool availability.


Summary

MethodBest ForAuto-Update
NativeMost users, simplicity
npmNode.js developers, flexibility
APTSystem-level management
HomebrewHomebrew users

For most Ubuntu users, the native installer is the way to go — one command, no dependencies to manage, and always up to date. Pick the method that fits your workflow and start coding.