The terminal
Navigate folders and run programs by typing commands.
Why it matters
Almost every AI tool starts in the terminal. Installing a library, running a script, starting a local model, copying a project from GitHub, even running coding assistants like Claude Code: the instructions are terminal commands. Once typing cd and ls feels normal, a page full of setup commands stops looking like a wall. It starts looking like a checklist.
What you'll be able to do
- Find out where you are and move between folders with pwd, ls and cd
- Create, read, copy, move and delete files from the command line
- Run a Python script from the terminal
- Read the setup instructions in an AI project's README without guessing
What it covers
- A text conversation with your computer
- Where am I?
- Making and changing files
- Running programs
- Reading a README's instructions
- Worked example: set up a report folder
A text conversation with your computer
The terminal is a window where you control your computer by typing commands instead of clicking. It's like texting your computer instead of pointing at things. On a Mac it's the Terminal app (Applications → Utilities → Terminal). On Windows, use PowerShell or Windows Terminal. The program inside it that reads and runs your commands is called the shell. On macOS it's zsh.
You type a command after the prompt and press Return. The shell runs it, prints any output, and shows a new prompt. A prompt often looks something like this:
sam@MacBook campaign-report %
That's your username, your computer's name, the folder you're in, and %, which means "ready". You never type the prompt itself.
Most commands follow the same shape:
- a program name,
- optional flags, which change how it behaves (they start with
-), - arguments, which say what to act on.
ls -l data
Here ls is the program (list files). -l is a flag (long format, with sizes and dates). And data is the argument (which folder to list).
Note: In documentation you'll often see commands written as
$ ls -l. The$stands for the prompt. Don't type it.
Where am I?
Your files are arranged as a tree of folders. The terminal also calls them directories. At any moment the shell has a current working directory: the folder your commands act on. It's like the room you're standing in. Three commands do most of the work of finding your way around:
| Command | What it does |
|---|---|
pwd | print working directory: shows the folder you're in |
ls | lists what's in the current folder (ls data lists another folder) |
cd name | change directory: moves into a folder |
Show the answer
pwd
pwd prints the working directory. ls lists what's in it, and cd moves you somewhere else.
A few shortcuts make cd fast:
cd ..moves up one level, to the folder that contains this one...always means "the parent folder", and.means "this folder".cd ~, or justcdon its own, goes to your home folder,/Users/yourname. The~is shorthand for it.cd ~/projects/campaign-reportjumps straight to a folder from anywhere.
Paths come in two kinds, like a full street address versus "two doors down":
- An absolute path starts at the top of the tree with
/, or at your home folder with~. It works from anywhere:/Users/sam/projects/campaign-report/notes.txt. - A relative path starts from wherever you are now. If you're already in
campaign-report, the same file is justnotes.txt, and the spending data isdata/spend.csv.
Files whose names start with a dot, like .gitignore or .env, are hidden. Plain ls skips them, and ls -a shows them. You'll meet both of those files in later lessons, and both matter.
Tip: Press Tab to finish a file or folder name for you. Type
cd daand press Tab, and the shell completes it tocd data/. It saves typing and catches typos.
Try it below. The terminal starts inside a small project folder.
path = "/Users/ann/projects/shop" parts = path.split("/") print(parts[-1])
Show the answer
shop
split("/") cuts the path at each slash, and [-1] takes the last piece, shop. That last piece is the folder you're in, which is what the terminal prompt usually shows.
Work through the tasks under the terminal, or type help to see every command the simulator knows.
~/projects/campaign-report. You run cd data, then cd .., then pwd. What does pwd print?Show the answer
/Users/you/projects/campaign-report
cd data goes down one level and cd .. comes back up one level, so you end where you started. cd .. doesn't undo anything; it always moves to the parent of wherever you are.
Making and changing files
| Command | What it does |
|---|---|
mkdir output | makes a new folder called output (mkdir -p a/b/c makes nested folders in one go) |
touch notes.txt | creates an empty file (or updates the date on an existing one) |
cat notes.txt | prints a file's contents |
echo "Q3 review" > notes.txt | writes text into a file, replacing what was there |
echo "Check CPC" >> notes.txt | adds a line to the end of a file |
cp notes.txt backup.txt | copies a file |
mv notes.txt archive/ | moves a file; mv old.txt new.txt renames it |
rm notes.txt | deletes a file (rm -r folder deletes a folder and everything in it) |
echo prints whatever you give it. On its own it prints to the screen. The > sign redirects that output into a file instead. One > replaces the file's contents, and two >> add to the end of it. Mixing them up is a classic way to wipe a file, so give it a moment's thought every time.
Watch out:
rmdoesn't use the Trash. A deleted file is gone, with no "are you sure?" and no undo.rm -ron the wrong folder can remove a whole project. Runpwdandlsfirst so you know exactly what you're deleting.
notes.txt contains three lines. You run echo "Final numbers" > notes.txt. What's in the file now?Show the answer
Only the line Final numbers
A single > replaces the whole file with the new output. To keep the old lines and add one at the end, use >>.
Running programs
Every command you've typed so far is actually a small program. Python is a program too. To run a Python file, give its name to python3:
python3 report.py
On a Mac the command is python3, not python. Older guides say python, which on many Macs either doesn't exist or points at something else. (On Windows it's usually python or py.) Two quick checks:
python3 --version which python3
The first prints the version. The academy's browser Python is 3.14, and your computer may have an older one. which shows the full path of the program a command will run. That helps when something "isn't found" or the wrong version runs.
A few habits that save time:
- Up arrow brings back your previous command, so you can rerun or edit it.
historylists the commands you've typed recently.- Ctrl+C stops a program that's running too long or stuck in a loop.
clearwipes the screen when it gets cluttered (your files are untouched).
Reading a README's instructions
Open-source AI projects explain setup as a list of commands. Now you can read one:
cd ~/projects git clone https://github.com/example/ad-analyzer.git cd ad-analyzer python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt python3 analyze.py
You already know cd and python3. git clone downloads a project (next lesson). The venv, source and pip lines set up the project's own Python packages (the lesson after that).
Sometimes two commands are joined with &&, as in cd ad-analyzer && python3 analyze.py. That means "run the second only if the first worked".
cd ad-analyzer && python3 analyze.py, what happens if the cd fails?Show the answer
The Python script doesn't run
&& means "run the second only if the first worked", which stops you running a script from the wrong place.
Watch out: Don't paste commands you don't understand into your terminal. Be most careful with ones that start with
sudo(run as administrator), or that send a download straight into the shell, likecurl ... | sh. Those can change anything on your computer. If an AI assistant or a website suggests one, ask what each part does first.
Worked example: set up a report folder
Here's a short session from start to finish. Lines starting with % are what you type, and the other lines are what the terminal prints back:
% cd ~/projects % mkdir -p q4-report/data % cd q4-report % echo "Q4 report notes" > notes.txt % echo "Check search CPC" >> notes.txt % cat notes.txt Q4 report notes Check search CPC % ls data notes.txt % pwd /Users/sam/projects/q4-report
Step by step:
mkdir -pmakesq4-reportand thedatafolder inside it in one go.cdmoves into the new project folder.- The first
echouses>, so it createsnotes.txtwith one line. The second uses>>, so it adds a line instead of replacing the first. catshows both lines,lsshows the folder and the file, andpwdconfirms where you are.
If the second echo had used a single >, cat would show only "Check search CPC".
rm notes.txt by mistake. Can you get the file back from the Trash?Show the answer
No: rm doesn't use the Trash, so the file is gone
rm deletes for good, with no "are you sure?" and no undo. Run pwd and ls first, so you know exactly what you're deleting.
Practice what you just read
- a practice exercise that checks your code
- a 6-question quiz
- 5 review cards for spaced repetition
Try a quiz question
You're in /Users/sam/projects/site. You run cd ../blog. Where are you now?