How to install Claude Code on Linux. On a small server the installer can run out of memory

How to install Claude Code on Ubuntu, Debian, Fedora and Alpine. The install script, the apt, dnf and apk repositories, logging in over SSH, common errors and uninstalling.

Part of the guideClaude Code, the complete guide. From installation to your own skills and plugins

In this article
  1. Requirements before you install Claude Code on Linux
  2. Install with the script or from a repository
  3. Alpine and other musl distributions
  4. Logging in on a server without a browser
  5. Common installation errors on Linux
  6. Sandboxing, updates and uninstalling

In short

On Linux, Claude Code installs with a script or from signed apt, dnf and apk repositories. We cover distribution requirements, Alpine, logging in on a server without a browser, memory and library errors, and uninstalling.

On the cheapest cloud server, the Claude Code install ends with a single word, Killed. That is not a bug in the program. It is the system killing the process because memory ran out. Linux gives you more ways to install than a Mac or Windows, and more places where things can go differently. Everything below was checked against the Anthropic documentation as of 10 November 2026.

What the tool itself does is covered in What is Claude Code. The rest of the series lives in the Claude Code guide.

Requirements before you install Claude Code on Linux

The documentation lists Ubuntu 20.04 and later, Debian 10 and later, and Alpine Linux 3.19 and later. Package repositories also exist for Fedora and RHEL. The processor must be x64 or ARM64, with at least 4 GB of RAM. The install step alone needs roughly 512 MB of free memory. To log in you need a Pro, Max, Ultra, Team or Enterprise plan, a Claude Console account, or access through your company's cloud provider.

Windows with WSL follows these same instructions, because in WSL you install the Linux version. The differences are in the Windows install guide.

Install with the script or from a repository

The simplest route is the install script. That version updates itself.

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

The program goes to ~/.local/bin/claude, and its versions to ~/.local/share/claude/versions/. When the installer finishes, open a new terminal session and run claude --version. claude doctor checks the install and settings files without starting a session.

On servers, repositories are often more convenient because updates arrive with the rest of the system. Anthropic runs signed apt, dnf and apk repositories, each with a stable and a latest channel. Stable serves a version that is usually about a week old and skips releases with major regressions. This is the stable channel on Debian and Ubuntu.

bash
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
gpg --show-keys /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

gpg --show-keys should print exactly one fingerprint, 31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE. If a fresh system is missing curl or gpg, install them with sudo apt install curl gnupg. On Fedora and RHEL you add the repository with a file in /etc/yum.repos.d/ and install with sudo dnf install claude-code. The documentation has the exact file contents.

A repository install does not update through Claude Code. You update it with your normal system upgrade, for example sudo apt update && sudo apt upgrade claude-code or sudo dnf upgrade claude-code.

Alpine and other musl distributions

Alpine has no bash or curl by default, so the install script fails with not found. Install the needed packages first.

bash
apk add bash curl libgcc libstdc++ ripgrep

ripgrep is in the community repository. If apk cannot find it, add that repository to /etc/apk/repositories and run apk update. Then set USE_BUILTIN_RIPGREP to 0 in ~/.claude/settings.json so Claude Code uses the system ripgrep. Anthropic also runs an apk repository, in which case the install is apk add claude-code after you add the key and the repository address.

Logging in on a server without a browser

On first start, claude wants to open a browser. Over SSH or in a container there is none, so press c to copy the login address. Open it in a browser on your own computer and sign in. The page shows a code, which you paste into the terminal at Paste code here. If pasting does not work, use claude auth login, which reads the code from standard input.

On Linux the login is stored in ~/.claude/.credentials.json with mode 0600, so only your user can access it. A Mac uses the Keychain, here it is a plain file, so do not copy your ~/.claude folder to other people's machines.

Common installation errors on Linux

The documentation describes a few symptoms that mostly happen on Linux.

  • Killed, or a message about the install being killed with exit code 137, means out of memory. Close other processes or add a swap file, for example 2 GB, and run the script again.
  • The install hangs in a Docker container when the script starts from /. Set WORKDIR /tmp first.
  • Error loading shared library libstdc++.so.6 means you got the musl build on a glibc system or the other way round. ldd --version tells you which one you have.
  • Illegal instruction means the wrong architecture or a CPU without AVX, common in older virtual machines. Another install method will not help, because it downloads the same binary.
  • bash: claude: command not found means ~/.local/bin is not on PATH. Add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc and open a new session.

If home folders live on network storage, a session can crash with Bus error when an update on another machine removes the file it is running. The documentation recommends installing the binary on local disk in that case, for example from a repository.

Sandboxing, updates and uninstalling

On Linux and WSL 2, Claude Code can run commands in a sandbox that limits file and network access. It needs the bubblewrap and socat packages, installed on Debian and Ubuntu with sudo apt-get install bubblewrap socat. Running /sandbox inside a session shows what is missing.

The script install updates itself, and claude update does it right away. Removing it looks like this.

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

An apt install is removed with sudo apt remove claude-code, dnf with sudo dnf remove claude-code, and apk with apk del claude-code. Remove the repository file and the key as well. Settings, approvals and history stay in ~/.claude and the ~/.claude.json file.

After installing, go on to first run and login, and before working on a server read about Claude Code permissions.

On a low-memory server, add swap first and run the installer after that. If you want to find out where AI could take work off your business beyond code, our free AI audit is a good place to start.

What would you like to change in your business?

Leave your number. We will talk about your process and see whether we can help. The first call is free.

When is the best time to call?
Controller: Oleksandr Bondarenko (BondSoft)Privacy PolicyTerms of Service
Legal details

The data controller is Oleksandr Bondarenko, trading as Oleksandr Bondarenko Software Solutions (BondSoft), ul. Jana Heweliusza 11, 80-890 Gdańsk, Poland, NIP 5833576264, e-mail: office@bondsoft.pl.

We process your data solely to contact you about your enquiry and to present an offer — on the basis of your consent (Art. 6(1)(a) GDPR and Art. 398 of the Polish Electronic Communications Law) and our legitimate interest in handling the enquiry (Art. 6(1)(f) GDPR).

Providing the data is voluntary but necessary for us to reply. You may withdraw your consent at any time by writing to office@bondsoft.pl — this does not affect the lawfulness of processing before the withdrawal.

You have the right to access your data, rectify it, erase it, restrict its processing, transfer it, and lodge a complaint with the President of the Polish Personal Data Protection Office.

Full information: Privacy Policy.

Send us an email

The service this text is about

Automation and AI / OCR

Automation of document re-typing, OCR and checking rules, and your data stays with you.