Skip to content
Search RunEntLinux

Searches general documentation on RunEntLinux. Each distribution has its own documentation search.

    Browse this documentation

    Claude Code is the official command-line programming tool from Anthropic, powered by the Claude large language model. It works directly in your terminal to help you write code, analyze projects, and perform system administration tasks. It can understand the context of an entire codebase and directly read/write files and run commands, making it a powerful assistant for server-side development and operations.

    • CentOS Stream 9 & 10 / AlmaLinux 9 & 10 / Rocky Linux 9 & 10
    • Node.js 22 or higher; the current LTS is Node.js 24 (Node.js 20 reached EOL in 2026-04)
    • Anthropic API key (obtain from console.anthropic.com)
    • Network access to the Anthropic API

    The Node.js version in the default EL repositories may be outdated (EL 9.8 / EL 10 currently ship Node.js 24 / 22 respectively). It is recommended to install the latest LTS version via the NodeSource repository.

    Section titled “Option 1: NodeSource Repository (Recommended)”
    Terminal window
    # Install Node.js 24.x LTS
    curl -fsSL https://rpm.nodesource.com/setup_24.x | sudo bash -
    sudo dnf install -y nodejs
    Terminal window
    # List available Node.js versions
    sudo dnf module list nodejs
    # Enable and install Node.js 24
    sudo dnf module enable nodejs:24 -y
    sudo dnf install -y nodejs

    Verify the installation:

    Terminal window
    node --version
    npm --version

    Install globally using npm:

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

    Verify the installation:

    Terminal window
    claude --version
    Terminal window
    npm install -g @anthropic-ai/claude-code@latest

    Running claude for the first time will guide you through authentication. You can also set it in advance via an environment variable:

    Terminal window
    # Temporary setting
    export ANTHROPIC_API_KEY="sk-ant-xxxxx"
    # Permanent setting (add to shell configuration file)
    echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxx"' >> ~/.bashrc
    source ~/.bashrc

    If you access the API through a proxy service, you can customize the API URL:

    Terminal window
    export ANTHROPIC_BASE_URL="https://your-proxy.example.com"
    export ANTHROPIC_API_KEY="your-key"

    Claude Code’s configuration files are located in the ~/.claude/ directory. You can adjust settings through the interactive /config command or edit the configuration files directly:

    Terminal window
    ls -la ~/.claude/

    Run directly in your project directory:

    Terminal window
    cd /path/to/your/project
    claude

    Once in the interactive interface, you can describe your needs in natural language.

    Use the -p flag for a one-off question, suitable for scripting:

    Terminal window
    # Single question
    claude -p "Explain the directory structure of this project"
    # Analyze a specific file
    claude -p "Analyze the configuration of /etc/nginx/nginx.conf. Are there any security concerns?"
    Terminal window
    # Analyze logs
    journalctl -u nginx --since "1 hour ago" | claude -p "Analyze these logs. Are there any anomalies?"
    # Review code
    cat app.py | claude -p "Review the security of this code"
    # Analyze system state
    top -bn1 | claude -p "Analyze the system load"

    In interactive mode, commands starting with / are built-in commands:

    CommandDescription
    /helpShow help information
    /configModify configuration
    /clearClear conversation context
    /compactCompress conversation history to save tokens
    /costView API usage for the current session
    You: Check the current disk usage and find the directories using the most space
    You: Write a bash script that periodically cleans up log files older than 30 days in /var/log
    You: Create a Python Flask API with /health and /status endpoints
    You: Read the current project code and write deployment steps for Rocky Linux
    You: Generate an Nginx reverse proxy configuration that forwards /api requests to backend port 8080 with SSL enabled
    You: Check the security configuration of /etc/ssh/sshd_config and provide hardening recommendations

    Claude Code supports MCP (Model Context Protocol) servers, which can extend its capabilities. MCP servers provide Claude Code with additional tools and data sources.

    Create a .mcp.json file in the project root directory:

    {
    "mcpServers": {
    "filesystem": {
    "command": "npx",
    "args": [
    "-y",
    "@modelcontextprotocol/server-filesystem",
    "/opt/data"
    ]
    },
    "postgres": {
    "command": "npx",
    "args": [
    "-y",
    "@modelcontextprotocol/server-postgres",
    "postgresql://user:pass@localhost:5432/mydb"
    ]
    }
    }
    }

    You can also create a global MCP configuration in the ~/.claude/ directory.

    Add them via Claude Code interactive commands:

    Terminal window
    # Add filesystem MCP
    claude mcp add filesystem npx -y @modelcontextprotocol/server-filesystem /opt/data
    # Add PostgreSQL MCP
    claude mcp add postgres npx -y @modelcontextprotocol/server-postgres "postgresql://user:pass@localhost/db"
    # List configured MCP servers
    claude mcp list

    On a server, it is recommended to run Claude Code inside tmux to prevent session loss from SSH disconnections:

    Terminal window
    # Create a new tmux session
    tmux new -s claude
    # Run claude inside tmux
    claude
    # To detach, press Ctrl+B then D
    # To reattach
    tmux attach -t claude

    If Claude Code needs to operate on files protected by SELinux:

    Terminal window
    # View the SELinux context of files
    ls -Z /var/www/html/
    # If files created by Claude Code have incorrect context, restore them
    sudo restorecon -Rv /var/www/html/

    When using on production servers, it is recommended to run Claude Code as a regular user instead of root:

    Terminal window
    # Create a dedicated user
    sudo useradd -m claude-user
    sudo su - claude-user
    # Install and run
    npm install -g @anthropic-ai/claude-code
    export ANTHROPIC_API_KEY="sk-ant-xxxxx"
    claude

    Offline or Restricted Network Environments

    Section titled “Offline or Restricted Network Environments”

    If the server accesses the internet through a proxy:

    Terminal window
    # Set HTTPS proxy
    export HTTPS_PROXY="http://proxy.example.com:7890"
    export ANTHROPIC_API_KEY="sk-ant-xxxxx"
    claude

    If you encounter permission errors:

    Terminal window
    # Option 1: Change the npm global directory
    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
    # Option 2: Use sudo (not recommended)
    sudo npm install -g @anthropic-ai/claude-code
    Terminal window
    # Check version
    node --version
    # If below 22, upgrade Node.js following the instructions above

    Check network connectivity and proxy settings:

    Terminal window
    # Test API connectivity (replace model with a currently available model ID; see Anthropic docs)
    curl -v https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "content-type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -d '{"model":"claude-sonnet-4-5","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'