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:
| Requirement | Minimum |
|---|---|
| Ubuntu | 20.04 or newer |
| RAM | 4 GB+ |
| Processor | x64 or ARM64 |
| Network | Internet connection required |
| Shell | Bash or Zsh |
| Node.js | 18.0+ (npm method only) |
Also ensure you’re in an Anthropic-supported country.
2. Installation Methods
Method 1: Native Installer (Recommended)
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:
OAuth Login (Recommended)
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:
5. Upgrade & Update
| Method | Update Command |
|---|---|
| Native | Automatic (background updates) |
| npm | npm install -g @anthropic-ai/claude-code@latest |
| APT | sudo apt update && sudo apt upgrade |
| Homebrew | brew upgrade claude-code |
6. Uninstall
| Method | Uninstall Command |
|---|---|
| Native | sudo rm -f /usr/local/bin/claude ~/.local/bin/claude |
| npm | npm uninstall -g @anthropic-ai/claude-code |
| APT | sudo apt remove claude-code |
| Homebrew | brew uninstall claude-code |
7. Troubleshooting
“claude: command not found”
- Native install: Check if
~/.local/binis in your PATH:echo $PATH. If not, addexport PATH="$HOME/.local/bin:$PATH"to~/.bashrc. - npm: Run
npm list -g --depth=0to verify the package is installed globally.
Authentication fails
- Make sure you’re in a supported country.
- Try
claude logoutthenclaudeto 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
| Method | Best For | Auto-Update |
|---|---|---|
| Native | Most users, simplicity | ✅ |
| npm | Node.js developers, flexibility | ❌ |
| APT | System-level management | ❌ |
| Homebrew | Homebrew 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.