Claude Code
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.
System Requirements
Section titled “System Requirements”- 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
Installing Node.js
Section titled “Installing Node.js”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.
Option 1: NodeSource Repository (Recommended)
Section titled “Option 1: NodeSource Repository (Recommended)”# Install Node.js 24.x LTScurl -fsSL https://rpm.nodesource.com/setup_24.x | sudo bash -sudo dnf install -y nodejsOption 2: dnf module (EL 9 only)
Section titled “Option 2: dnf module (EL 9 only)”# List available Node.js versionssudo dnf module list nodejs
# Enable and install Node.js 24sudo dnf module enable nodejs:24 -ysudo dnf install -y nodejsVerify the installation:
node --versionnpm --versionInstalling Claude Code
Section titled “Installing Claude Code”Install globally using npm:
npm install -g @anthropic-ai/claude-codeVerify the installation:
claude --versionUpdating Claude Code
Section titled “Updating Claude Code”npm update -g @anthropic-ai/claude-codeConfiguration
Section titled “Configuration”Setting the API Key
Section titled “Setting the API Key”Running claude for the first time will guide you through authentication. You can also set it in advance via an environment variable:
# Temporary settingexport ANTHROPIC_API_KEY="sk-ant-xxxxx"
# Permanent setting (add to shell configuration file)echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxx"' >> ~/.bashrcsource ~/.bashrcUsing a Third-Party API Proxy
Section titled “Using a Third-Party API Proxy”If you access the API through a proxy service, you can customize the API URL:
export ANTHROPIC_BASE_URL="https://your-proxy.example.com"export ANTHROPIC_API_KEY="your-key"Configuration Files
Section titled “Configuration Files”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:
ls -la ~/.claude/Basic Usage
Section titled “Basic Usage”Starting an Interactive Session
Section titled “Starting an Interactive Session”Run directly in your project directory:
cd /path/to/your/projectclaudeOnce in the interactive interface, you can describe your needs in natural language.
Single Command Mode
Section titled “Single Command Mode”Use the -p flag for a one-off question, suitable for scripting:
# Single questionclaude -p "Explain the directory structure of this project"
# Analyze a specific fileclaude -p "Analyze the configuration of /etc/nginx/nginx.conf. Are there any security concerns?"Piping Input
Section titled “Piping Input”# Analyze logsjournalctl -u nginx --since "1 hour ago" | claude -p "Analyze these logs. Are there any anomalies?"
# Review codecat app.py | claude -p "Review the security of this code"
# Analyze system statetop -bn1 | claude -p "Analyze the system load"Common Interactive Commands
Section titled “Common Interactive Commands”In interactive mode, commands starting with / are built-in commands:
| Command | Description |
|---|---|
/help | Show help information |
/config | Modify configuration |
/clear | Clear conversation context |
/compact | Compress conversation history to save tokens |
/cost | View API usage for the current session |
Practical Use Cases
Section titled “Practical Use Cases”Server Operations
Section titled “Server Operations”You: Check the current disk usage and find the directories using the most spaceYou: Write a bash script that periodically cleans up log files older than 30 days in /var/logCode Development
Section titled “Code Development”You: Create a Python Flask API with /health and /status endpointsYou: Read the current project code and write deployment steps for Rocky LinuxConfiguration File Management
Section titled “Configuration File Management”You: Generate an Nginx reverse proxy configuration that forwards /api requests to backend port 8080 with SSL enabledYou: Check the security configuration of /etc/ssh/sshd_config and provide hardening recommendationsMCP Servers
Section titled “MCP Servers”Claude Code supports MCP (Model Context Protocol) servers, which can extend its capabilities. MCP servers provide Claude Code with additional tools and data sources.
Configuring MCP Servers
Section titled “Configuring MCP Servers”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.
Common MCP Servers
Section titled “Common MCP Servers”Add them via Claude Code interactive commands:
# Add filesystem MCPclaude mcp add filesystem npx -y @modelcontextprotocol/server-filesystem /opt/data
# Add PostgreSQL MCPclaude mcp add postgres npx -y @modelcontextprotocol/server-postgres "postgresql://user:pass@localhost/db"
# List configured MCP serversclaude mcp listTips for Using on EL Servers
Section titled “Tips for Using on EL Servers”Using with tmux
Section titled “Using with tmux”On a server, it is recommended to run Claude Code inside tmux to prevent session loss from SSH disconnections:
# Create a new tmux sessiontmux new -s claude
# Run claude inside tmuxclaude
# To detach, press Ctrl+B then D# To reattachtmux attach -t claudeSetting SELinux Context
Section titled “Setting SELinux Context”If Claude Code needs to operate on files protected by SELinux:
# View the SELinux context of filesls -Z /var/www/html/
# If files created by Claude Code have incorrect context, restore themsudo restorecon -Rv /var/www/html/Limiting Privileges
Section titled “Limiting Privileges”When using on production servers, it is recommended to run Claude Code as a regular user instead of root:
# Create a dedicated usersudo useradd -m claude-usersudo su - claude-user
# Install and runnpm install -g @anthropic-ai/claude-codeexport ANTHROPIC_API_KEY="sk-ant-xxxxx"claudeOffline or Restricted Network Environments
Section titled “Offline or Restricted Network Environments”If the server accesses the internet through a proxy:
# Set HTTPS proxyexport HTTPS_PROXY="http://proxy.example.com:7890"export ANTHROPIC_API_KEY="sk-ant-xxxxx"claudenpm Global Install Permission Issues
Section titled “npm Global Install Permission Issues”If you encounter permission errors:
# Option 1: Change the npm global directorymkdir -p ~/.npm-globalnpm config set prefix '~/.npm-global'echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrcnpm install -g @anthropic-ai/claude-code
# Option 2: Use sudo (not recommended)sudo npm install -g @anthropic-ai/claude-codeNode.js Version Too Old
Section titled “Node.js Version Too Old”# Check versionnode --version
# If below 22, upgrade Node.js following the instructions aboveConnection Timeout
Section titled “Connection Timeout”Check network connectivity and proxy settings:
# 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"}]}'