How to Install Claude Code on Linux

Linux users get some of the best Claude Code support of any platform. Multiple install methods, native package manager repositories, and a smooth command-line experience that fits right into how you already work.

This guide covers every major Linux distribution and install method, with troubleshooting for the common failure points.

This is part of our complete Claude Code Beginner’s Guide.


TL;DR

  • Supported distros include Ubuntu 20.04+, Debian 10+, Fedora/RHEL, and Alpine 3.19+
  • You need at least a Pro plan ($20/month) to authenticate and use Claude Code
  • The native installer is the fastest method — one command, no dependencies
  • apt, dnf, and apk are available for system-managed installs
  • No Node.js required unless you specifically choose the npm method

What You Need Before You Start

Supported Linux distributions

Claude Code officially supports:

  • Ubuntu 20.04 or later**
  • Debian 10 or later**
  • Fedora / RHEL** (via dnf)
  • Alpine Linux 3.19 or later** (requires extra setup — covered below)
  • Any x64 or ARM64 processor

If you’re running a modern Linux distribution, you’re almost certainly covered.

A paid Anthropic account

The free Claude.ai plan does not include Claude Code. You need at least a Pro plan ($20/month). Sign up at claude.ai/upgrade if you haven’t yet.


Install Method 1: Native Installer (Recommended)

The native installer is the quickest path. It downloads a self-contained binary with no external dependencies — no Node.js, no system package manager involvement.

Step 1: Run the install command

Open your terminal and run:


# Install Claude Code using Anthropic's official native installer
curl -fsSL https://claude.ai/install.sh | bash

What’s happening here:

  • curl downloads the install script from Anthropic’s servers
  • -fsSL tells curl to follow redirects, stay silent, and fail on errors
  • | bash pipes the downloaded script into bash to execute it immediately

The installer runs in about 30–60 seconds. You’ll see output as it downloads and configures itself.

Step 2: Open a new terminal session

After the installer completes, open a new terminal window or tab. The claude command was added to your PATH, but your current session doesn’t know about it yet.

You can also source your profile in the same session:


# Reload your shell profile to apply the new PATH
source ~/.bashrc
# or if you use Zsh:
source ~/.zshrc

Step 3: Verify the installation


# Confirm Claude Code is installed and print the version number
claude --version

You should see something like 2.1.211 (Claude Code). Any version number means success.

Step 4: Run the health check


# Run Claude Code's built-in diagnostic tool
claude doctor

This prints a status report. Look for green checkmarks or a “Not authenticated” note — that’s expected before login.

Step 5: Log in


# Launch Claude Code and begin the authentication flow
claude

Claude Code will try to open a browser for authentication. If you’re on a headless server without a browser, it will print a URL — copy it and open it on another device. Sign in with your Anthropic account, authorize Claude Code, and you’re done.


Install Method 2: apt (Ubuntu and Debian)

If you prefer to manage Claude Code through your system package manager, Anthropic publishes a signed apt repository.

Step 1: Install curl and gnupg if needed


# Install required tools for adding the repository
sudo apt install curl gnupg

Step 2: Download and verify the signing key


# Create the keyrings directory
sudo install -d -m 0755 /etc/apt/keyrings

# Download the Anthropic signing key
sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
  -o /etc/apt/keyrings/claude-code.asc

Verify the key fingerprint to make sure it’s genuine:


# Display the key fingerprint for verification
gpg --show-keys /etc/apt/keyrings/claude-code.asc

The fingerprint should be: 31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE

If the fingerprint matches, continue. If it doesn’t, stop and don’t proceed — something went wrong with the download.

Step 3: Add the repository and install


# Add the Claude Code apt repository (stable channel)
echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main" \
  | sudo tee /etc/apt/sources.list.d/claude-code.list

# Update package list and install Claude Code
sudo apt update
sudo apt install claude-code

Step 4: Verify and log in


# Confirm the installation
claude --version

# Start Claude Code and log in
claude

💡 Pro Tip: Unlike the native installer, apt installs don’t auto-update. Run sudo apt update && sudo apt upgrade claude-code periodically to stay current.


Install Method 3: dnf (Fedora and RHEL)

Step 1: Add the repository


# Create the Claude Code dnf repository file
sudo tee /etc/yum.repos.d/claude-code.repo <<'EOF'
[claude-code]
name=Claude Code
baseurl=https://downloads.claude.ai/claude-code/rpm/stable
enabled=1
gpgcheck=1
gpgkey=https://downloads.claude.ai/keys/claude-code.asc
EOF

Step 2: Install Claude Code


# Install Claude Code via dnf
sudo dnf install claude-code

dnf will download the signing key and ask you to confirm the fingerprint. Verify it matches 31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE before accepting.

Step 3: Verify and log in


# Check the version
claude --version

# Start Claude Code and authenticate
claude

To upgrade later: sudo dnf upgrade claude-code


Install Method 4: Alpine Linux

Alpine requires a bit of extra setup because it uses musl (a different C library) and doesn’t include bash or curl by default.

Step 1: Install required packages


# Install dependencies required by Claude Code on Alpine
apk add bash curl libgcc libstdc++ ripgrep

If ripgrep isn’t found, add the community repository first:


# Add the Alpine community repository
echo "https://dl-cdn.alpinelinux.org/alpine/v3.22/community" >> /etc/apk/repositories
apk update
apk add bash curl libgcc libstdc++ ripgrep

Step 2: Run the install script


# Install Claude Code on Alpine
curl -fsSL https://claude.ai/install.sh | bash

Step 3: Configure Claude Code to use the system ripgrep

Create or edit the settings file to tell Claude Code not to use its built-in search binary (which isn’t compatible with musl):


# Create the settings file with the ripgrep configuration
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "USE_BUILTIN_RIPGREP": "0"
  }
}
EOF

Step 4: Verify and log in


# Check the installation
claude --version

# Authenticate
claude

Common Problems and How to Fix Them

“command not found: claude” after installing

Open a new terminal session or run source ~/.bashrc (or ~/.zshrc for Zsh). The PATH update only applies to new sessions. If it still fails, run echo $PATH and check that ~/.local/bin is listed.

If it’s missing, add it manually:


# Add ~/.local/bin to your PATH permanently
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

“curl: not found” during install

Install curl first:


# Ubuntu/Debian
sudo apt install curl

# Fedora/RHEL
sudo dnf install curl

# Alpine
apk add curl

The apt repository fails to verify the key

If gpg --show-keys shows a different fingerprint, the key download may have been intercepted or corrupted. Delete the file and try again:


# Remove the bad key and re-download
sudo rm /etc/apt/keyrings/claude-code.asc
sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
  -o /etc/apt/keyrings/claude-code.asc
gpg --show-keys /etc/apt/keyrings/claude-code.asc

Login page can’t open (headless server)

If Claude Code can’t open a browser (common on servers), it will print a URL in the terminal. Copy that URL, open it in a browser on any device, log in with your Anthropic account, and the server session will be authenticated.

Permission denied errors

Never use sudo with the native installer or with Claude Code commands. If you get permission errors, it usually means a previous npm-based install was done with sudo. Check for that:


# Find where the existing claude binary lives
which claude

# If it's in /usr/local/bin, remove it
sudo rm /usr/local/bin/claude

Then reinstall using the native installer without sudo.

“syntax error near unexpected token ‘<'" during install

This error means curl received an HTML error page (like a 403 or a network block) instead of the install script. Check your network connection and make sure downloads.claude.ai isn’t being blocked by a firewall or proxy.


Key Takeaways

  • The native installer (curl -fsSL https://claude.ai/install.sh | bash) works on Ubuntu, Debian, Fedora, and most Linux distros
  • apt, dnf, and apk** are available for system-managed installs with signed repositories
  • Alpine Linux** needs extra packages installed first (bash, curl, libgcc, libstdc++, ripgrep)
  • Always open a new terminal session after installing before running claude --version
  • Package manager installs don’t auto-update — run your system upgrade command periodically

Next Steps

Return to the Claude Code Beginner’s Guide for the full learning path.