Reviewing a repository, tracing a bug, or drafting a patch is faster when the assistant can work inside your shell instead of in a browser tab. Anthropic’s native installer is the official way to install Claude Code on Ubuntu, while the other supported methods mostly matter when you already manage development tools through Homebrew or Node.js.
Claude Code works on Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS, including Ubuntu Server, but minimal images still need the curl command in Linux and enough memory for the initial download. Ubuntu’s default repositories do not provide an official claude-code package, so the supported installation paths are the ones that matter here.
Install Claude Code on Ubuntu
Ubuntu has one direct upstream path and two compatibility-oriented alternatives for Claude Code. The native installer remains the default recommendation for most Ubuntu systems because it updates itself and does not depend on Node.js.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Native installer | Anthropic setup docs | Latest upstream release | Automatic background updates | Most Ubuntu systems |
| Homebrew | Homebrew Cask | Latest cask release | Manual via brew upgrade | Users already on Homebrew |
| npm (deprecated) | npm registry | Latest npm package | Manual via npm update | Compatibility with an existing Node.js workflow |
If you searched for apt install claude or apt install claude-code, Ubuntu does not ship an official package for Claude Code. On Ubuntu 26.04, 24.04, and 22.04, apt-cache policy claude-code returns no candidate, so use one of the supported installer paths instead.
These instructions target Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. Claude Code requires a Claude Pro, Max, Teams, Enterprise, or Console-backed account, and the native installer worked the same way on all three supported Ubuntu LTS releases during validation.
Install Claude Code on Ubuntu with the Native Installer
The native installer is the cleanest Ubuntu path because it places the binary in ~/.local/bin, stores version files under ~/.local/share/claude, and keeps the CLI updated without a separate package manager.
Install curl first if your system does not already include it. Desktop Ubuntu installations often have it, but server and minimal images commonly do not.
sudo apt update
sudo apt install curl -y
These commands use
sudofor the steps that need root privileges. If your account is not in the sudoers file yet, follow the guide on how to add a new user to sudoers on Ubuntu before continuing.
Download the official installer and let it place the current native build in your home directory:
curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code... Checking installation status... Installing Claude Code native build latest... Setting up launcher and shell integration... Claude Code successfully installed! Version: 2.1.72 Location: ~/.local/bin/claude Next: Run claude --help to get started
If the installer warns that ~/.local/bin is not in your PATH, append that directory to your shell profile, open a new terminal, and then verify the launcher.
claude --version
2.1.72 (Claude Code)
The native installer also accepts a release target when you want the delayed stable channel or a pinned version:
curl -fsSL https://claude.ai/install.sh | bash -s stable
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.72
Install Claude Code on Ubuntu with Homebrew
Use Homebrew only if it already manages the rest of your CLI stack. If you still need the package manager itself, the guide to install Homebrew on Ubuntu covers the bootstrap, and Ubuntu systems also need install Git on Ubuntu before Homebrew can finish its own setup.
brew install --cask claude-code
After Homebrew links the binary into its prefix, verify the CLI from a shell where brew shellenv is already loaded:
claude --version
2.1.72 (Claude Code)
Homebrew does not use Claude Code’s background updater, so later upgrades stay in the Homebrew workflow.
Install Claude Code on Ubuntu with npm
The npm package is deprecated, so treat it as a compatibility option instead of the default Ubuntu path. Claude Code needs Node.js 18 or newer for this method, which Ubuntu 26.04 and 24.04 provide from their default repositories, but Ubuntu 22.04 does not.
If you do not already have a current Node.js runtime, the guide to install Node.js on Ubuntu covers the supported upgrade paths. Once Node.js 18 or newer is available, keep npm’s global prefix inside your home directory so the install works without sudo:
mkdir -p ~/.local
npm config set prefix ~/.local
npm install -g @anthropic-ai/claude-code
The
npm config set prefix ~/.localstep moves global npm packages into your home directory, which avoids theEACCESerrors Ubuntu returns when a normal user tries to write into/usr/local. Do not usesudo npm install -ghere.
The npm prefix above reuses ~/.local/bin, so the same PATH fix from the native method applies if claude is still missing in a new shell. You can verify the binary directly first:
~/.local/bin/claude --version
2.1.72 (Claude Code)
If you already have the deprecated npm build installed, migrate to the native build with the current supported command and then remove the npm package:
claude install
npm uninstall -g @anthropic-ai/claude-code
Authenticate Claude Code on Ubuntu
Claude Code needs an account before it can send prompts, read project context, or apply changes. Claude Pro, Max, Teams, Enterprise, Claude Console, and supported cloud-provider accounts work here, but the free Claude.ai tier does not.
Sign In to Claude Code on Ubuntu
Open a terminal inside the repository you want Claude Code to work with, then start the interactive session:
cd ~/your-project
claude
Claude Code opens a browser for the login flow on first launch. If no browser appears, press c to copy the login URL and open it manually. On Ubuntu Server or a remote SSH session, copy that URL into a browser on the machine you actually use for desktop browsing.
Amazon Bedrock, Google Vertex AI, and Microsoft Foundry accounts follow a different path. Set the provider environment variables first, then run claude; those integrations do not use the browser-based Claude.ai login flow.
Check Claude Code Authentication Status on Ubuntu
Use the CLI status command any time you want to confirm whether this shell is already authenticated:
claude auth status --text
Not logged in. Run claude auth login to authenticate.
Once you finish the browser flow, the same command returns account details instead of the warning. You can also start or reset authentication directly from the shell:
claude auth login
claude auth logout
Use Claude Code on Ubuntu
After the install and login steps, Claude Code behaves like a terminal-native coding assistant instead of a browser chatbot. Start in a project directory, give it a concrete task, and let it read files, run commands, and propose edits in context.
Start a Claude Code Session on Ubuntu
Launching claude in a repository starts the interactive session that most developers use day to day:
cd ~/your-project
claude
Type /help to list built-in commands, or use /init to create a project-level CLAUDE.md file that explains your coding conventions and repository layout.
Use Common Claude Code Commands on Ubuntu
These are the commands worth learning first if you want faster daily use instead of hunting through the command palette every session:
| Command | What It Does |
|---|---|
claude | Starts the interactive session in the current project |
claude -p "explain this function" | Runs one non-interactive prompt and exits |
claude -c | Continues the most recent session in the current directory |
claude -r "session-name" | Resumes a named or ID-based session |
/help | Shows built-in commands and bundled skills |
/init | Creates a project CLAUDE.md instructions file |
/config | Opens the settings interface |
/status | Shows version, account, and active configuration sources |
/memory | Edits Claude Code memory files for the current project |
Try Claude Code Prompts on Ubuntu
These first prompts mirror the workflows Anthropic documents in its quickstart and map well to everyday Ubuntu development sessions:
claude
> what does this project do?
> where is the main entry point?
> add tests for the authentication helper
When you only need one answer without staying in the REPL, print mode is faster:
claude -p "explain the function in src/auth.ts"
claude -c -p "continue with the next failing test"
Configure Claude Code on Ubuntu
Claude Code keeps its settings in a small set of JSON files, with separate scopes for your user account and for the repository you are working in. That split matters on Ubuntu because personal preferences and team-shared instructions usually do not belong in the same file.
Review Claude Code Settings Files on Ubuntu
| Path | Purpose |
|---|---|
~/.claude/settings.json | User-wide settings such as permissions, hooks, and model defaults |
.claude/settings.json | Shared project settings stored with the repository |
.claude/settings.local.json | Local project overrides that stay out of source control |
~/.claude.json | Global state such as OAuth session data, theme, and local MCP state |
.mcp.json | Project MCP server configuration |
Open Claude Code Settings on Ubuntu
The interactive settings UI is usually faster than hand-editing JSON when you only want to inspect or toggle common options:
/config
/status
/config opens the settings interface, while /status shows which configuration sources are active and whether any of them contain errors.
Set Claude Code Update Preferences on Ubuntu
The official settings file can hold both the preferred release channel and the environment variable that disables the background updater:
{
"autoUpdatesChannel": "stable",
"env": {
"DISABLE_AUTOUPDATER": "1"
}
}
Use stable when you want a delayed release channel that skips problematic builds. Keep latest if you want new Claude Code features as soon as Anthropic publishes them.
Update Claude Code on Ubuntu
Update Claude Code with the same toolchain you used for installation. Native installs and package-managed installs do not share update state, so mixing commands is what usually creates version confusion.
Update Native Claude Code on Ubuntu
Native installations update themselves in the background, but you can force an immediate check when you want the latest build right away:
claude update
Update Homebrew Claude Code on Ubuntu
Homebrew casks only move when Homebrew updates them, so keep the cask and its cached files tidy in the same pass:
brew upgrade claude-code && brew cleanup claude-code
Update npm Claude Code on Ubuntu
The deprecated npm package still follows the usual npm upgrade flow, although migrating to the native build remains the better long-term choice. Run it from the same user account and npm prefix you configured during installation:
npm update -g @anthropic-ai/claude-code
Troubleshoot Claude Code on Ubuntu
Most Ubuntu problems come down to PATH, download connectivity, search tooling, or running a diagnostic command from the wrong kind of terminal. These checks cover the issues that showed up during live validation and the ones Anthropic documents most often.
Fix Claude Code Command Not Found on Ubuntu
If claude is missing after a successful install, confirm the launcher exists before you change your shell profile:
ls -l ~/.local/bin/claude
lrwxrwxrwx 1 linuxcapable linuxcapable 54 Mar 11 11:54 /home/linuxcapable/.local/bin/claude -> /home/linuxcapable/.local/share/claude/versions/2.1.72
If that symlink exists, add ~/.local/bin to your shell profile and reload it. Bash users can update ~/.bashrc, while Zsh users should put the same line in ~/.zshrc after they install Zsh on Ubuntu.
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
claude --version
2.1.72 (Claude Code)
Fix Claude Code Installer Download Errors on Ubuntu
If the installer returns HTML instead of a shell script, or if curl breaks mid-download, verify that your machine can still reach the real installer URL:
curl -fsSL https://claude.ai/install.sh -o /dev/null && echo reachable
reachable
If that command fails, retry from a different network or set HTTP_PROXY and HTTPS_PROXY before running the installer again. If the returned HTML says Claude Code is unavailable in your region, the install script is working as designed and you need an account from a supported country.
Fix Claude Code Search Issues on Ubuntu
If @file mentions, search, or discovery features feel incomplete, switch Claude Code to the system ripgrep package instead of the bundled binary:
sudo apt install ripgrep -y
Add the environment override to ~/.claude/settings.json or to the project settings file if you only want the change in one repository:
{
"env": {
"USE_BUILTIN_RIPGREP": "0"
}
}
Run Claude Code Diagnostics on Ubuntu
claude doctor is the quickest way to inspect install method, search status, and update state, but it expects a real TTY. Run it in a normal terminal window rather than through a non-interactive SSH pipe:
claude doctor
Diagnostics Currently running: native (2.1.72) Path: /home/linuxcapable/.local/share/claude/versions/2.1.72 Config install method: native Search: OK (bundled) Updates Auto-updates: enabled Auto-update channel: latest Stable version: 2.1.58 Latest version: 2.1.72
Fix Claude Code Login Problems on Ubuntu
If browser login fails, clear the current session and start the OAuth flow again. When Ubuntu is running over SSH or on a headless server, remember that the login URL must open on a machine with a browser, not inside the remote shell itself.
claude auth logout
claude auth login
Remove Claude Code from Ubuntu
Remove Claude Code with the same method you used to install it. The native uninstall removes the launcher and version files first, while your personal settings stay behind until you explicitly delete them.
Remove Native Claude Code from Ubuntu
Delete the launcher and the version directory that the native installer created:
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claude
Verify that the command is gone from your shell:
command -v claude || echo command-not-found
command-not-found
During validation, ~/.claude and ~/.claude.json still remained after native removal, so clean those separately only if you want to wipe your settings and history too.
Remove Homebrew Claude Code from Ubuntu
Homebrew keeps this removal inside its own cask database:
brew uninstall --cask claude-code
Remove npm Claude Code from Ubuntu
If you stayed on the deprecated npm package, remove it through npm from the same user-local prefix instead of deleting files manually:
npm uninstall -g @anthropic-ai/claude-code
Remove Claude Code Settings on Ubuntu
Delete the configuration files only when you want a full reset of your user state and project-specific Claude Code metadata:
Removing these files deletes your Claude Code settings, OAuth session, project memory, MCP configuration, and local session history. Keep them if you only wanted to remove the executable.
rm -rf ~/.claude
rm -f ~/.claude.json
rm -rf .claude
rm -f .mcp.json
Claude Code on Ubuntu FAQ
No. Ubuntu 26.04, 24.04, and 22.04 do not provide an official claude-code package in the default repositories. Use Anthropic’s native installer, the Homebrew cask, or the deprecated npm package instead.
Yes. The official Ubuntu download path is Anthropic’s install script at https://claude.ai/install.sh, which fetches the current native Linux build and enables background updates. That is the recommended Ubuntu method unless you already manage the CLI through Homebrew.
Use the native installer on most Ubuntu systems because it does not depend on Node.js and updates itself automatically. Use Homebrew only when brew already manages the rest of your CLI stack, and keep npm as a compatibility path for existing Node.js workflows rather than a fresh default install.
Yes. Claude Code works on Ubuntu Server and minimal cloud images as long as the machine can reach Anthropic’s installer URL, has enough memory for the initial install, and can complete the browser-based login flow. On a headless server, copy the login URL into a browser on your workstation when prompted.
Yes. The native installer worked on Ubuntu 22.04 during validation, and Homebrew can also be used there. The only extra caveat is the deprecated npm path: Ubuntu 22.04 ships Node.js 12.x in the default repositories, so you need Node.js 18 or newer before npm installation will work.
Conclusion
Claude Code is installed on Ubuntu and ready to work from your project directories, whether you chose the native installer or a package-managed path. Start in a repository with claude, use /init to add project instructions, and pair it with install Git on Ubuntu if you want cleaner commit, diff, and review workflows.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>