UbuntuUbuntu Based

How To Install Claude Code on Ubuntu 24.04 LTS

Install Claude Code on Ubuntu 24.04 LTS

If you spend most of your day in a terminal, you already know the value of tools that fit your workflow instead of fighting it. Claude Code is Anthropic’s official AI coding assistant that runs directly in your shell — no browser tab, no context switching, no IDE plugin required. In this guide, you will learn exactly how to install Claude Code on Ubuntu 24.04 LTS, authenticate your account, verify the setup, and start using it in your projects within minutes.

This tutorial covers two installation methods: the native binary installer (recommended) and the npm method for Node.js developers. You will also find a dedicated troubleshooting section for the most common errors Ubuntu users hit during setup.

What Is Claude Code and Why Does It Matter for Linux Developers?

Before diving into commands, it helps to understand what you are actually installing and why it is different from other AI coding tools.

Claude Code CLI is a terminal-native interface for Anthropic’s Claude AI. Unlike GitHub Copilot (which lives inside VS Code) or ChatGPT (which lives in a browser), Claude Code runs as a shell process alongside your existing workflow.

You can ask it to read files, generate code, refactor functions, run commands, explain architecture decisions, and manage Git workflows — all without leaving your terminal. It supports any language, any editor, and any project structure.

Ubuntu 24.04 LTS (Noble Numbat) is a tier-1 supported platform for Claude Code. This means Anthropic actively tests and maintains compatibility against this release, so you are on stable ground.

There are two ways to use Claude Code:

  • Claude Pro/Max/Teams subscription — ~$20/month, best for individual developers with consistent usage
  • Anthropic Console account — pay-per-use API billing, best for teams, automation pipelines, and variable workloads

Both methods work on Ubuntu 24.04 LTS with no functional difference in how you install the tool itself.

Prerequisites Before You Install Claude Code on Ubuntu 24.04

Make sure you meet all of these requirements before running any commands. Skipping this step is the number-one reason installations fail.

System Requirements

  • Ubuntu 24.04 LTS (Noble Numbat) — 64-bit
  • Minimum 4 GB RAM (8 GB recommended for comfortable use)
  • At least 500 MB free disk space
  • Active internet connection (required for installation and all Claude Code operations)
  • Bash or Zsh shell (both ship with Ubuntu 24.04 by default)

Account Requirements

  • An active Anthropic account — no free offline tier exists
  • Either a Claude Pro/Max/Teams subscription or an Anthropic Console account with billing enabled and at least $5 in API credits
  • Sign up at console.anthropic.com if you do not already have an account

Software Requirements

  • curl — pre-installed on most Ubuntu 24.04 systems (required for the native method)
  • Node.js 18 or higher — required only for the npm method
  • Git 2.23+ — optional, but strongly recommended for project workflows

Step 1: Update Your Ubuntu 24.04 LTS System

Always start with a full system update. This prevents dependency mismatches, ensures you have the latest curl binary, and reduces the chance of mid-install conflicts.

Open your terminal and run:

sudo apt update && sudo apt upgrade -y

What this does: apt update refreshes your package index from all configured repositories. apt upgrade -y upgrades all installed packages without prompting for confirmation.

Next, confirm your Ubuntu version to make sure you are on 24.04 LTS:

lsb_release -a

Expected output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.2 LTS
Release:        24.04
Codename:       noble

Finally, make sure curl is available:

curl --version

If curl is missing, install it:

sudo apt install curl -y

Your system is now ready for installation.

Step 2: Install Claude Code via Native Binary (Recommended Method)

Why the Native Binary Is the Right Choice

Anthropic officially moved away from recommending npm as the primary installation method. The native binary installer is now the recommended approach for all Linux users for good reason:

  • No Node.js dependency — it installs as a standalone self-contained binary
  • Automatic updates — the binary checks for and applies updates on its own
  • No root/sudo required — installs to ~/.local/bin/claude in your home directory
  • Simpler PATH management — the installer handles it automatically for most shells

Run the Official Installer Script

Run this single command to download and install Claude Code directly from Anthropic’s CDN:

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

What each flag does:

  • -f — Fail silently on HTTP errors instead of returning a response body
  • -s — Silent mode: suppresses progress meter
  • -S — Show errors when -s is active
  • -L — Follow redirects automatically

Expected output after a successful install:

Setting up Claude Code...
✔ Claude Code successfully installed!
Version: 2.x.x
Location: ~/.local/bin/claude
Next: Run claude --help to get started

The installer automatically adds ~/.local/bin to your PATH by appending an export line to your .bashrc or .profile.

Install a Specific Version (Optional)

If you need a pinned version for a team environment or CI/CD pipeline, the installer script accepts version arguments:

# Install the stable channel (approximately one week behind latest)
curl -fsSL https://claude.ai/install.sh | bash -s stable

# Install a specific pinned version number
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.0

Reload Your Shell

After installation, reload your shell configuration so the PATH change takes effect:

source ~/.bashrc

If you use Zsh:

source ~/.zshrc

Step 3: Alternative — Install Claude Code via npm on Ubuntu 24.04 Setup

If you are a Node.js developer and prefer managing tools through npm, this method works well. It also gives you more control over the installed version via npm’s standard package management commands.

Install Node.js 20.x via NodeSource

Ubuntu 24.04’s default APT repository ships an older version of Node.js. Use the official NodeSource repository to get Node.js 20 LTS, which meets Claude Code’s minimum requirement of Node.js 18+.

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

Verify the installation:

node --version   # Expected: v20.x.x
npm --version    # Expected: v10.x.x or higher

Configure npm for Non-Root Global Installs

This step is critical. Never run sudo npm install -g — it creates file ownership conflicts, breaks future updates, and introduces security risks.

Instead, configure a user-level global directory:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

What this does: It tells npm to install global packages into your home directory rather than into system-owned paths. This means you never need root permissions for npm install -g again.

Install Claude Code Globally via npm

With permissions sorted, install Claude Code globally:

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

This command downloads the @anthropic-ai/claude-code package and all its dependencies, then places the claude binary in ~/.npm-global/bin. Expect it to take 30–60 seconds depending on your connection speed.

Step 4: Verify the Installation

Regardless of which installation method you used, run these two checks to confirm everything is working.

Check the installed version:

claude --version

Expected output:

2.x.x (Claude Code)

Run the built-in health diagnostic:

claude doctor

Expected output for a healthy native install:

Claude Code Doctor

Installation
  Install method: native
  Version: 2.x.x
  Update channel: latest

System
  Operating system: linux
  Node.js: Not required (native installation)
  Shell: /bin/bash

Status: All checks passed

For npm installations, the Node.js line will show your installed version instead of “Not required.” If claude doctor reports any failures, see the Troubleshooting section below.

Step 5: Authenticate Claude Code and Configure Your Account

With the binary installed and verified, you now need to link Claude Code to your Anthropic account. This is a one-time setup that only takes a couple of minutes.

Launch Claude Code for the First Time

Navigate to any project directory and start Claude Code:

cd ~/your-project
claude

On first launch, Claude Code automatically starts the authentication wizard. You will see a login method selector in your terminal.

Authentication Method A — Claude Pro/Max/Teams Subscription

Select option 1: “Claude account with subscription” from the menu.

Claude Code will generate a browser URL. Open it, log in to your claude.ai account, and grant the requested permissions:

  • Access to your Anthropic profile information
  • Permission to generate API usage on your behalf
  • Session access for persistent authentication

After approving, copy the authorization code from your browser and paste it back into the terminal prompt. Claude Code stores your credentials at ~/.claude/ and you will not need to repeat this step unless you log out or rotate your credentials.

Authentication Method B — Anthropic Console API Key

Select option 2: “Anthropic Console account” from the menu.

Navigate to https://console.anthropic.com/settings/keys in your browser. Click Create Key, give it a descriptive name (e.g., claude-code-ubuntu-dev), and copy the full key string — it starts with sk-ant-.

Paste the key when prompted in your terminal. You should see:

API key validated successfully.
Login successful.

Important: Ensure your Console account has billing enabled and at least $5 in credits loaded before attempting API key authentication.

Choose Your Terminal Theme

On first launch, Claude Code also prompts you to choose between Dark and Light terminal themes. You can change this later with:

claude config

Step 6: Essential Commands to Get Started on Ubuntu 24.04

Now that Claude Code is installed and authenticated, here are the key commands every Ubuntu developer should know:

Command What It Does
claude Start an interactive session in the current directory
claude --version Check the installed version number
claude doctor Run a full system health check
claude update Pull and install the latest available version
claude config View and modify configuration settings
claude "explain this function" Ask a one-shot question without entering interactive mode

Starting a session inside VS Code’s integrated terminal: Claude Code works perfectly inside VS Code’s built-in terminal with no additional extensions required. Open a terminal in VS Code with Ctrl + `, navigate to your project, and run claude.

To exit any Claude Code session, type exit or press Ctrl+C.

Step 7: Security Best Practices for Your Claude Code on Ubuntu 24.04 Setup

Security is not an afterthought — especially if you use Claude Code on a server or in a team environment.

  • Never store your API key in plaintext — do not commit sk-ant- keys to .env files or shell config files in shared repositories.
  • Never run Claude Code as root — always use a standard user account.
  • Set spending limits on your Anthropic Console account at https://console.anthropic.com/settings/limits to cap unexpected API costs.
  • Rotate API keys periodically — generate new keys in the Console and revoke old ones every 90 days in production environments.
  • Use network access controls in enterprise deployments — implement pilot groups before rolling out to your entire team.

Troubleshooting: Common Errors When You Configure Claude Code on Ubuntu 24.04

Even with a clean Ubuntu 24.04 LTS installation, a few common issues appear regularly. Here are the most frequent ones and exactly how to fix them.

Error 1: “command not found: claude”

Cause: The directory containing the claude binary is not in your system’s $PATH. This happens with both the native and npm methods if the shell was not reloaded after installation.

Fix:

source ~/.bashrc
# For Zsh users:
source ~/.zshrc

If the problem persists, manually add the correct path:

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

# For npm install:
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Error 2: npm Permission Error During Global Install

Cause: npm’s global prefix is set to a root-owned system directory.

Fix:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g @anthropic-ai/claude-code

Never use sudo with npm install -g.

Error 3: Node.js Version Too Old

Cause: Ubuntu 24.04’s built-in APT Node.js package may be below the required version 18+.

Fix: Remove the system Node.js and install from NodeSource:

sudo apt remove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
node --version  # Should show v20.x.x

Error 4: Authentication Fails / Authorization Code Error

Cause: Either the Anthropic account has no billing enabled, the region is not supported, or the OAuth flow timed out.

Fix:

  • Confirm your Anthropic Console account has billing enabled and credits loaded
  • Check that your country/region is on Anthropic’s supported list at console.anthropic.com
  • Re-run claude and restart the OAuth flow — authorization codes expire quickly
  • If using API key auth, generate a fresh key and verify it starts with sk-ant-

Error 5: claude doctor Reports Failures

Cause: Usually an outdated binary, a broken PATH, or a missing internet connection.

Fix:

# Update the binary
claude update

# Confirm internet connectivity
curl -I https://api.anthropic.com

# Re-run diagnostics
claude doctor

How to Update or Uninstall Claude Code on Ubuntu 24.04

Update Claude Code

For the native binary method, updates are automatic. You can also trigger one manually:

claude update

For the npm method:

npm update -g @anthropic-ai/claude-code

Uninstall Claude Code

Native install:

rm -rf ~/.local/bin/claude ~/.local/share/claude-code

npm install:

npm uninstall -g @anthropic-ai/claude-code

Remove stored credentials and config data:

rm -rf ~/.claude

Congratulations! You have successfully installed Claude Code. Thanks for using this tutorial for installing Claude Code on your Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Claude Code website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a dedicated and highly skilled Linux Systems Administrator with over a decade of progressive experience in designing, deploying, and maintaining enterprise-grade Linux infrastructure. His professional journey began in the telecommunications industry, where early exposure to Unix-based operating systems ignited a deep and enduring passion for open-source technologies and server administration.​ Throughout his career, r00t has demonstrated exceptional proficiency in managing large-scale Linux environments, overseeing more than 300 servers across development, staging, and production platforms while consistently achieving 99.9% system uptime. He holds advanced competencies in Red Hat Enterprise Linux (RHEL), Debian, and Ubuntu distributions, complemented by hands-on expertise in automation tools such as Ansible, Terraform, Bash scripting, and Python.
Back to top button