The Work Environment: the Terminal and a First Code File
- 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
.pyextension 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.
- Chapter 1 — the terminal, the shell and basic commands (PowerShell / Bash)
- 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:
| Term | What it is | Example |
|---|---|---|
| Terminal | The window: the program that shows text and takes keyboard input. | Windows Terminal, the VS Code terminal, Terminal.app on a Mac |
| Shell | The interpreter: the program running inside the window, which reads what you typed and carries it out. | PowerShell, Bash, Zsh, cmd |
| Command | The instruction itself. | cd week-1 |
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:
-aor--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
| Action | PowerShell | Bash / Zsh |
|---|---|---|
| Where am I? | pwd | pwd |
| What is here? | ls (or dir) | ls |
| Including hidden files | ls -Force | ls -a |
| Enter a folder | cd week-1 | cd week-1 |
| One folder up | cd .. | cd .. |
| To the home folder | cd ~ | cd ~ (or just cd) |
| Create a folder | mkdir week-2 | mkdir week-2 |
| Create an empty file | New-Item notes.txt | touch notes.txt |
| Show a file’s content | cat notes.txt | cat notes.txt |
| Copy | cp a.txt b.txt | cp a.txt b.txt |
| Move / rename | mv a.txt b.txt | mv a.txt b.txt |
| Delete a file | rm notes.txt | rm notes.txt |
| Delete a folder with its content | rm -r folder | rm -r folder |
| Clear the screen | cls (or clear) | clear |
| Help on a command | Get-Help cp | man 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
| Key | What it does |
|---|---|
Tab | Autocomplete of file and folder names. Type cd we + Tab and you get cd week-1. |
↑ / ↓ | Move through previous commands. |
Ctrl + C | Stop the running command. |
Ctrl + L | Clear the screen. |
First code example
Navigating and checking. Along the way we will see the prompt change:
pwd
cd ~
pwd
cd dev\kodkod6
lsExample 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-1Line-by-line breakdown
| Command | What happened |
|---|---|
pwd | print working directory: prints where we are. |
cd ~ | Jump to the home folder. |
pwd | Confirms that we really moved. |
cd dev\kodkod6 | A relative path, from the home folder into dev, and then into kodkod6. |
ls | Shows 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 tokodkod6.
Common mistake
The mistake: thinking rm is like “delete” in the file explorer.
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 ProjectsSet-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. Andrmdoes not send to the recycle bin. Tabto autocomplete,↑for the previous command,Ctrl + Cto 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
| Text | A code file is an ordinary text file — you can open it in any text editor. |
.py | The 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. |
| Interpreter | The Python program reads the file and carries it out. Without it, the file is just text. |
| Top to bottom | Execution 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.
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.
Recommended folder structure for the course
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
kodkod6folder (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.pyOutput:
Hello, World!| Command | What it does |
|---|---|
cd week-1 | change directory — moves the terminal to the folder where the file is. |
python hello.py | Starts 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 inkodkod6\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
.pyextension 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
cdto the folder and thenpython 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:
- The window where you type and see the output.
mkdir week-2- PowerShell on Windows, or Bash on Mac and Linux.
- The program that understands what we typed and carries it out.
cd ..
Show solution
- Terminal — the window.
- Command — one instruction: create a folder.
- Shell — these are the names of different shells.
- Shell — the “brain” that interprets and carries out the commands.
- 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\- What is the full path of the file
hello.py? - The terminal stands in
C:\dev\kodkod6\week-2. Which command takes it back tokodkod6? - Why is it a good idea to keep all the course files under one folder, and not on the desktop?
Show solution
C:\dev\kodkod6\week-1\hello.pycd ..— two dots = one folder up.- When everything is under
kodkod6it 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-2Show solution
| Command | Command name | Arguments | Flag |
|---|---|---|---|
git --version | git | — | --version |
cp notes.txt backup.txt | cp | notes.txt, backup.txt | — |
ls -la | ls | — | -la |
mkdir week-2 | mkdir | week-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:
- Creates a folder called
week-1. - Enters it.
- Shows where the terminal stands now.
- 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- Why doesn’t Python find the file, if it exists?
- Give two ways to fix it.
Show solution
- Python looks for the file only in the current directory — the folder where the terminal stands (
kodkod6). The file is in the subfolderweek-1, so it is not found. - Two ways:
- Move into the folder first:
cd week-1, and thenpython hello.py. - Run it with the path:
python week-1\hello.py.
- Move into the folder first:
(A third option: the ▷ Run button in VS Code, which runs the file with its full path.)