Claude Code on Linux: Ubuntu, Debian, Fedora, Arch Installation Guide (2026)

Install Claude Code on Linux with the native one-command installer. Covers Ubuntu, Debian, Fedora, RHEL, Arch, and Alpine. Includes SSH/headless setup, tmux integration, systemd service, and common Linux-specific issues.

March 10, 2026 ยท 2 min read

Claude Code runs natively on Linux. One curl command, no Node.js, no package manager conflicts. This guide covers every major distribution, headless server setup, tmux session persistence, and common Linux-specific issues.

1 cmd
Installation
4 GB
Minimum RAM
0
Node.js required
5+
Distros supported

Linux is a first-class Claude Code platform

Claude Code was built on and for Unix environments. Unlike Windows, there are no compatibility shims, no WSL2 requirements, and no feature gaps. Every MCP server, file watcher, shell integration, and git hook works on Linux exactly as the documentation describes.

System Requirements

Before installing, confirm your system meets these requirements:

  • Distribution: Ubuntu 20.04+, Debian 10+, Alpine Linux 3.19+, Fedora (current), RHEL 8+, or any glibc-based distribution
  • RAM: 4 GB minimum. 8 GB or more recommended for large codebases
  • Shell: Bash or Zsh. The installer adds the binary to your PATH automatically
  • Network: Active internet connection. Claude Code communicates with Anthropic's API
  • Account: Claude Pro ($20/month), Max ($100-200/month), Teams, Enterprise, or Anthropic Console with API credits

The free Claude.ai plan does not include Claude Code access. You need a paid subscription or Console credits.

Ubuntu and Debian

The native installer works on Ubuntu 20.04, 22.04, 24.04 and Debian 10, 11, 12 without any prerequisites. Run this from your terminal:

Install Claude Code (Ubuntu / Debian)

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

The installer downloads the Claude Code binary, places it at ~/.local/bin/claude, and adds that directory to your PATH if it is not already there. It also stores versioned binaries at ~/.local/share/claude/versions/ for rollback support.

Verify the installation

Verify

# Check version
claude --version

# Run the built-in diagnostic
claude doctor

# Navigate to a project and start
cd ~/your-project
claude

PATH fix (if needed)

If the installer completes but claude is not found, your shell's PATH does not include ~/.local/bin. Fix it:

Add ~/.local/bin to PATH

# For Bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# For Zsh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

No sudo required

The native installer does not need root. It installs entirely in your home directory. Never run the installer with sudo. Doing so creates root-owned files in /root/.local/, which your regular user cannot access or update.

Fedora and RHEL

Claude Code is not in Fedora's official repositories. The native installer handles everything:

Install Claude Code (Fedora / RHEL)

# Optional: update your system first
sudo dnf upgrade --refresh

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

Verify and fix PATH the same way as Ubuntu above. On Fedora, ~/.local/bin is often already in PATH for interactive shells, but not for login shells used by SSH connections or cron. Add it explicitly if you plan to use Claude Code in those contexts.

Verify on Fedora

which -a claude
# Expected: /home/username/.local/bin/claude

claude --version

Arch Linux

Two options on Arch: the native installer (same curl command), or the AUR package for users who prefer pacman-style management.

Option 1: Native installer

Native installer (Arch)

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

Option 2: AUR

AUR installation (using yay)

# Latest version
yay -S claude-code

# Stable channel (approximately one week behind latest)
yay -S claude-code-stable

The AUR packages do not auto-update. Run yay -Syu claude-code periodically to get new versions. The native installer auto-updates in the background by default.

Alpine Linux

Alpine uses musl libc instead of glibc. The native installer's bundled ripgrep binary is compiled for glibc and will not run on Alpine without additional packages. Install these first:

Install dependencies (Alpine)

apk add libgcc libstdc++ ripgrep

Then tell Claude Code to use the system ripgrep instead of the bundled one. Add this to your ~/.claude/settings.json:

~/.claude/settings.json (Alpine)

{
  "env": {
    "USE_BUILTIN_RIPGREP": "0"
  }
}

Now run the standard installer:

Install Claude Code (Alpine)

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

Alpine is common in Docker images. This same setup works inside Alpine-based containers for CI/CD pipelines.

npm Installation (Deprecated)

The npm method still works but Anthropic officially deprecated it in favor of the native installer. If you are on this path, switch now:

Migrate from npm to native

# Install the native binary
curl -fsSL https://claude.ai/install.sh | bash

# Remove the old npm installation
npm uninstall -g @anthropic-ai/claude-code

If you need to keep using npm for compatibility (for example, in a monorepo where Claude Code is a dev dependency), install Node.js 18+ first. Use nvm to avoid permission issues:

Install Node.js via nvm (if needed for npm method)

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc

# Install Node.js 22 LTS (recommended)
nvm install 22
nvm use 22

# Configure user-level npm prefix (avoids sudo)
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

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

Never use sudo with npm install -g

Running sudo npm install -g @anthropic-ai/claude-code creates root-owned files that break future updates and create security risks. If you get EACCES errors, configure a user-level npm prefix as shown above, or switch to the native installer which has no permission issues.

API Key and Authentication

On first run, Claude Code opens your browser for OAuth authentication with your Anthropic account. The session token is stored at ~/.claude.json.

For API key authentication (required for headless servers, CI/CD, and automated agents), set the ANTHROPIC_API_KEY environment variable:

Set API key (add to ~/.bashrc or ~/.zshrc)

export ANTHROPIC_API_KEY=sk-ant-api03-...

Reload your shell or source the file:

Apply immediately

source ~/.bashrc   # or source ~/.zshrc

Verify Claude Code can authenticate:

Test authentication

claude doctor

Interactive vs. non-interactive auth

The ANTHROPIC_API_KEY environment variable works reliably in non-interactive (headless/CI) mode. In interactive mode on a headless server, Claude Code may still prompt for browser-based login on first use. Run claude -p "hello" first on the server to confirm the API key auth path works before depending on it in automation.

SSH and Headless Server Setup

Claude Code works on headless Linux servers without a display or desktop environment. The setup has two parts: getting Claude Code installed and authenticated, then keeping sessions alive across SSH disconnections.

Authentication on a headless server

When you run claude on a server without a browser, it prints a URL instead of opening one automatically. Copy that URL, open it on your local machine, and complete the OAuth flow. The token is saved on the server side.

First-time auth on headless server

# SSH into your server
ssh user@your-server.com

# Run claude - it will print an auth URL
claude
# Output: Visit https://claude.ai/oauth/... to authenticate
# Open that URL in your local browser, complete login
# Press Enter on the server after completing auth

For automated environments where browser auth is not possible, use an API key from the Anthropic Console instead:

API key auth for fully headless setup

# Add to your server's ~/.bashrc
export ANTHROPIC_API_KEY=sk-ant-api03-...

# Test non-interactive mode
claude -p "list the files in this directory" --output-format json

Non-interactive (print) mode

The -p flag runs Claude Code non-interactively, prints the response to stdout, and exits. This is what you use in scripts, cron jobs, and CI pipelines:

Non-interactive mode

# Single prompt, exits after response
claude -p "summarize the changes in the last 5 git commits"

# With output format for parsing
claude -p "review this file for bugs" --output-format json

# Limit turns to prevent runaway agents
CLAUDE_CODE_MAX_TURNS=5 claude -p "refactor the auth module"

tmux Integration

tmux is the standard way to keep Claude Code sessions alive on Linux servers. When you detach from a tmux session, Claude Code keeps running. Reconnect from any SSH session and pick up exactly where you left off.

Install tmux

Install tmux

# Ubuntu / Debian
sudo apt-get install -y tmux

# Fedora / RHEL
sudo dnf install -y tmux

# Arch
sudo pacman -S tmux

# Alpine
apk add tmux

Basic tmux workflow with Claude Code

tmux + Claude Code workflow

# Start a named tmux session
tmux new-session -s claude

# Inside the session: navigate to your project and start Claude Code
cd ~/your-project
claude

# Detach without stopping Claude Code (Ctrl+b, then d)
# Ctrl+b d

# Later: reattach from any SSH session
tmux attach-session -t claude

# List active sessions
tmux list-sessions

Recommended tmux config for Claude Code

~/.tmux.conf

# Enable mouse support
set -g mouse on

# 256-color terminal (Claude Code renders colors correctly)
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# Increase scrollback buffer for long Claude Code responses
set -g history-limit 50000

# Prevent session name truncation
set -g status-left-length 40

Reload the config after saving: tmux source-file ~/.tmux.conf

Multiple Claude Code agents in parallel

tmux windows and panes let you run multiple Claude Code sessions simultaneously. Use Ctrl+b c to create a new window, Ctrl+b n to switch between windows. Each window can run a separate Claude Code agent on a different project or task.

systemd Service for Background Agents

For Claude Code agents that need to run continuously as daemons, a systemd user service is cleaner than a tmux session. The agent starts on login, restarts on failure, and writes logs to journald.

Create the service file

~/.config/systemd/user/claude-agent.service

[Unit]
Description=Claude Code Background Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=%h/your-project
Environment=ANTHROPIC_API_KEY=sk-ant-api03-...
ExecStart=%h/.local/bin/claude -p "watch for new files and summarize changes" --output-format stream-json
Restart=on-failure
RestartSec=30
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=default.target

Enable and start the service

Enable and manage the service

# Create the directory if it doesn't exist
mkdir -p ~/.config/systemd/user

# Reload systemd to pick up the new file
systemctl --user daemon-reload

# Enable on login + start now
systemctl --user enable --now claude-agent

# Check status
systemctl --user status claude-agent

# View logs
journalctl --user -u claude-agent -f

# Stop / restart
systemctl --user stop claude-agent
systemctl --user restart claude-agent

For the service to survive after you log out (not just after login), enable lingering for your user:

Enable linger (service runs even when logged out)

sudo loginctl enable-linger $USER

Linux vs macOS vs Windows

Claude Code's behavior across platforms depends on how close you are to a native Unix environment.

Linux (native)macOSWindows (WSL2)Windows (native)
File watchingFull (inotify)Full (FSEvents)Full (inotify via WSL2)Limited
Shell integrationFullFullFull (bash/zsh)PowerShell only
MCP serversAll workAll workAll workSome limitations
Git hooksFullFullFullPartial
Desktop appNot availableAvailableAvailable (inside WSL2)Available
Auto-updatesYesYesYesYes
Node.js requiredNoNoNoNo
Setup complexityLowLowMedium (WSL2)Medium

Linux advantages

Native inotify file watching. No compatibility shims. Full MCP server support. First-class SSH and headless use. Lightweight enough to run on a $5/month VPS. Systemd for process management.

macOS advantages

Desktop app available. Homebrew integration. Same Unix environment as Linux with better hardware support for Apple Silicon. FSEvents-based file watching is efficient and well-tested.

Windows notes

WSL2 closes most of the gap with Linux. Native PowerShell install works for basic tasks. File operations on Windows drives accessed from WSL2 are 3-5x slower than native Linux filesystem access.

Common Linux Issues

claude: command not found

The installer placed the binary at ~/.local/bin/claude but that directory is not in your PATH. Open a new terminal (some distributions load ~/.local/bin automatically in new sessions) or add it manually:

Fix PATH

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Verify
which claude

Permission denied during installation

This happens when ~/.local/bin/ or ~/.local/share/ is owned by root (from a previous sudo install attempt). Fix the ownership:

Fix directory ownership

sudo chown -R $USER:$USER ~/.local/bin ~/.local/share/claude
# Then re-run the installer
curl -fsSL https://claude.ai/install.sh | bash

ripgrep errors on Alpine or musl systems

If you see errors about ripgrep failing to execute on Alpine or other musl-based distributions, install the system packages and disable the built-in ripgrep:

Fix ripgrep on Alpine

apk add libgcc libstdc++ ripgrep

# Create settings.json if it doesn't exist
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "USE_BUILTIN_RIPGREP": "0"
  }
}
EOF

Authentication URL not printing on headless server

Some terminal emulators suppress URLs. Run Claude Code with the print flag to confirm the API key path works instead:

Test API key on headless server

ANTHROPIC_API_KEY=sk-ant-... claude -p "say hello"

Update stuck or failing

If auto-updates fail, run a manual update:

Manual update

claude update

# Or reinstall from scratch
curl -fsSL https://claude.ai/install.sh | bash

Uninstall Claude Code on Linux

Complete uninstall

# Remove the binary and version files
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claude

# Remove settings and session data (optional - this deletes all config)
rm -rf ~/.claude
rm -f ~/.claude.json

Frequently Asked Questions

How do I install Claude Code on Linux?

Run curl -fsSL https://claude.ai/install.sh | bash. Works on Ubuntu 20.04+, Debian 10+, Fedora, RHEL, and most glibc-based distributions. No Node.js required.

Does Claude Code work on headless Linux servers?

Yes. SSH into your server and run claude. It prints an authentication URL that you open on your local machine. After authenticating, the token is stored on the server. Use claude -p with an ANTHROPIC_API_KEY for fully non-interactive operation.

Does Claude Code support Alpine Linux?

Yes, with two extra steps. Install libgcc, libstdc++, and ripgrep via apk, then set USE_BUILTIN_RIPGREP=0 in your settings.json. Then run the standard installer.

Do I need Node.js to install Claude Code on Linux?

No. The native installer is self-contained. Node.js 18+ is only needed if you use the deprecated npm method.

How do I use Claude Code non-interactively in a script?

Use the -p flag: claude -p "your prompt". Set ANTHROPIC_API_KEY for authentication. Add --output-format json for parseable output in scripts. Set CLAUDE_CODE_MAX_TURNS to limit agent execution.

Is there a Claude Code desktop app for Linux?

No. The desktop app is macOS and Windows only. The CLI has no such limitation and is the primary interface for Linux users. The VS Code extension also works on Linux through the terminal.

Related Guides

Install Claude Code

Full installation guide covering macOS, Linux, and Windows. Native installer, Homebrew, npm, authentication, and post-install setup.

Claude Code on Windows

WSL2, native PowerShell, Docker, and VS Code Dev Containers. Covers CRLF issues, WSL2 filesystem performance, and Windows Terminal setup.

Claude Code in Docker

Run Claude Code in containers. Dockerfile setup, Alpine-based images, CI/CD integration, and volume mounts for project access.

CLAUDE.md Guide

Give Claude persistent context about your codebase. The most impactful post-install step for teams.

Supercharge Claude Code with Morph

Morph builds MCP servers that make Claude Code faster and more accurate. WarpGrep gives Claude RL-trained code search in its own context window. Fast Apply speeds up file edits by 10x. Both plug directly into Claude Code as MCP tools.