How to Install Claude Code on Ubuntu and Linux

By 

Published on

6 min read

Installing the Claude Code AI coding assistant in a Linux terminal on Ubuntu

Claude Code is Anthropic’s AI coding agent for the terminal. You start it inside a project directory, describe what you want in plain language, and it reads the code, edits files, and runs commands to get there.

This guide covers the recommended native installer first, then the official Linux package-manager repositories and npm alternative for systems that need them.

Prerequisites

Claude Code runs on Ubuntu 20.04+, Debian 10+, and Alpine 3.19+, on x64 or ARM64, with at least 4 GB of RAM. You also need a Claude account: a Pro, Max, Team, or Enterprise plan, or an Anthropic Console account with API billing. The free Claude.ai plan does not include Claude Code access.

Quick Reference

TaskCommand
Install, recommendedcurl -fsSL https://claude.ai/install.sh | bash
Install with apt, advancedsudo apt install claude-code (after adding the repository)
Install with dnf, advancedsudo dnf install claude-code (after adding the repository)
Install with apk, advancedapk add claude-code (after adding the repository)
Install with npm, alternativenpm install -g @anthropic-ai/claude-code
Verifyclaude --version or claude doctor
Startclaude (inside a project directory)
Updateclaude update
Uninstall (native)rm -f ~/.local/bin/claude && rm -rf ~/.local/share/claude

Anthropic’s native installer works on every supported distribution and keeps itself updated in the background:

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

As with any piped installer, you can download the script first and read it before running it. The installer places the claude binary in ~/.local/bin and its version data in ~/.local/share/claude; no root privileges are needed. On Alpine and other musl-based distributions, install libgcc, libstdc++, and ripgrep through the package manager first, then set USE_BUILTIN_RIPGREP=0 in the env section of Claude Code’s settings.json.

By default you get the latest release channel. If you prefer the stable channel, which trails by about a week and skips releases with major regressions, install with:

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

Option 2: Linux Package Managers (Advanced)

The native installer is the recommended path for most Linux workstations. Anthropic also publishes official signed apt, dnf, and apk repositories for managed systems where updates should flow through the operating system package manager.

On Ubuntu, Debian, and Derivatives, add the signing key and the apt repository, then install the package:

Terminal
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc -o /etc/apt/keyrings/claude-code.asc
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
sudo apt update
sudo apt install claude-code

Before trusting the key, verify its fingerprint:

Terminal
gpg --show-keys /etc/apt/keyrings/claude-code.asc

The reported fingerprint should be 31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE. Package manager installations do not auto-update; new versions arrive through your normal sudo apt update && sudo apt upgrade workflow.

On Fedora, RHEL, and Derivatives, create a dnf repository file and install the package:

Terminal
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
sudo dnf install claude-code

When dnf prompts you to accept the signing key, verify that the fingerprint matches 31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE. To upgrade later, run:

Terminal
sudo dnf upgrade claude-code

On Alpine Linux, download the repository key, add the stable repository, and install the package:

Terminal
wget -O /etc/apk/keys/claude-code.rsa.pub https://downloads.claude.ai/keys/claude-code.rsa.pub
echo "https://downloads.claude.ai/claude-code/apk/stable" >> /etc/apk/repositories
apk add claude-code

Verify the downloaded Alpine key before trusting it:

Terminal
sha256sum /etc/apk/keys/claude-code.rsa.pub

The checksum should be 395759c1f7449ef4cdef305a42e820f3c766d6090d142634ebdb049f113168b6. To upgrade later, run apk update && apk upgrade claude-code.

Option 3: npm

If you already manage global tools through npm, Claude Code is available as a package. It requires Node.js 22 or later:

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

The package downloads the same native binary the standalone installer uses, so the installed claude command does not run through Node.js at runtime.

Warning
Do not run npm install -g with sudo. It creates root-owned files in your npm directory and breaks later updates. If the install fails with permission errors, configure npm to use a user-writable global prefix instead.

To upgrade an npm installation later, run npm install -g @anthropic-ai/claude-code@latest.

Verifying the Installation

Confirm the binary is on your PATH and working:

Terminal
claude --version
output
2.1.201 (Claude Code)

Your version number will differ. For a fuller health check covering the installation type, auto-update status, and configuration, run:

Terminal
claude doctor

First Run and Sign-In

Start Claude Code from inside the project you want to work on, since it uses the current directory as its workspace:

Terminal
cd ~/projects/my-app
claude

On the first run it opens a browser window to sign in. Log in with your Claude.ai account (Pro, Max, Team, or Enterprise) or with an Anthropic Console account if you pay per API usage. After authenticating once, the session is stored and you go straight to the prompt on subsequent runs. From there, try something small first, for example explain this project or summarize what app.js does.

Updating Claude Code

Native installations check for updates on startup and install them in the background, so normally there is nothing to do. To force an update immediately:

Terminal
claude update

Package-manager installations update with the system. Use sudo apt update && sudo apt upgrade claude-code on Ubuntu and Debian, sudo dnf upgrade claude-code on Fedora and RHEL, and apk update && apk upgrade claude-code on Alpine. Npm installations update with npm install -g @anthropic-ai/claude-code@latest.

Uninstalling Claude Code

For the native installer, remove the binary and version data:

Terminal
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claude

For apt, remove the package and repository configuration:

Terminal
sudo apt remove claude-code
sudo rm /etc/apt/sources.list.d/claude-code.list /etc/apt/keyrings/claude-code.asc

For dnf, remove the package and repository file:

Terminal
sudo dnf remove claude-code
sudo rm /etc/yum.repos.d/claude-code.repo

For apk, remove the package, repository entry, and key:

Terminal
apk del claude-code
sed -i '\|downloads.claude.ai/claude-code/apk|d' /etc/apk/repositories
rm /etc/apk/keys/claude-code.rsa.pub

For npm, run npm uninstall -g @anthropic-ai/claude-code. User settings and session history live in ~/.claude and ~/.claude.json; delete those too if you want to remove user-level state. Claude Code can also create project-level .claude directories and .mcp.json files, so remove those from individual projects only when you no longer need their saved settings.

Troubleshooting

claude: command not found after installing
The native installer puts the binary in ~/.local/bin, which some shells do not have on their PATH. Add it to your shell profile and reload:

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

npm prints an EBADENGINE warning
Your Node.js is older than version 22. The install usually still completes, since the package ships a native binary, but upgrading Node.js removes the warning and matches the supported configuration.

Sign-in loop or “This account does not have access”
Claude Code is not included in the free Claude.ai plan. Log in with a Pro, Max, Team, or Enterprise account, or use an Anthropic Console account with billing set up.

Conclusion

The one-line native installer is the right choice for most machines, the apt repository fits servers that standardize on package-manager updates, and npm works where Node.js tooling is already in place; all three install the same binary. Once you are set up, Claude Code pairs naturally with the GitHub CLI for turning its changes into commits and pull requests, and if you prefer running models locally, see our guide to Ollama on Ubuntu .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page