10  Terminal basics

11 Terminal basics

A terminal is a text window into your computer. You type commands; it does things. It is the cheapest, most reliable interface to a working computer ever invented, and the harness for the CLI agent we use in Part III. You do not need to be a power user. You need a small, comfortable working set.

11.1 What you will get from this chapter

  • A terminal you can open in under three seconds.
  • The five commands you will reuse in every project.
  • A clear sense of what not to do until you mean it.

11.2 Open a terminal

  • macOS. Cmd-Space, type terminal, press Return.
  • Windows. Open Windows Terminal if you have it (Windows 11 ships with it; on Windows 10, install from the Microsoft Store). Otherwise PowerShell. Use Command Prompt only if neither of the above is available.
  • Linux. Ctrl-Alt-T, or your distribution’s “Terminal” app.

You will see a blinking cursor next to a prompt — usually your username and computer name and a $ or >. That is the AI of the 1970s. It is still here because it works.

11.3 Five commands

Most of what you will type in the terminal for this book is one of these.

pwd          # where am I?
ls           # what is in this folder?
cd folder    # move into a folder
cd ..        # move up one level
clear        # tidy the screen

On Windows PowerShell, pwd and ls work; on plain Command Prompt you would use cd (without arguments) and dir instead. PowerShell is the path of least resistance for this book.

A typical session: open terminal, pwd to see where it dropped you, cd Documents/projects/my-project, ls to confirm you are where you think you are, run something, clear when the screen gets messy.

11.4 Paths in one paragraph

A path is the address of a file or folder.

  • macOS / Linux: /Users/anna/Documents/dawai/data/hotels.csv
  • Windows: C:\Users\Anna\Documents\dawai\data\hotels.csv

Two shortcuts will save you typing:

  • ~ means your home folder. cd ~/Documents works on macOS and Linux. PowerShell understands ~ too.
  • Tab completion. Start typing a folder name and press Tab. The shell finishes it for you. Press Tab twice to see options.

11.5 Running scripts and tools

The reason any of this matters for the book:

python script.py            # run a Python script
python -m venv .venv        # make a virtual environment
pip install pandas          # install a package
git status                  # ask Git what changed
claude                      # start the Claude Code CLI agent

Each of these is a tool that ships with a name; you call it by typing the name. You will pick up more as you go.

11.6 Stopping something that is running

If a command runs forever, Ctrl-C stops it. Press it. If the program ignores Ctrl-C, close the terminal window. Both are fine. Neither breaks anything.

11.7 What not to do until you mean it

Three commands look harmless and are not. Avoid them until you understand them.

  • rm -rf <something> — deletes a folder and everything in it, no Recycle Bin. Even more so on macOS and Linux. Pause before you type it.
  • sudo (macOS / Linux) — runs a command as administrator. Most things in this book do not need it. If a chat AI tells you to sudo and you do not know why, ask why first.
  • git push --force — already covered in Git for analysts.

11.8 Where AI helps · Where AI bluffs

Helps. Translating “I want to count the lines in every CSV in this folder” into a single shell command. Explaining what an unfamiliar command does. Suggesting safer alternatives.

Bluffs. Mixing macOS commands with Windows ones in the same answer. Recommending a destructive command without flagging it. Telling you to rm something on the basis of a misunderstanding of your folder structure. Read what the AI is asking you to delete; read it twice.

11.9 Keep this with you, not the AI

  • The decision to run a command, especially one with rm, sudo, or --force in it. AI advises; you press Enter.
  • The path you are operating in. “Run this in your project folder” assumes you know which folder that is. Look at pwd before you act.

11.10 Try this

Open a terminal. Run pwd, ls, then cd ~, then pwd again. You should see your home folder. cd back into a project folder you care about. Confirm ls shows what you expect. Total time: under a minute.

If you got that far, the terminal is no longer the obstacle. The CLI agent in Part III will live here.

11.11 AI and me

  1. How did AI support me here?
  2. How did AI fail me?
  3. How did AI extend me?

11.12 Where to go next

VS Code and Copilot for the IDE harness, or Installing a CLI agent for the CLI harness. You do not need both today.