教程

零基础终端入门:macOS/Linux/Windows 三平台安装 Claude Code 的逐步指南

零基础终端入门指南:macOS 四步(Command+空格打开终端/安装脚本/重启/claude 启动)、Linux 四步(Ctrl+Alt+T/安装/source/.bashrc/启动)、Windows 五步(安装 Git for Windows/打开 PowerShell/irm 安装脚本/重启/启动)、SSL/TLS 错误修复、安装后三个入门示例(网页/文件整理/规划咨询)、五大常见安装问题(command not found/HTML 错误/irm not recognized/Git Bash 缺失/claude not recognized),以及无需终端的替代方案(桌面应用/VS Code 插件/网页版)。

2026/3/84分钟 阅读ClaudeEagle

从未用过终端?没关系。本文手把手带你打开终端、安装 Claude Code,完成第一次对话——全程不需要任何编程知识。

macOS 安装步骤

第一步:打开终端

方法一:按 Command + 空格,搜索「Terminal」,回车打开

方法二:打开「应用程序」→「实用工具」→「终端」

第二步:安装 Claude Code

在终端窗口中,复制粘贴以下命令,按回车执行:

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

等待安装完成(约 1-2 分钟)。

第三步:关闭并重新打开终端

安装后需要重启终端让配置生效。关闭终端窗口,重新打开一个新的终端。

第四步:启动 Claude Code

bash
claude

首次启动会打开浏览器要求登录,用你的 claude.ai 账号登录即可。


Linux 安装步骤(Ubuntu/Debian)

第一步:打开终端

  • Ubuntu:按 Ctrl + Alt + T
  • 其他发行版:在应用程序菜单中搜索「Terminal」或「终端」

第二步:安装 Claude Code

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

第三步:重载 Shell 配置

bash
source ~/.bashrc
# 或关闭终端重新打开

第四步:启动

bash
claude

Windows 安装步骤

第一步:安装 Git for Windows

前往 git-scm.com/downloads/win 下载安装 Git for Windows。

安装时保持默认选项,一路「Next」即可。

第二步:打开 PowerShell

Win + X,点击「Windows PowerShell」(或「终端」)。

不要用「命令提示符(CMD)」,需要用 PowerShell。

第三步:安装 Claude Code

powershell
irm https://claude.ai/install.ps1 | iex

如果出现 SSL/TLS 错误,先运行这行再重试:

powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
irm https://claude.ai/install.ps1 | iex

第四步:重启 PowerShell

关闭 PowerShell 窗口,重新打开。

第五步:启动 Claude Code

powershell
claude

安装成功后能做什么?

看到 Claude Code 欢迎界面后,你不需要会写代码。用中文描述你想做的事就行。

创建一个简单网页

帮我创建一个显示「Hello World」的简单网页

Claude 会帮你创建文件,双击生成的 HTML 文件即可在浏览器中查看。

整理文件

看一下我桌面上的截图,根据图片内容重命名它们

学习和规划

我想做一个个人预算记录工具,需要哪些步骤?

常见安装问题

macOS/Linux:command not found

关闭终端重新打开,再次运行 claude

如果还是不行:

bash
# Zsh(macOS 默认)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# Bash(Linux 默认)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

macOS/Linux:出现 HTML 代码或 syntax error

安装脚本下载到了 HTML 页面。改用 Homebrew:

bash
brew install --cask claude-code

Windows:irm is not recognized

你在 CMD 里,需要用 PowerShell。关闭 CMD,改用 Win + X 打开 PowerShell。

Windows:Claude Code on Windows requires git-bash

Git for Windows 未安装,回到第一步重新安装。如果已安装但仍报错:

powershell
$env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git\bin\bash.exe"

然后再运行 claude

Windows:claude is not recognized

重启电脑后再试。如果仍不行:

powershell
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')

关闭 PowerShell,重新打开后再试。


其他使用 Claude Code 的方式

如果不想用终端,Claude Code 还提供:

  • 桌面应用:图形界面,无需终端
  • VS Code / JetBrains 插件:在编辑器中直接使用
  • 网页版:在 claude.ai/code 使用,无需安装
  • GitHub Actions / GitLab CI/CD:自动化流水线集成

原文:Terminal guide - Claude Code Docs | 来源:Anthropic 官方文档

相关文章推荐

教程Claude Code 新手入门完整教程:安装、登录、第一个任务全流程(2026 最新)Claude Code 新手入门完整教程:从安装到第一个任务全流程,涵盖 macOS/Windows/Linux 安装、常见报错处理、核心命令速查和 5 个高频使用场景。2026/4/9教程Claude Code Remote Control 使用指南:手机和浏览器远程继续本地会话Claude Code Remote Control 让你在手机、平板或浏览器中继续本地 Claude Code 会话。代码仍在本机执行,web/mobile 只是连接窗口,可访问本地文件、MCP servers 和项目配置。2026/6/8教程Claude Code Routines 指南:定时、API 和 GitHub 事件触发的云端自动化Claude Code Routines 让 Claude Code 在 Anthropic 管理的云端基础设施上自动运行:可按计划执行、由 HTTP API 触发,或响应 GitHub PR/release 等事件。2026/6/8教程Claude Code Agent Teams 使用指南:多 Claude 会话协作、共享任务列表和直接通信Claude Code Agent Teams 适合需要多个 Claude Code 会话并行探索、互相挑战和协调的复杂任务。它不同于 subagents:teammates 有独立上下文、共享任务列表,并能直接通信。2026/6/8教程Claude Code Dynamic Workflows 完整指南:用脚本编排上百个 SubagentsClaude Code Dynamic Workflows 让编排逻辑从上下文窗口迁移到 JavaScript 脚本,适合代码库审计、500 文件迁移、多源交叉验证研究和可重复质量检查。2026/6/8教程OpenClaw ACP Agents 完整指南:把 Codex、Claude Code、Gemini 接入聊天线程OpenClaw ACP Agents 官方文档中文整理:什么是 ACP runtime、如何把 Codex/Claude Code/Gemini CLI 绑定到聊天、current conversation bind、thread-bound session、持久会话、运行时配置和适用场景。2026/6/4