{"id":167458,"date":"2026-05-09T11:19:49","date_gmt":"2026-05-09T08:19:49","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=167458"},"modified":"2026-05-09T11:20:39","modified_gmt":"2026-05-09T08:20:39","slug":"install-claude-code-ubuntu-2604","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-claude-code-ubuntu-2604\/","title":{"rendered":"Install Claude Code CLI on Ubuntu 26.04 LTS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Claude Code is Anthropic&#8217;s CLI for its Claude models, from Opus 4.8 up to the Mythos-class <a href=\"https:\/\/computingforgeeks.com\/claude-fable-5-released-features-benchmarks\/\">Claude Fable 5<\/a>, the same family that powers Claude.ai, but with full repository awareness, hooks, sub-agents, and MCP server support that the chat interface does not give you. On Ubuntu 26.04 LTS the install is one apt step plus one npm step. Everything else is auth, config, and the small handful of conventions that turn the CLI into a real engineering tool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide walks the install on a fresh 26.04 server, runs through the OAuth and API-key auth paths, registers Claude Code&#8217;s settings file, and connects an MCP server so the CLI can pull live data from your stack. Tested with Claude Code 2.1.138 on Node.js 24, the current LTS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Tested May 2026 on Ubuntu 26.04 (Resolute Raccoon) server, kernel 7.0.0-15-generic, Node.js 24.15.0, npm 11.12.1, Claude Code 2.1.138<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu 26.04 LTS server or workstation with sudo access<\/li>\n\n<li>An Anthropic account (free signup at <a href=\"https:\/\/console.anthropic.com\" target=\"_blank\" rel=\"noreferrer noopener\">console.anthropic.com<\/a>) for either OAuth login or an API key<\/li>\n\n<li>Outbound HTTPS to <code>api.anthropic.com<\/code> and <code>claude.ai<\/code><\/li>\n\n<li>Optional: an existing project directory you want Claude to work against<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install Node.js 24 from NodeSource<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Claude Code is a Node CLI and needs Node 18 or newer. Ubuntu 26.04&#8217;s default <code>nodejs<\/code> apt package is fine, but the NodeSource <code>setup_24.x<\/code> script gives you the current LTS line which Anthropic tests against:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>curl -fsSL https:\/\/deb.nodesource.com\/setup_24.x | sudo bash -\nsudo apt install -y nodejs\nnode --version\nnpm --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see <code>v24.15.0<\/code> or newer for Node and <code>11.x<\/code> for npm. The NodeSource installer added an apt source under <code>\/etc\/apt\/sources.list.d\/nodesource.list<\/code> so future <code>apt upgrade<\/code> runs pick up Node 24 patch releases.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Claude Code globally<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Anthropic publishes the CLI as <code>@anthropic-ai\/claude-code<\/code> on the public npm registry. A global install puts the <code>claude<\/code> binary on your PATH:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>sudo npm install -g @anthropic-ai\/claude-code\nwhich claude\nclaude --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The version stamp confirms a working install:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>2.1.138 (Claude Code)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The captured terminal below shows the full chain end to end on a fresh 26.04 box, from the NodeSource bootstrap through the version stamp:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"920\" height=\"720\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2026\/05\/wm-install-claude-code-ubuntu-2604-cli.png\" alt=\"Install Claude Code CLI on Ubuntu 26.04 via npm\" class=\"wp-image-167452\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2026\/05\/wm-install-claude-code-ubuntu-2604-cli.png 920w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2026\/05\/wm-install-claude-code-ubuntu-2604-cli-300x235.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2026\/05\/wm-install-claude-code-ubuntu-2604-cli-768x601.png 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The screenshot above captures the full chain on a fresh 26.04 box: NodeSource bootstrap, apt install, npm global install, and the <code>claude --version<\/code> probe. From this point forward the CLI is callable as <code>claude<\/code> from any directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Pick an auth path<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Claude Code accepts four auth backends. Pick the one that matches your billing arrangement:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Backend<\/th><th>Best for<\/th><th>Setup<\/th><\/tr><\/thead><tbody><tr><td><strong>Anthropic account (OAuth)<\/strong><\/td><td>Pro \/ Max \/ Team subscribers, individuals<\/td><td>Browser flow on first <code>claude<\/code> launch<\/td><\/tr><tr><td><strong>API key<\/strong><\/td><td>Console.anthropic.com pay-per-token, CI runners<\/td><td><code>ANTHROPIC_API_KEY<\/code> env var<\/td><\/tr><tr><td><strong>Amazon Bedrock<\/strong><\/td><td>AWS-hosted Claude billing<\/td><td><code>CLAUDE_CODE_USE_BEDROCK=1<\/code> + AWS creds<\/td><\/tr><tr><td><strong>Google Vertex AI<\/strong><\/td><td>GCP-hosted Claude billing<\/td><td><code>CLAUDE_CODE_USE_VERTEX=1<\/code> + ADC<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Path A: OAuth login (Anthropic account)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the CLI in any directory. The first launch opens an interactive setup that asks for an auth backend; pick option 1 (Anthropic account). The CLI prints a URL plus a one-time code:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>claude<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Open the URL in any browser, sign in to your Anthropic account, paste the code into the CLI when it prompts, and the CLI writes a refresh token to <code>~\/.claude\/credentials.json<\/code>. From the next launch onwards there is no prompt; the CLI uses the stored refresh token automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Path B: API key (best for servers)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For headless servers, CI runners, and anything that should not pop a browser, generate an API key at <a href=\"https:\/\/console.anthropic.com\/settings\/keys\" target=\"_blank\" rel=\"noreferrer noopener\">console.anthropic.com\/settings\/keys<\/a> and export it:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>echo 'export ANTHROPIC_API_KEY=\"your-anthropic-api-key-here\"' &gt;&gt; ~\/.bashrc\nsource ~\/.bashrc\nclaude --print \"say hello in one sentence\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>--print<\/code> flag (alias <code>-p<\/code>) runs the CLI non-interactively and dumps the model&#8217;s reply to stdout. Useful for confirming auth works and as the building block for shell scripting Claude into pipelines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: First interactive session<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The interactive REPL is where Claude Code is most useful. Open it inside a project directory:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>cd ~\/projects\/my-app\nclaude<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The CLI prints the Claude Code prompt, reads any <code>CLAUDE.md<\/code> in the current directory or its parents, and waits for instructions. A first useful turn:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>&gt; What does this repo do? Walk me through the main entry points.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Claude reads your README, package.json (or pyproject.toml, Cargo.toml, etc.), and the file tree, then answers in your terminal. From here you can ask it to write features, fix bugs, run commands, and edit files. Every change goes through a permission prompt the first time you use a new tool category.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Type <code>\/help<\/code> at the prompt to see the slash commands (skills, plugins, sessions). Type <code>\/model<\/code> to swap between Opus 4.7 (default for hardest reasoning) and Sonnet 4.6 (faster, cheaper). Press <code>Ctrl+C<\/code> twice to exit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: settings.json and CLAUDE.md<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Two files turn Claude Code from a chat UI into a configurable agent. <code>~\/.claude\/settings.json<\/code> holds global preferences (default model, hooks, MCP servers). <code>CLAUDE.md<\/code> holds project-specific instructions and lives at any level of your repo:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>mkdir -p ~\/.claude\ncat &gt; ~\/.claude\/settings.json &lt;&lt;'EOF'\n{\n  \"model\": \"claude-opus-4-7\",\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(git:*)\",\n      \"Bash(npm:*)\",\n      \"Bash(pytest:*)\",\n      \"Read\",\n      \"Edit\",\n      \"Write\"\n    ],\n    \"deny\": [\n      \"Bash(rm -rf:*)\"\n    ]\n  }\n}\nEOF\nchmod 600 ~\/.claude\/settings.json<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The permissions block is the safety net. <code>allow<\/code> lists tool patterns that skip the permission prompt; <code>deny<\/code> lists patterns the agent will refuse even if you approve them at runtime. Lock the file at mode 600 because it can hold tokens for hooks and MCP servers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Drop a CLAUDE.md at the root of any project to give Claude project-specific instructions:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>cat &gt; CLAUDE.md &lt;&lt;'EOF'\n# Project context\n\nStack: FastAPI + Postgres + Redis behind Caddy.\nRun tests with `pytest -x`. Lint with `ruff check .`.\nKeep changes under 200 lines per PR. Prefer dataclasses over dicts.\nEOF<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Claude reads this file on session start, follows the conventions, and keeps the rules in context across multi-turn work. The companion <a href=\"https:\/\/computingforgeeks.com\/claude-code-cheat-sheet\/\">Claude Code cheat sheet<\/a> covers the full slash-command and flag surface, and the <a href=\"https:\/\/computingforgeeks.com\/claude-code-routines-setup\/\">routines guide<\/a> explains how to wire scheduled agent runs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Add an MCP server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MCP (Model Context Protocol) servers let Claude pull live data from your stack: read a database, hit an API, browse a Notion workspace. Anthropic and the community ship dozens; the install pattern is the same for all of them. The <a href=\"https:\/\/github.com\/modelcontextprotocol\/servers\" target=\"_blank\" rel=\"noreferrer noopener\">filesystem MCP server<\/a> is the simplest example. Wire it via <code>claude mcp add<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>claude mcp add filesystem \\\n  --command \"npx\" \\\n  --args \"-y,@modelcontextprotocol\/server-filesystem,$HOME\/projects\"\nclaude mcp list<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The next interactive session knows how to read and search any file under <code>~\/projects<\/code> through the MCP filesystem tool. To remove it later: <code>claude mcp remove filesystem<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a real production wire-up, swap the filesystem example for the Postgres MCP, GitHub MCP, or your own. The <a href=\"https:\/\/computingforgeeks.com\/claude-code-github-actions-infrastructure\/\">Claude Code in GitHub Actions guide<\/a> shows the same pattern in CI; the <a href=\"https:\/\/computingforgeeks.com\/claude-code-kubernetes-guide\/\">Kubernetes integration<\/a> wires Claude into <code>kubectl<\/code> on a cluster.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Useful command flags<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The CLI surface is large. The flags worth knowing on day one:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Flag<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td><code>-p, --print<\/code><\/td><td>Non-interactive: print Claude&#8217;s reply and exit<\/td><\/tr><tr><td><code>-c, --continue<\/code><\/td><td>Resume the most recent conversation in this directory<\/td><\/tr><tr><td><code>--add-dir DIR<\/code><\/td><td>Allow tool access to additional directories<\/td><\/tr><tr><td><code>--model claude-sonnet-4-6<\/code><\/td><td>Override the default model for this session<\/td><\/tr><tr><td><code>--dangerously-skip-permissions<\/code><\/td><td>Skip every permission prompt; sandbox-only<\/td><\/tr><tr><td><code>--mcp-config PATH<\/code><\/td><td>Load an extra MCP server config<\/td><\/tr><tr><td><code>-d, --debug api,hooks<\/code><\/td><td>Verbose debug to stderr, filter by category<\/td><\/tr><tr><td><code>--bare<\/code><\/td><td>Skip auto-memory, hooks, plugins (CI-friendly)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Combine them. A nightly cron that asks Claude to scan a repo and open a PR:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>cd ~\/projects\/site &amp;&amp; \\\n  claude --bare --model claude-sonnet-4-6 \\\n         --print \"review the diff in the last 7 days and write a CHANGELOG entry\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and what they mean<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Error: <code>EACCES: permission denied, mkdir '\/usr\/lib\/node_modules\/...'<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You ran <code>npm install -g<\/code> without sudo. The fix is either to use sudo (the route this guide takes) or to set up an unprivileged npm prefix:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>mkdir -p ~\/.npm-global\nnpm config set prefix ~\/.npm-global\necho 'export PATH=~\/.npm-global\/bin:$PATH' &gt;&gt; ~\/.bashrc\nsource ~\/.bashrc\nnpm install -g @anthropic-ai\/claude-code<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Error: <code>Authentication failed: invalid_grant<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The OAuth refresh token expired or got rotated. Force a fresh login: <code>claude \/logout<\/code> from the REPL, then <code>claude<\/code> to redo the OAuth flow. If you are on the API-key path, double-check <code>echo $ANTHROPIC_API_KEY | head -c 20<\/code> matches the prefix in the console.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Error: <code>MCP server failed to start<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The npx command in the MCP definition could not resolve the package. Run the same npx invocation in your shell to see the underlying error; usually a missing Node version or a typo in the args list. Re-add with <code>claude mcp remove NAME<\/code> followed by <code>claude mcp add<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Error: <code>Tool 'Bash' is not allowed<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The settings.json permissions block did not include the command pattern Claude is trying to run. Add a more specific pattern (such as <code>Bash(git status:*)<\/code>) or a broader one (<code>Bash(git:*)<\/code>) and reload by exiting and re-entering the REPL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update and uninstall<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Update to the current release with the same npm command:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>sudo npm install -g @anthropic-ai\/claude-code@latest\nclaude --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pin a specific build instead of latest by appending <code>@2.1.138<\/code> (or whichever release you tested against). Clean uninstall:<\/p>\n\n\n\n<pre class=\"wp-block-code code\"><code>sudo npm uninstall -g @anthropic-ai\/claude-code\nrm -rf ~\/.claude\nunset ANTHROPIC_API_KEY<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Node 24 install stays in place and can be removed separately with <code>sudo apt remove --purge nodejs<\/code> if you no longer need it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a deeper look at the Claude family of models, the <a href=\"https:\/\/computingforgeeks.com\/claude-opus-4-7-released-features-benchmarks\/\">Claude Opus 4.7 release notes<\/a> cover the model behind the default. The <a href=\"https:\/\/computingforgeeks.com\/reduce-claude-code-token-usage-tools\/\">token-reduction guide<\/a> shows the patterns that cut your monthly Claude bill in half. Pair this install with the <a href=\"https:\/\/computingforgeeks.com\/install-nodejs-ubuntu-2604\/\">Node.js install reference<\/a> for runtime details and the <a href=\"https:\/\/computingforgeeks.com\/install-ansible-ubuntu-2604\/\">Ansible install<\/a> if you plan to wrap Claude Code around configuration management.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That is the full path: Node 24 in place, Claude Code 2.1.138 globally installed, OAuth or API-key auth wired, settings.json with sane permissions, project-specific CLAUDE.md, and an MCP server attached. From here, every Claude session knows about your stack, your conventions, and the data sources you have chosen to expose.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Claude Code CLI on Ubuntu 26.04 with Node.js 24, OAuth or API-key auth, settings.json permissions, CLAUDE.md, and MCP servers.<\/p>\n","protected":false},"author":7,"featured_media":167455,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50,81],"tags":[282,2254],"cfg_series":[39800],"class_list":["post-167458","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-tutorials","category-ubuntu","tag-linux","tag-ubuntu","cfg_series-ubuntu-2604-devops-tools"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/167458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=167458"}],"version-history":[{"count":2,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/167458\/revisions"}],"predecessor-version":[{"id":167465,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/167458\/revisions\/167465"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/167455"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=167458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=167458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=167458"},{"taxonomy":"cfg_series","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/cfg_series?post=167458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}