14  14. Getting Bash on Your Computer (Mac and Windows)

To follow the rest of this book you need a command line that speaks Bash. A Mac has one built in. On Windows you install Git for Windows, which includes Git Bash. This page gets you set up and has you run your first commands. Pick your operating system in the tabs below; the book remembers your choice.

14.1 Set up your command line

Every Mac comes with the Terminal app - there is nothing to install.

  1. Press Cmd+Space to open Spotlight, type Terminal, and press Enter. (Or, in Finder, open Applications > Utilities and double-click Terminal.)

  2. A window opens with a prompt such as:

    maria@MacBook-Air ~ %

The % tells you the shell is zsh, the Mac’s default since macOS 10.15 Catalina. For the commands in this book, zsh and Bash work the same way, so you can stay in zsh (see the deeper dive below for the few differences). If your prompt ends in $ instead, your account is set up to use Bash - also fine.

To try real Bash, type bash and press Enter. macOS first prints this notice:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

Then the prompt changes to bash-3.2$ (the program’s name and version); the $ shows that you are in Bash. The Mac’s built-in Bash is an old version, 3.2, which is fine for this book. Type exit to go back to zsh.

Git itself is set up later, in Installing and Configuring Git.

Windows doesn’t include Bash, so you install Git for Windows. It contains Git (the version-control tool you will use from What Is Version Control? on) and Git Bash, a Bash command line for Windows.

  1. Go to git-scm.com/install/windows and click the link that downloads the latest x64 version. (On a Windows-on-ARM laptop, for example one with a Snapdragon processor, choose Git for Windows/ARM64 Setup instead.)

  2. Run the downloaded installer (Git-...-64-bit.exe). If Windows asks whether to allow the app to make changes, click Yes.

  3. Click Next on each screen to accept the defaults, except on these three screens:

    Screen What to choose
    Select Components Also check Add a Git Bash Profile to Windows Terminal.
    Choosing the default editor used by Git The default, Vim, is hard for beginners. Choose Use Visual Studio Code as Git’s default editor if VS Code is already installed; otherwise choose Use the Nano editor by default.
    Adjusting the name of the initial branch in new repositories Choose Override the default branch name for new repositories and keep main in the box.

    On the screen Adjusting your PATH environment, keep the option marked (Recommended): “Git from the command line and also from 3rd-party software”.

  4. On the last options screen the button says Install. When installation finishes, check Launch Git Bash and click Finish.

Opening Git Bash later:

  • Start menu: type Git Bash and press Enter. It opens in your home folder.
  • From a folder in File Explorer: right-click the folder (or empty space inside it) and choose Open Git Bash here, which opens Git Bash in that folder. On Windows 11, click Show more options first (or press Shift+F10).
  • In Windows Terminal: click the ⌄ arrow next to the tabs and choose Git Bash. To make Git Bash the default, go to Settings > Startup > Default profile.

The Git Bash prompt takes two lines:

sam@DESKTOP-4F7Q2K1 UCRT64 ~
$

Older versions of Git show MINGW64 instead of UCRT64, and on laptops with an ARM processor (such as some Surface and Snapdragon laptops) you may see CLANGARM64. It makes no difference for this book.

14.2 Your first commands

Type each of these commands and press Enter after each one:

echo hello
whoami
pwd
date

Output:

hello
maria
/Users/maria
Tue Oct  6 10:42:17 EDT 2026
hello
sam
/c/Users/sam

followed by the current date and time (its format may differ slightly from the Mac’s).

  • echo prints whatever you give it (more in Writing to Files).
  • whoami prints your user name.
  • pwd prints the folder you are in - right now, your home folder (see Files, Folders, and Paths).
  • date prints the current date and time.

If you see an error such as command not found, check the spelling and the spaces, and make sure you are in the right program (see the next sections).

14.3 Copy, paste, and closing the window

Copying commands from this book into the terminal saves typing, but the keys differ from what you are used to:

Mac Terminal Git Bash window Windows Terminal
Copy Cmd+C Just select the text with the mouse (it is copied automatically), or Ctrl+Insert Ctrl+C while text is selected
Paste Cmd+V Shift+Insert, or right-click and choose Paste Ctrl+V

In a terminal, Ctrl+C normally means “stop the running command”, not “copy”. In the Git Bash window, Ctrl+V doesn’t paste by default either. (You can turn on Ctrl+Shift+C and Ctrl+Shift+V under Options > Keys.)

To finish, type exit and press Enter: this ends the shell session. Git Bash then closes its window. On a Mac, quit the Terminal app with Terminal > Quit Terminal (Cmd+Q). If you started Bash inside zsh, exit takes you back to zsh.

14.4 The prompt, and making yours the same as everyone’s

The prompt is the text the shell prints when it’s ready for your next command, for example maria@Marias-MacBook-Air ~ %. You type after it. Everything before the % or $ is just information, and it differs from student to student because it depends on:

  • the shell program: Macs use zsh (its prompt ends in %), Git Bash and most Linux terminals use Bash (ending in $);
  • the computer: the user name and computer name are often shown;
  • settings: each shell’s start-up file can change the prompt.

Typical prompts, in a folder named task-app:

Computer Typical prompt
Mac (zsh) maria@Marias-MacBook-Air task-app % (only the folder’s own name)
Windows (Git Bash) sam@DESKTOP-4F7Q2K1 MINGW64 ~/projects/full-stack-demo-app/task-app and $ on the next line
Linux (Bash) alex@laptop:~/projects/full-stack-demo-app/task-app$

So don’t rely on the prompt to tell you where you are. To be sure, type pwd (“print working directory”): it always prints the full path of the folder you’re in. To be sure you’re in the right folder before a command, cd into it: that’s harmless if you’re already there.

Which shell am I running? Type echo $0 and press Enter. It prints -zsh or zsh for zsh, and bash or -bash for Bash (the - only means the shell was started as a “login shell”). It matters because zsh and Bash differ in a few details (see “zsh vs. Bash on a Mac” below), and because the two read different start-up files.

Optional: give yourself the course’s prompt. If you’d like your prompt to look the same as your classmates’ and your instructor’s, set it to just the folder you’re in, followed by $ and a space, for example ~/projects/full-stack-demo-app/task-app$ (~ is your home folder). Type the one command for your computer, once. It adds a line to your shell’s start-up file, which the shell reads every time it starts, so the prompt stays the same after you close the terminal or restart the computer:

echo "PROMPT='%~\$ '" >> ~/.zshrc

~/.zshrc is zsh’s start-up file. %~ means “the current folder”.

echo "PS1='\w\$ '" >> ~/.bashrc

~/.bashrc is Bash’s start-up file. \w means “the current folder”. The next time Git Bash starts, it may say it created ~/.bash_profile for you; that’s expected (it makes Git Bash read ~/.bashrc).

echo "PS1='\w\$ '" >> ~/.bashrc

~/.bashrc is Bash’s start-up file. \w means “the current folder”.

Then close the terminal and open a new one (VS Code’s terminal too: click the trash icon on the terminal panel and open a new one). The new prompt appears. >> adds the line to the end of the file without touching the rest (Writing to Files: echo, >, >>, and cat explains it). To undo, open the file in VS Code (code ~/.zshrc or code ~/.bashrc), delete the line that starts with PROMPT= or PS1=, and save.

14.5 Windows: make sure you are in Git Bash

Windows has two other built-in command lines, and Windows Terminal often opens one of them by default:

Program Prompt looks like Lists files with
PowerShell PS C:\Users\sam> Get-ChildItem (also accepts ls, but not Bash options such as ls -la)
CMD (Command Prompt) C:\Users\sam> dir
Git Bash sam@DESKTOP-4F7Q2K1 UCRT64 ~ and $ on the next line ls

The commands in this book are Bash commands, so type them in Git Bash. If a command from this book fails in a window whose prompt starts with PS or looks like C:\...>, you are in the wrong program. (Occasionally an installer has to be run in PowerShell; its instructions say so explicitly.)

14.6 Claude Code and Git for Windows

As of Oct 6, 2026 · Official docs: Advanced setup · Terminal guide for new users

Claude Code runs natively on Windows. Its documentation lists Git for Windows as optional but recommended: Git for Windows provides Git Bash, which Claude Code uses for its Bash tool (the tool Claude uses to run shell commands). Without Git for Windows, Claude Code runs shell commands through PowerShell instead. Because this book teaches Bash, install Git for Windows first. Installing Claude Code itself is covered in Installing Claude Code.

Claude Code’s own beginner terminal guide tells you to accept every default in the Git installer. That is enough for Claude Code; the three changes recommended above simply make Git friendlier to use.

14.7 WSL: a full Linux inside Windows (optional)

The Windows Subsystem for Linux (WSL) runs a real Linux system (Ubuntu by default) inside Windows, using a lightweight virtual machine. You install it by opening PowerShell as administrator, running wsl --install, and restarting the computer (Windows 10 version 2004 or later, or Windows 11). Inside WSL you can install any Linux software, but it is a separate world: your Windows C: drive appears as /mnt/c, and Linux has its own home folder.

WSL is popular with professional developers, and you may want to explore it later (Microsoft’s WSL install guide). This book uses Git Bash because it installs in minutes, works directly with your normal Windows folders, and also gives you Git.

For the commands in this book (cd, ls, pwd, mkdir, rm, echo, quotes, variables, export), zsh and Bash use the same syntax. A few differences can still surprise you in zsh:

  • Comments typed at the prompt. In Bash, everything after a # is a comment and is ignored. In zsh (by default) it is not: pasting ls -l # long list passes #, long and list to ls, which then complains that they don’t exist. Leave the comment out, or run setopt interactivecomments first.
  • Wildcards that match nothing. ls *.csv in a folder without CSV files gives zsh: no matches found: *.csv in zsh; Bash passes the pattern on to ls, which reports that the file doesn’t exist (see Wildcards and Pipes).
  • rm * asks first. zsh asks for confirmation before deleting every file in a folder with rm *; Bash doesn’t.
  • A few quoting and echo details. For example, echo "a\nb" prints two lines in zsh but a\nb in Bash, and zsh doesn’t split unquoted variables at spaces. If an example on the quoting pages behaves differently for you, type bash and try it again.
  • Settings files. zsh reads ~/.zshrc; Bash reads ~/.bashrc or ~/.bash_profile (see Environment Variables).

If you prefer, chsh -s /bin/bash makes Bash your default shell (chsh -s /bin/zsh switches back). It’s not necessary for this course.

  • Your home folder ~ is /c/Users/sam, which is C:\Users\sam (see Files, Folders, and Paths).
  • The C: drive is /c, the D: drive is /d, and so on.
  • In Git Bash, / on its own is not your C: drive: it is the folder where Git is installed (C:\Program Files\Git). To get to your files, use cd ~ or cd /c.
  • If OneDrive backs up your Desktop and Documents folders, those folders live inside your OneDrive folder (whose name starts with OneDrive). Run ls ~ to see where your Documents folder really is.

Practice Questions

Easy

Question 1 · Multiple choice

Which app does a Mac user open to use the command line?

  1. Finder
  2. Terminal
  3. Git Bash
  4. PowerShell

b. Terminal comes with every Mac. Finder is the Mac’s file browser (a GUI). Git Bash is the Windows program you install with Git for Windows, and PowerShell is a Windows shell.

Question 2 · Short answer

What is Git Bash, and how do Windows users get it?

Git Bash is a Bash command line for Windows. It is installed together with Git when you install Git for Windows (from git-scm.com/install/windows).

Question 3 · True or false

Mac users must install a Bash program before they can follow this book.

False. Every Mac has the Terminal app with zsh (the default) and Bash already installed. The commands in this book work the same in zsh.

Question 4 · Matching

Match each prompt with the program that shows it.

Prompt Program
1. maria@MacBook-Air ~ % A. PowerShell
2. PS C:\Users\sam> B. Git Bash
3. C:\Users\sam> C. zsh in Mac Terminal
4. sam@DESKTOP-4F7Q2K1 UCRT64 ~ (and $ on the next line) D. CMD (Command Prompt)

1 → C, 2 → A, 3 → D, 4 → B.

Question 5 · Short answer

Give two ways to open Git Bash on Windows after installing Git for Windows.

Any two of:

  • Search the Start menu for Git Bash.
  • Right-click a folder in File Explorer and choose Open Git Bash here (on Windows 11, click Show more options first).
  • In Windows Terminal, choose Git Bash from the ⌄ menu (if you added the Git Bash profile during installation).

Question 6 · Multiple choice

What does the command whoami print?

  1. Your computer’s name
  2. Your user name
  3. The current folder
  4. The shell you are using

b. For example maria or sam. The current folder is printed by pwd. The computer’s name is part of the prompt, but whoami doesn’t print it.

Medium

Question 7 · Scenario

Sam pastes ls -la into a window whose prompt is PS C:\Users\sam> and gets an error. What is wrong, and what should he do?

The PS shows that he is in PowerShell, not Bash. PowerShell has its own commands and doesn’t understand Bash options such as -la. He should open Git Bash (Start menu, or the ⌄ menu in Windows Terminal) and run the command there.

Question 8 · Short answer

When installing Git for Windows, which three screens does this book tell you to change, and what do you choose on each?

  1. Select Components: also check Add a Git Bash Profile to Windows Terminal.
  2. Choosing the default editor used by Git: choose Visual Studio Code (if installed) or Nano instead of the default, Vim.
  3. Adjusting the name of the initial branch in new repositories: choose Override the default branch name and keep main.

Everything else: accept the defaults (including the Recommended PATH option).

Question 9 · Predict the output

Sam (Windows user name sam) opens Git Bash from the Start menu and types whoami and then pwd. What does he see?

sam
/c/Users/sam

Git Bash opened from the Start menu starts in his home folder, C:\Users\sam, which Git Bash writes as /c/Users/sam.

Question 10 · Scenario

In the Git Bash window, Sam selects a command with the mouse and presses Ctrl+C to copy it, then Ctrl+V to paste it - and nothing is pasted. What should he do instead?

In the Git Bash window, selecting text already copies it, so no key is needed (or he can press Ctrl+Insert). To paste, he should press Shift+Insert or right-click and choose Paste. Ctrl+C means “stop the running command” in a terminal, and Ctrl+V doesn’t paste in this window unless he enables Ctrl+Shift+C / Ctrl+Shift+V under Options > Keys.

Question 11 · Short answer

Maria types bash in her Mac’s Terminal. What does she see, how can she tell that she is now in Bash, and how does she get back to zsh?

macOS prints a notice saying that the default interactive shell is now zsh. Then the prompt changes to bash-3.2$ - the $ at the end shows she is in Bash (zsh shows %). Typing exit takes her back to zsh.

Question 12 · True or false

According to the Claude Code documentation, Claude Code cannot run on Windows unless Git for Windows is installed.

False. Git for Windows is optional but recommended. With it, Claude Code uses Git Bash for its Bash tool; without it, Claude Code runs shell commands through PowerShell instead.

Question 13 · Short answer

What is WSL, and how do you install it?

WSL (Windows Subsystem for Linux) runs a real Linux system (Ubuntu by default) inside Windows, using a lightweight virtual machine. To install it, open PowerShell as administrator, run wsl --install, and restart the computer. This book uses Git Bash instead.

Question 14 · Scenario

Maria’s prompt is maria@Marias-MacBook-Air task-app %. Sam’s is two lines, sam@DESKTOP-4F7Q2K1 MINGW64 ~/projects/full-stack-demo-app/task-app and $. Are they in the same folder? How can each of them be sure which folder they’re in?

You can’t tell from Maria’s prompt: zsh shows only the folder’s own name, task-app, not where it is. Sam’s Git Bash prompt shows the full path. Each of them can type pwd, which prints the full path of the current folder on every computer. The prompts differ because Maria’s Mac runs zsh and Sam’s Windows laptop runs Bash, with different default prompts.

Question 15 · Short answer

What does echo "PS1='\w\$ '" >> ~/.bashrc do, and why does the new prompt still appear after you restart the computer?

It adds the line PS1='\w$ ' to the end of the file ~/.bashrc (>> appends without erasing the rest). PS1 sets Bash’s prompt: \w is the current folder, followed by $ and a space. ~/.bashrc is Bash’s start-up file, which Bash reads every time it starts, so every new terminal, also after a restart, gets the new prompt.

Hard

Question 16 · Compare

Compare Git Bash and WSL: what each one is, where your C: drive appears, and why this book uses Git Bash.

Git Bash WSL
What it is Bash and common command-line tools running as ordinary Windows programs (installed with Git for Windows) A real Linux system running inside Windows
C: drive /c /mnt/c
Home folder Your Windows home (/c/Users/sam) A separate Linux home folder

This book uses Git Bash because it is quick to install, works directly with your normal Windows folders, and installs Git at the same time. WSL is more powerful (you can install any Linux software) but adds a separate system to manage.

Question 17 · Find the bug

Maria copies this line from a website into her Mac’s Terminal (zsh):

ls -l   # show details

She gets errors saying that #, show and details don’t exist. Why? Give two ways to avoid the problem.

In Bash, # starts a comment, so the rest of the line is ignored. In zsh’s default settings, comments typed at the prompt are not recognized, so #, show and details are passed to ls as names of files to list - and those files don’t exist. To avoid it:

  • paste only the command (ls -l), without the comment, or
  • run setopt interactivecomments in zsh (or switch to Bash by typing bash).

Question 18 · Scenario

Sam’s Windows Terminal always opens PowerShell. He would like it to open Git Bash instead. What are his options?

  • For a single tab: click the ⌄ arrow next to the tabs and choose Git Bash.
  • Permanently: in Windows Terminal, go to Settings > Startup > Default profile and choose Git Bash.

Both require the Git Bash profile (the Add a Git Bash Profile to Windows Terminal option in the installer). He can also simply open Git Bash from the Start menu.

Question 19 · Long answer

A classmate installed Git for Windows by clicking Next on every screen. What will be different for them compared with someone who followed this page’s three recommendations? Is it a problem?

  • Editor: Git will open Vim when it needs a message typed (for example for a commit without -m). Vim is hard to use - even quitting requires a special command.
  • Branch name: new repositories will start on a branch called master instead of main, while GitHub uses main by default.
  • Windows Terminal: there will be no Git Bash profile in Windows Terminal (Git Bash still works from the Start menu).

None of this is serious. Git and Git Bash work fine, and the editor and branch name can be changed later with git config (see Installing and Configuring Git), or by running the installer again.

Question 20 · Scenario

In Git Bash, Sam types cd / and then ls. He sees folders such as bin, etc and usr, but none of his own files. Where is he, and how does he get back to his files?

In Git Bash, / is the folder where Git is installed (C:\Program Files\Git), not his C: drive. His files are in his home folder. cd ~ (or just cd) takes him home, to /c/Users/sam; cd /c takes him to the top of the C: drive.

© 2025-2026 Y. Rosenthal. All rights reserved.