Installing Claude Code Into Your Linux System

By Gian Valentino Ampang

SysAdmin
Claude Code Linux Setup Banner

Introduction

Claude Code is an AI-powered agentic coding assistant developed by Anthropic. Operating directly inside your terminal, IDE, or desktop environment, it can analyze codebases, edit files, execute shell commands, and manage Git workflows—all using plain language instructions.

Free Tier Tip: While using Claude Code directly through Anthropic's official API can get expensive, you can run it 100% free on Linux by routing it through OpenRouter's free model tier.

Step 1: Update Your System and Install Dependencies

Before installing Claude Code, ensure your package manager is up to date and that Node.js and npm are installed on your system.

1. Update Package Managers

Choose the command corresponding to your Linux distribution:

bash — Debian / Ubuntu
$ sudo apt update && sudo apt upgrade -y
bash — Fedora
$ sudo dnf update && sudo dnf upgrade -y
bash — Arch Linux
$ sudo pacman -Syu
bash — openSUSE
$ sudo zypper refresh && sudo zypper update -y

2. Install Node.js and npm

If you do not have Node.js and npm installed yet, run the appropriate command for your system:

bash — Install Node.js & npm
# Debian / Ubuntu
$ sudo apt install nodejs npm -y

# Fedora
$ sudo dnf install nodejs npm -y

# Arch Linux
$ sudo pacman -S nodejs npm

# openSUSE
$ sudo zypper install nodejs npm -y

3. Install Claude Code

Run the official installation script:

Installing Claude Code script
bash — Install script
$ curl -fsSL https://claude.ai/install.sh | bash

Once the installation finishes, add the binary path to your shell profile so your system can locate the claude executable:

bash — Export environment PATH
$ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
Tip: You can verify where Claude Code was installed by running: which claude

Step 2: Obtain a Free OpenRouter API Key

OpenRouter Key Generation Dashboard
  • Go to OpenRouter.ai and create a free account (or log in).
  • Navigate to your Account Dashboard and click Get API Keys.
  • Click Create Key, give it a name, and copy the generated API key immediately.
Important: Save your API key somewhere secure (like a password manager). You will not be able to view full key details again after closing the window.

Using the openrouter/free endpoint allows OpenRouter to automatically route your requests to available free models (such as nvidia/nemotron-3-ultra or others) and rotate them if daily limits are reached.

Step 3: Configure Claude Code to Use OpenRouter

Now, direct Claude Code to route requests through OpenRouter by adding the necessary environment variables to your configuration file.

Open your bash configuration file in a text editor:

bash — Open bashrc
$ nano ~/.bashrc

Scroll to the bottom of the file and paste the following block:

bash — OpenRouter Config
# ==========================================
# OpenRouter Free Model Configuration for Claude Code
# ==========================================
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="sk-or-v1-YOUR-OPENROUTER-KEY-HERE"
export ANTHROPIC_API_KEY=""

# Set primary model to OpenRouter's free tier
export ANTHROPIC_MODEL="openrouter/free"

# Route background agents to the free model tier
export ANTHROPIC_DEFAULT_SONNET_MODEL="openrouter/free"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="openrouter/free"

(Be sure to replace sk-or-v1-YOUR-OPENROUTER-KEY-HERE with your actual key).

Save and exit the editor (Ctrl + O, Enter, then Ctrl + X in nano).

Reload your configuration to apply the changes:

bash — Reload environment
$ source ~/.bashrc

Step 4: Run Claude Code

Launching Claude Code Terminal

Navigate to your target project directory and launch Claude Code:

bash — Launch agent
$ cd /path/to/your/project
$ claude

You can now interact with and maintain your project using plain English instructions right from your terminal.

Caution: AI agents are not perfect and can occasionally make errors. Always review shell commands generated by Claude Code before executing them.

Recommendation