The Work Environment: the Terminal and a First Code File

Lesson goals
  • Tell the difference between a terminal, a shell and a command
  • Break a command into its parts — name, arguments and flags
  • Explain why we write code in a file, and what the .py extension means
  • Know a tidy folder structure for the course and the naming rules for files and folders

In this lesson

This lesson is built from two short chapters, in the same order as the slides. The tools themselves (Python, VS Code, Git and Docker) were already installed in the Installations topic.

  1. Chapter 1 — the terminal, the shell and basic commands (PowerShell / Bash)
  2. Chapter 2 — the work folder and a first Python file

Chapter 1: The Terminal, the Shell and Basic Commands (PowerShell / Bash)

What will we learn?

  • The difference between a terminal and a shell.
  • How a command is built.
  • The basic commands every developer uses every day: navigating, listing, creating, copying, moving, deleting.
  • PowerShell (Windows) versus Bash/Zsh (Mac/Linux).

Why do we need this?

  • Git, installing packages with pip, and running a server (the backend and databases topics) are all done from the terminal.
  • Real servers in the cloud have no graphical interface — only a terminal.
  • Once you get used to it, the terminal is faster than the mouse: one command can create 5 folders at once.

Explanation from the basics

Terminal, shell, command

Three terms that are confusing at first:

TermWhat it isExample
TerminalThe window: the program that shows text and takes keyboard input.Windows Terminal, the VS Code terminal, Terminal.app on a Mac
ShellThe interpreter: the program running inside the window, which reads what you typed and carries it out.PowerShell, Bash, Zsh, cmd
CommandThe instruction itself.cd week-1
Analogy

The terminal is the phone, the shell is the person on the other end who understands the language and does what you ask, and the command is the sentence you say. You can hold the same phone (terminal) and talk to different people who understand different languages (PowerShell or Bash).

  • PowerShell — the modern Windows shell.
  • Bash — the common shell on Linux. Zsh — the default on a Mac, almost identical to Bash for the basic commands.
  • cmd — the old Windows shell. We will not use it.

The prompt

The prompt is the text the shell shows while it waits for a command:

PS C:\Users\dana\dev\kodkod6>        ← PowerShell: "PS" + current directory
dana@laptop:~/dev/kodkod6$           ← Bash: user@computer:directory$

~ (tilde) in Bash = the user’s home folder.

How a command is built

command   argument(s)    flag(s)/option(s)
  cp      notes.txt  backup.txt
  ls      -la
  mkdir   week-2
  • Command — what to do.
  • Argument — what to do it to (a file, a folder).
  • Flag / option — how to do it. In Bash: -a or --all. In PowerShell: -Recurse, -Force.
  • A space separates the parts. That is why names with spaces need quotes: cd "My Folder". And it is one more reason not to put spaces in names.

Syntax

The main command table

ActionPowerShellBash / Zsh
Where am I?pwdpwd
What is here?ls (or dir)ls
Including hidden filesls -Forcels -a
Enter a foldercd week-1cd week-1
One folder upcd ..cd ..
To the home foldercd ~cd ~ (or just cd)
Create a foldermkdir week-2mkdir week-2
Create an empty fileNew-Item notes.txttouch notes.txt
Show a file’s contentcat notes.txtcat notes.txt
Copycp a.txt b.txtcp a.txt b.txt
Move / renamemv a.txt b.txtmv a.txt b.txt
Delete a filerm notes.txtrm notes.txt
Delete a folder with its contentrm -r folderrm -r folder
Clear the screencls (or clear)clear
Help on a commandGet-Help cpman cp (exit: q)

In PowerShell, ls, cat, cp, mv, rm are aliases for longer commands (Get-ChildItem, Get-Content, Copy-Item…). That way the same basic commands work in both environments.

Keyboard shortcuts that save hours

KeyWhat it does
TabAutocomplete of file and folder names. Type cd we + Tab and you get cd week-1.
↑ / ↓Move through previous commands.
Ctrl + CStop the running command.
Ctrl + LClear the screen.

First code example

Navigating and checking. Along the way we will see the prompt change:

pwd
cd ~
pwd
cd dev\kodkod6
ls

Example output:

Path
----
C:\Users\dana\dev\kodkod6\week-1

Path
----
C:\Users\dana

    Directory: C:\Users\dana\dev\kodkod6

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          06/10/2026     09:12                sandbox
d----          06/10/2026     08:40                week-1

Line-by-line breakdown

CommandWhat happened
pwdprint working directory: prints where we are.
cd ~Jump to the home folder.
pwdConfirms that we really moved.
cd dev\kodkod6A relative path, from the home folder into dev, and then into kodkod6.
lsShows the content. In PowerShell, d in the Mode column marks a directory (folder).

Another example

We build the folder structure of the Python topic with commands only, create files, copy, rename and delete:

cd ~\dev\kodkod6
mkdir week-2
cd week-2
mkdir day-1, day-2, day-3
New-Item day-1\notes.txt
ls
cp day-1\notes.txt day-2\notes.txt
mv day-2\notes.txt day-2\summary.txt
ls day-2
rm day-1\notes.txt
cd ..

In Bash/Zsh (Mac / Linux), the same thing:

cd ~/dev/kodkod6
mkdir week-2
cd week-2
mkdir day-1 day-2 day-3
touch day-1/notes.txt
ls
cp day-1/notes.txt day-2/notes.txt
mv day-2/notes.txt day-2/summary.txt
ls day-2
rm day-1/notes.txt
cd ..

Breakdown:

  • mkdir day-1, day-2, day-3 — in PowerShell you can create several folders at once with commas. In Bash — with spaces.
  • New-Item / touch — create an empty file.
  • cp source destination — copy: the source stays, and a copy is created.
  • mv source destination — move. If the destination is in the same folder with a different name, it is really a rename.
  • rm — delete.
  • cd .. — back to kodkod6.

Common mistake

The mistake: thinking rm is like “delete” in the file explorer.

rm does not send to the recycle bin!

A file deleted with rm is deleted permanently. There is no undo and no recycle bin. In particular: never run rm -r on a path you are not sure about, and never copy commands from the internet that contain rm -rf / or sudo rm.

A safe habit: before rm, run ls on exactly the same path and check what you are about to delete.

Second mistake — spaces in names:

cd My Projects
Set-Location: A positional parameter cannot be found that accepts argument 'Projects'.

The shell saw two arguments: My and Projects. The fix: cd "My Projects". And better from the start: my-projects.

Third mistake — running Python code in the shell:

PS> print("hi")

print is a Python command, not a PowerShell one. It runs inside Python: python -c "print('hi')", or inside a .py file. And the other way round: cd does not work inside a Python file.

Summary

  • Terminal = the window. Shell = the interpreter (PowerShell / Bash / Zsh). Command = the instruction.
  • A command = name + arguments + flags, separated by spaces.
  • Navigating: pwd, ls, cd, cd .., cd ~.
  • Files: mkdir, New-Item / touch, cp, mv, rm. And rm does not send to the recycle bin.
  • Tab to autocomplete, ↑ for the previous command, Ctrl + C to stop.

Official documentation

Chapter 2: The Work Folder and a First Python File

What will we learn?

  • Why we write code in a file, and what a code file really is.
  • How to build a tidy work folder (workspace folder) for the whole course.
  • What happens when you run a file: the interpreter reads it from top to bottom.
  • What the current directory is, and why it causes the most common beginner error.

Why do we need this?

  • A line you type in the terminal disappears the moment you close the window. A real program is dozens and hundreds of lines — you need to save them.
  • In the course we will write dozens of files: exercises, projects, servers. Without order, after a week you will not find anything. Professional developers keep every project in its own folder — and that is also how Git and VS Code expect to work: project = folder.
  • Many beginner errors (“the file was not found”) happen because the terminal is in a different folder from the file.

Explanation from the basics

File and folder

  • File — a unit of information saved on the disk: a document, an image, or a code file.
  • Folder / directory — a “drawer” that holds files and more folders.
  • Path — the full address of a file, from the root down to it. For example: C:\dev\kodkod6\week-1\hello.py.

What a code file really is

TextA code file is an ordinary text file — you can open it in any text editor.
.pyThe extension tells the operating system and VS Code: “this is Python code”. VS Code sees it and turns on syntax highlighting and a run button.
InterpreterThe Python program reads the file and carries it out. Without it, the file is just text.
Top to bottomExecution starts at the first line and continues line after line to the end.

The current directory

The terminal always “stands” in one folder — it appears to the left of the cursor (the prompt):

PS C:\dev\kodkod6\week-1>

When you type python hello.py, Python looks for hello.py in the current directory only. If the file is in another folder — it will not find it.

Analogy

The terminal is like a person standing in a particular room of a house. If you ask them to “bring the book from the shelf” — they will look only on the shelf in the room where they are standing. If the book is in another room, you first need to tell them to change rooms (the cd command), or give them the full address.

C:\dev\kodkod6\          (Mac: ~/dev/kodkod6/)
├── week-1\
│   └── hello.py
├── week-2\
├── week-3\
└── week-4\
  • One folder for the whole course (kodkod6), with a folder for every week inside it.
  • Naming rules: lowercase English letters, no spaces and no Hebrew. Instead of a space, use a hyphen - for folders and an underscore _ for Python files (my_file.py). Spaces and non-English characters in a path cause problems in many tools.
  • In VS Code, open the whole kodkod6 folder (File → Open Folder), not a single file.

How to run a file

Say the week-1 folder has a file hello.py with one line that prints Hello, World!. The instructor will demonstrate running it on the screen:

cd week-1
python hello.py

Output:

Hello, World!
CommandWhat it does
cd week-1change directory — moves the terminal to the folder where the file is.
python hello.pyStarts the interpreter and hands it the file. It reads it from top to bottom and carries out every line.

A second way to run: the Run button. In VS Code, when a .py file is open, there is a triangle ▷ at the top right (Run Python File). Clicking it opens a terminal and runs the file with its full path — so there is no need for cd.

Common mistake

The mistake: running from the wrong folder.

PS C:\dev\kodkod6> python hello.py
can't open file '...hello.py':
[Errno 2] No such file or directory
  • The terminal stands in kodkod6, and the file is in kodkod6\week-1.
  • Python looks for the file only in the current directory.
  • The fix: first cd week-1, and only then run. Or run with the path: python week-1\hello.py.

Second mistake: not saving before running. If the file’s tab shows a circle ⚪ instead of ✕, the file was not saved, and Python will run the old version. It is a good idea to turn on File → Auto Save.

Summary

  • A code file is a text file. The .py extension says it is Python code.
  • Project = folder. English names, no spaces: kodkod6/week-1/hello.py.
  • The interpreter reads the file and carries it out from top to bottom.
  • The current directory is where the terminal stands — and that is where Python looks for the file.
  • Run with cd to the folder and then python file.py, or with the ▷ button in VS Code.

Official documentation

Practice

Comprehension questions on the lesson material — no code.

Exercise 1: Terminal, shell or command?

For each sentence, write whether it describes a terminal, a shell or a command:

  1. The window where you type and see the output.
  2. mkdir week-2
  3. PowerShell on Windows, or Bash on Mac and Linux.
  4. The program that understands what we typed and carries it out.
  5. cd ..
Show solution
  1. Terminal — the window.
  2. Command — one instruction: create a folder.
  3. Shell — these are the names of different shells.
  4. Shell — the “brain” that interprets and carries out the commands.
  5. Command — one instruction: move one folder up.

The rule: the terminal is the window, the shell is the program running inside it, and the command is what you type.

Exercise 2: What is the full path?

The course folder structure:

C:\dev\kodkod6\
├── week-1\
│   └── hello.py
└── week-2\
  1. What is the full path of the file hello.py?
  2. The terminal stands in C:\dev\kodkod6\week-2. Which command takes it back to kodkod6?
  3. Why is it a good idea to keep all the course files under one folder, and not on the desktop?
Show solution
  1. C:\dev\kodkod6\week-1\hello.py
  2. cd .. — two dots = one folder up.
  3. When everything is under kodkod6 it is easy to find any file even a month later, the paths are short and have no spaces, and you can open the whole course in VS Code at once.

Exercise 3: How a command is built

In each of the following commands — what is the command name, what is the argument and what is the flag (if any)?

git --version
cp notes.txt backup.txt
ls -la
mkdir week-2
Show solution
CommandCommand nameArgumentsFlag
git --versiongit—--version
cp notes.txt backup.txtcpnotes.txt, backup.txt—
ls -lals—-la
mkdir week-2mkdirweek-2—

The rule: command = what to do, argument = what to do it to, flag = how (a change of behavior, starts with a hyphen).

Exercise 4: Navigating folders

The terminal stands in C:\dev\kodkod6. Write the sequence of commands that does the following, in order:

  1. Creates a folder called week-1.
  2. Enters it.
  3. Shows where the terminal stands now.
  4. Goes back one folder up.
Show solution
mkdir week-1
cd week-1
pwd
cd ..
  • mkdir — create a folder.
  • cd week-1 — move into the folder.
  • pwd — prints the current path: C:\dev\kodkod6\week-1.
  • cd .. — two dots = one folder up.

Exercise 5: “No such file or directory”

The file hello.py is in C:\dev\kodkod6\week-1. A student runs:

PS C:\dev\kodkod6> python hello.py
can't open file '...hello.py': [Errno 2] No such file or directory
  1. Why doesn’t Python find the file, if it exists?
  2. Give two ways to fix it.
Show solution
  1. Python looks for the file only in the current directory — the folder where the terminal stands (kodkod6). The file is in the subfolder week-1, so it is not found.
  2. Two ways:
    • Move into the folder first: cd week-1, and then python hello.py.
    • Run it with the path: python week-1\hello.py.

(A third option: the ▷ Run button in VS Code, which runs the file with its full path.)