The terminal from zero (PowerShell and macOS Terminal)

Learn the terminal from zero in PowerShell and macOS Terminal side by side: the prompt, cd, ls, mkdir, paths, PATH, exit codes and Ctrl+C.

Tool lesson, about 60 minutes, 17 steps

By the end you can

  • Open a terminal on Windows or macOS and read its prompt to know where you are.
  • Move around and create folders with cd, ls or dir, and mkdir, using tab completion and history.
  • Run a program, explain PATH, read an exit code, and stop a running program with Ctrl+C.

Before this: Your computer: requirements, files, folders and paths

Step 1 of 17

A window that takes orders

Later in this course you will start Beacon Yard's code syncing into Studio by typing two words, rojo serve, and pressing Enter. You will push your work to GitHub with git push. Neither of these has a button. Both happen in a terminalTerminalA window where you type commands and read the replies.Think of it as the counter window you speak through to a clerk who runs your order.: a window where you type a command, press Enter, and read the reply.

The terminal looks old-fashioned, and that is part of its strength. Typed commands can be copied, pasted, written down and repeated exactly. Every professional tool you meet later works from it.

First, open one.

Windows 11. Right-click the Start button and choose Terminal. Windows Terminal opens with a PowerShell tab 1. On Windows 10, open Start, type PowerShell and choose Windows PowerShell.

Windows Terminal
Windows Terminal with one PowerShell tab showing the prompt PS C:\Users\you>

Select a numbered pin, or a row below, to read what it marks.

Windows Terminal, PowerShell tab. The prompt shows the folder you are in.

macOS. Press Command + Space, type Terminal and press Return. The Terminal app lives in Applications, in the Utilities folder 2.

macOS Terminal
Illustration of macOS: Terminal window showing the title bar and a zsh prompt ending in a percent sign.

Select a numbered pin, or a row below, to read what it marks.

macOS Terminal running zsh. The % ends the prompt. Illustration of macOS.

Build along

m00-baseplate

  1. Open a terminal using the steps for your system and leave it open for this lesson.

    You should see A window with a blinking cursor after a line ending in > (Windows) or % (macOS).

Link to this step · This confused me

Step 2 of 17

Read the prompt

The text before the cursor is the promptPromptThe text before the cursor that says the shell is ready, and where you are.Think of it as the clerk saying 'Next!', with the number of your folder on it.. It means "ready for your next command", and it tells you where you are standing:

text
PowerShell:  PS C:\Users\you>
macOS zsh:   you@mac ~ %

PowerShell prints the full path of the current folder, then >. The macOS shell, zsh, prints your user name, the computer's name, the current folder's short name, then %. The ~ is your home folder.

The folder you are standing in is the current directoryWorking directoryThe folder the terminal is standing in; relative paths start from here.Think of it as where you are standing at the counter., or working directory. Every relative path you type starts from there, exactly like the directions in the previous lesson.

Choose one

Your prompt reads PS C:\Users\you\Code\beacon-yard>. Where are you?

Your prompt reads PS C:\Users\you\Code\beacon-yard>. Where are you?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 3 of 17

Ordering at the tool counter

Both sidesThe terminal is the workshop's tool counter, where a clerk does one ordered thing and reports back.
In the pictureIn Roblox
The clerk saying 'Next!'The prompt
The orderThe command
The details of the orderThe arguments and options
Where you stand at the counterThe current directory
The receiptThe exit code
The stockrooms the clerk searchesThe folders listed in PATH

See the whole analogy cast

Picture the tool counter at the back of the yard's workshop. The clerk behind it does exactly what you ask, as long as you ask in the clerk's words.

  • The prompt is the clerk saying "Next!".
  • A commandCommandThe name of the program or built-in job you ask the shell to run.Think of it as the name of what you want from the clerk. is the name of what you want: ls, cd, git.
  • ArgumentsArgumentA detail you give a command, separated from it by spaces.Think of it as the details of your order. are the details of your order, separated by spaces: in cd src, the argument is src. Arguments that start with - are called options or flags, such as --version.
  • Where you stand at the counter is the current directory.
  • When the job is done, the clerk hands you a receipt that says whether it worked. You will read that receipt later in this lesson.

Think of it as The workshop's tool counter, where a clerk does one ordered thing and reports back

Match the pairs

Take the command git commit -m "Add coin pad". Match each piece to its role.

Link to this step · This confused me

Step 4 of 17

Where am I, and what is here?

Two commands answer the two questions you will ask most:

QuestionPowerShellmacOS zsh
Where am I?pwd (short for Get-Location)pwd
What is here?ls or dir (short for Get-ChildItem)ls

PowerShell accepts the short Unix-style names as aliases of its own longer commands, so most of this lesson types the same thing on both systems 3. What comes back looks different: PowerShell prints a table with a Mode column, where d marks a folder; macOS prints the names alone.

Try it in the sandbox first. It is a pretend computer, so nothing you type there can harm yours.

The terminal sandbox

Goal Run pwd, then ls, in your home folder.

The terminal sandbox: a preview of the simulation

Build along

m00-baseplate

  1. Optional, for real: Run pwd (or Get-Location), then ls, in your real terminal, starting from your home folder. If you are somewhere else, run cd ~ first.

    You should see pwd prints the full path of your home folder, and ls lists what is in it, including your Code folder.

Link to this step · This confused me

Step 5 of 17

Move with cd

cd means change directory. Give it a path, absolute or relative:

text
cd Code            go into the Code folder (relative)
cd ..              go up one level
cd ~               go to your home folder
cd C:\Users\you    absolute, Windows
cd /Users/you      absolute, macOS

The prompt changes after each cd, which is your confirmation that it worked. If the folder does not exist, you get an error and you stay where you were.

The terminal sandbox

Goal Starting in your home folder, reach Code/beacon-yard/src/shared, then run ls and find Config.luau.

The terminal sandbox: a preview of the simulation

Build along

m00-baseplate

  1. Optional, for real: From your home folder, run cd Code, then pwd. Then run cd .. and pwd again.

    You should see After the first cd, pwd ends in Code. After cd .., pwd is your home folder again.

Link to this step · This confused me

Step 6 of 17

Let the shell type for you

Typing whole paths is slow and error-prone. Two keys fix that.

Tab completes names. Type cd sr and press Tab: if only one name in the folder starts with sr, the shell finishes it to src (PowerShell writes .\src\). If several match, PowerShell cycles through them each time you press Tab, and zsh lists them.

The Up arrow brings back your previous commands, one press at a time. Edit the line with the Left and Right arrows, then press Enter to run it again.

Professionals rarely type a full file name. Tab completion also prevents typos, because it can only complete names that really exist.

Choose one

You type cd Con and press Tab, but nothing happens. What is the most likely reason?

You type cd Con and press Tab, but nothing happens. What is the most likely reason?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 7 of 17

Make folders with mkdir

mkdir makes a directory. It works on both systems, with one difference that catches people out:

text
mkdir notes                    both: makes notes in the current folder
mkdir src/client               PowerShell: makes any missing folders on the way
mkdir -p src/client            macOS: needs -p to do the same

Names with spaces need quotes, because a space separates arguments: mkdir "my notes" makes one folder on both systems. Without quotes, mkdir my notes does something unexpected on both: macOS makes two separate folders (my and notes), while PowerShell prints an error (A positional parameter cannot be found that accepts argument 'notes') and makes nothing (to make two sibling folders in PowerShell, separate them with a comma: mkdir my, notes). This is why the last lesson suggested names without spaces.

The terminal sandbox

Goal Inside Code, create practice/one/two with a single command, then cd into two.

The terminal sandbox: a preview of the simulation

Build along

m00-baseplate

  1. Optional, for real: Inside your Code folder, create scratch/one/two with a single command (add -p on macOS), then cd into two and run pwd.

    You should see pwd ends in Code/scratch/one/two (with backslashes on Windows).

Link to this step · This confused me

Step 8 of 17

Peek inside a file

You can print a text file's contents without opening an editor:

text
cat README.md          macOS
cat README.md          PowerShell (an alias of Get-Content)

To make an empty file, macOS uses touch notes.txt and PowerShell uses New-Item notes.txt. You will rarely need either, because your editor creates files for you. Reading a file with cat is handy for small files like .gitignore.

On macOS and Linux, names that start with a dot, such as .gitignore, are hidden until you run ls -a. On Windows, a leading dot does not hide a file on its own, so plain ls in PowerShell already shows .gitignore; only items marked with the Windows Hidden attribute (such as Git's .git folder) require ls -Force.

Choose one

On macOS, inside the beacon-yard folder, ls shows README.md and src, but you know there is a .gitignore. Why is it missing?

On macOS, inside the beacon-yard folder, ls shows README.md and src, but you know there is a .gitignore. Why is it missing?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 9 of 17

Run a program by name

Good place for a break. Your answers and progress are saved in this browser, so you can stop here and come back to this step. Tick what you can do now; if something is shaky, go back one step first.

Checkpoint

0 of 3 checked

Every command so far was built into the shell. Most of the time you will run programs: git, rojo, code. You type a program the same way, by its name and arguments.

Try one now. Git may not be installed yet, and that is fine, because an error is useful information.

text
git --version

There are three possible results:

  • git version 2.x.y means Git is installed and the shell found it.
  • On Windows, "The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program" means the shell could not find a program called git.
  • On macOS, a window may offer to install Apple's command line tools, which include Git 4. Accepting is safe; the Git lesson relies on it.

Build along

m00-baseplate

  1. Run git --version in your real terminal and note which of the three results you got.

    You should see You see a version number, a 'not recognized' or 'command not found' error, or the macOS install prompt. All three are fine for now.

Link to this step · This confused me

Step 10 of 17

PATH: where the shell looks

How does the shell find git when you never said which folder it is in? It checks a list of folders, in order, and runs the first file whose name matches. That list is an environment variableEnvironment variableA named setting that every program started from a shell can read.Think of it as a sticky note pinned to the shell that all its programs can see. called PATHPATHThe environment variable listing the folders the shell searches for programs.Think of it as the list of aisles the clerk checks, in order, for the tool you named. 5.

text
PowerShell:  $env:Path -split ';'
macOS zsh:   echo $PATH | tr ':' '\n'

Each command prints the folders one per line. Windows separates them with ; and macOS with :.

Two rules follow from this, and they explain most "it says not found but I just installed it" moments:

  1. An installer that adds a tool to PATH changes it for new terminals. A terminal that was already open keeps its old copy. Close it and open a fresh one.
  2. If a tool is installed but not on PATH, you can still run it by typing its full path.

In the counter picture, PATH is the list of stockrooms the clerk searches, in order.

Choose one

You install Git, go back to the terminal you already had open, and git --version still says 'not recognized'. What do you try first?

You install Git, go back to the terminal you already had open, and git --version still says 'not recognized'. What do you try first?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 11 of 17

The receipt: exit codes

Every program ends by handing back a number, its exit codeExit codeThe number a program hands back when it ends; 0 means success.Think of it as a receipt that says whether the job worked.. 0 means success. Anything else means something went wrong; the exact number is the program's choice.

PowerShellmacOS zsh
Last program's exit code$LASTEXITCODEecho $?
Did the last command succeed?$? (True or False)(same $?, 0 is success)

In PowerShell, $LASTEXITCODE holds the exit code of the last native program you ran, such as git 6.

You will rarely type these yourself. They matter because automation reads them. When GitHub tests Beacon Yard, each check is a command, and a non-zero exit code is what turns the check red.

Both sidesRemember: The terminal is the workshop's tool counter, where a clerk does one ordered thing and reports back.

The terminal sandbox

Goal Run cd nowhere, then show the exit code. Then run cd src and show it again.

The terminal sandbox: a preview of the simulation

Build along

m00-baseplate

  1. Optional, for real: Run cd nowhere, then show the exit code (echo $? on macOS, $? in PowerShell). Then run cd Code and show it again.

    You should see The first cd prints an error and the code is not 0 (False in PowerShell). After the cd that works, the code is 0 (True in PowerShell).

Link to this step · This confused me

Step 12 of 17

Stop, copy and paste

Some programs keep running until you stop them. rojo serve is one: it keeps syncing until you tell it to quit. Press Ctrl + C to stop the running program, on Windows and on macOS. The shell prints ^C and the prompt comes back.

That collides with copy and paste, so learn the terminal versions:

Windows (Windows Terminal or the PowerShell window)macOS Terminal
Stop the running programCtrl + C (with no text selected)Control + C
Copyselect text, then Ctrl + C or Ctrl + Shift + CCommand + C
PasteCtrl + V or right-clickCommand + V

Paste one command at a time and read it before pressing Enter. Windows Terminal warns you before pasting several lines at once, because each line runs as soon as it lands. The older Windows PowerShell window on Windows 10 does not warn you, so be extra careful there.

Choose one

rojo serve is running and printing messages. You want your prompt back. What do you press?

rojo serve is running and printing messages. You want your prompt back. What do you press?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 13 of 17

Where the counter idea breaks

A good clerk asks "are you sure?" before doing something drastic, and keeps returns in a back room for a week.

The terminal does neither. rm notes.txt on macOS and Remove-Item notes.txt in PowerShell (also spelled rm) delete the file immediately. They do not move it to the Recycle Bin or the Trash, and they do not ask first. Add -r or -Recurse and they delete whole folders the same way.

Where does it break?“The workshop's tool counter, where a clerk does one ordered thing and reports back” is a good picture of the terminal. Where does it stop being true?

It breaks here. A real clerk asks 'are you sure?' and keeps returns, but the terminal does exactly what you typed: deletions skip the Recycle Bin and there is no undo.

The true model. A shell reads a line, finds the program by name in PATH, runs it with the arguments in the current directory, and reports its exit status. It never asks for confirmation unless the program does.

Choose one

You run rm -r src by mistake inside beacon-yard. How do you get the folder back?

You run rm -r src by mistake inside beacon-yard. How do you get the folder back?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 14 of 17

Which terminal, which shell?

Two words get mixed up. The terminalTerminalA window where you type commands and read the replies.Think of it as the counter window you speak through to a clerk who runs your order. is the window. The shellShellThe program inside a terminal window that reads your commands and runs them.Think of it as the clerk behind the counter; the window is just the counter. is the program inside it that reads your commands. Windows Terminal can host several shells in tabs, and macOS Terminal runs zsh by default on macOS 10.15 and later 7. Studio still runs on macOS 10.14, whose default shell is bash: if your prompt ends in $ instead of %, type zsh and press Enter first, and every macOS command in this course works as written.

Shells you will meet

OptionWhat it isWhen pros pick itTrade-offs
PowerShellThe shell that comes with Windows. Its own commands have long names like Get-ChildItem, with Unix-style aliases. All Windows commands in this course are written for it (the Windows default).Any Windows machine, with nothing extra to install.Tutorials written for macOS or Linux need translating.
zshThe macOS default shell. It uses the Unix commands (ls, mkdir -p, rm) that Linux and most online tutorials also use (the macOS default).Any Mac, with nothing extra to install.Its commands differ from PowerShell's, so follow the macOS column of this course on a Mac.
Git BashA Unix-style shell installed with Git for Windows. Paths look like /c/Users/you.You prefer Unix commands on Windows, or follow tutorials written for macOS and Linux.You translate this course's Windows commands as you go.
Command Prompt (cmd)The old Windows shell.Mostly legacy scripts.It still works but uses different commands (dir, cd /d, no ls). Avoid it for this course.
Choose one

Windows Terminal is open with a Git Bash tab. Which commands apply?

Windows Terminal is open with a Git Bash tab. Which commands apply?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 15 of 17

Cheat sheet

Keep this nearby until the commands feel familiar.

Reference Terminal cheat sheet: PowerShell and zsh
TaskPowerShellmacOS zsh
Where am Ipwdpwd
Listls, ls -Force for hiddenls, ls -a for hidden
Movecd folder, cd .., cd ~same
Make foldersmkdir a\b\cmkdir -p a/b/c
Make an empty fileNew-Item f.txttouch f.txt
Print a filecat f.txtcat f.txt
Delete (no undo)Remove-Item f.txt, -Recurse for foldersrm f.txt, rm -r for folders
Show PATH$env:Path -split ';'echo $PATH | tr ':' '\n'
Last exit code$LASTEXITCODE (programs) or $? (PowerShell commands)echo $?
Stop a programCtrl + CControl + C
Clear the screenclear or clsclear
Put in order

Put these in order to create a folder called notes inside your Code folder and check it worked, starting from anywhere.

  1. cd Code
  2. cd ~
  3. ls
  4. mkdir notes

Link to this step · This confused me

Step 16 of 17

Challenges

Level 2, Builder

Challenge

Build the skeleton of Beacon Yard's folder tree using only the terminal, starting from your home folder. Use the sandbox below, so nothing touches your real beacon-yard later.

Start from
The terminal sandbox, preset home, in either flavour.

Done means

  • Code/beacon-yard/src/server, src/shared and src/client all exist.
  • An empty file README.md exists in Code/beacon-yard.
  • You used tab completion at least once (the Sim checks history for a completed path).
  • Your current directory at the end is Code/beacon-yard.

Meet the criteria above, then record your own result. No test grades this check.

The terminal sandbox

Goal Build the skeleton: server, shared and client under Code/beacon-yard/src, an empty README.md in Code/beacon-yard, using Tab completion at least once, and end in Code/beacon-yard.

The terminal sandbox: a preview of the simulation

Level 1, Apprentice

Challenge

Repeat the idea in your real terminal, with no sandbox: make a folder, look at it and read the exit code.

Start from
Your real terminal, in your home folder.

Done means

  • You created Code/practice in your real Code folder using the terminal.
  • You listed Code and saw practice in the output.
  • You printed the exit code of your last command and it was 0 (or True for $? in PowerShell).

Meet the criteria above, then record your own result. No test grades this check.

Link to this step · This confused me

Step 17 of 17

Recap

Retiring the analogy

You no longer need “the workshop's tool counter, where a clerk does one ordered thing and reports back”. A shell reads a line, finds the program by name in PATH, runs it with the arguments in the current directory, and reports its exit status. It never asks for confirmation unless the program does.

Recap

  1. The prompt shows where you stand. pwd, ls and cd answer where am I, what is here, and go there; Tab and the Up arrow do most of the typing.
  2. Programs are found through PATH, a list of folders. A terminal opened before an install does not see the new PATH, so open a fresh one.
  3. Exit code 0 means success and anything else means failure, which is what CI reads. Ctrl + C stops a running program, and terminal deletes have no undo.

The terminal is the workshop's tool counter, where a clerk does one ordered thing and reports back, until a real clerk asks 'are you sure?' and keeps returns, but the terminal does exactly what you typed: deletions skip the Recycle Bin and there is no undo.

Next A code editor from zero: VS Code and Cursor

Link to this step · This confused me