Day 1: Python and the Linux Terminal
CyberQuest Summer Camp - day deck
This is your hands-on companion to the main course deck. The main deck (Interactive_Slides.html) sends you to specific Parts here and to Modules in the notebook, then back. You can also run this deck on its own, top to bottom, with the Next arrow.
Morning Kickoff: Motivation & News (09:00 AM - 09:15 AM)
- Case Profile: The 2014 Sony Pictures Hack. Attackers compromised network architectures using targeted data deletion tools, revealing confidential emails and unreleased files. This demonstrates how cyberattacks can have real-world political consequences.
Teaching Session I: Core Lecture (09:15 AM - 11:15 AM)
Introduction to Computer Programming using Python
Python is an interpreted, high-level, general-purpose programming language. Because its syntax focuses heavily on readability, it is a widely used tool among security professionals for writing automated scanners and security tools.
* Variables: Named containers that store values.
* Syntax: The grammar rules regulating code configuration.
* Data Types: Strings (textual data like "admin"), Integers (whole numbers like 80), and Booleans (logical evaluations representing True or False).
Computer Networking Foundations
- Internet Protocol Address (IP Address): A unique numerical identifier assigned to a device or network interface.
- Data Packet: A formatted unit of data carried by a packet-switched network. Contains control metadata (headers) and user data payloads.
- Routing: The functional process of selecting paths across network nodes to guide packets from their source to their destination.
- HTTP vs HTTPS: Hypertext Transfer Protocol (HTTP) transmits network requests in unencrypted plain text. Hypertext Transfer Protocol Secure (HTTPS) uses Transport Layer Security (TLS) cryptographic protocols to encrypt communication channels, preventing eavesdropping.
The Linux Operating System Command Line Interface (CLI)
Cybersecurity systems, cloud networks, and penetration testing platforms like Kali Linux rely on a text-based command line interface instead of a graphical user interface.
* pwd (Print Working Directory): Outputs the full path of the current working folder.
* ls (List Directory Contents): Displays files inside the current working folder.
* cd (Change Directory): Moves the user into a different directory folder.
* mkdir (Make Directory): Generates a brand-new directory folder.
* echo (Display text line): Prints arguments to the standard output screen.
* cat (Concatenate): Reads file inner text and displays it directly to the terminal.
Teaching Session II: Labs & Interactive Tools (11:45 AM - 01:45 PM)
Practical Interactive Tools for Today
- CodeCombat: Navigate programming levels by typing functional Python loops and variable calls.
- OverTheWire Bandit: Connect via Secure Shell (SSH) and run commands (
ls,cd,cat) to search for text-based authentication keys hidden in files.
Recap & Tomorrow's Horizon (04:15 PM - 04:30 PM)
- Summary: Today we mastered core variables, network routing differences, and basic terminal control commands.
- Tomorrow Preview: We will move from basic technical systems to security management frameworks, examining threats, vulnerability analysis, and the legal limits of hacking.
Your plan for today
6 parts. Press Next to move in order.
- Part 1. Get oriented - 4 slides
- Part 2. Learn the basics - 25 slides
- Part 3. Code along - 1 slide
- Part 4. Play the free tools - 3 slides
- Part 5. Test yourself - 4 slides
- Part 6. Wrap up - 1 slide
PART 1 OF 6
Get oriented
Objectives, key terms, a picture, and the news.
This part is 4 slides. Press Next to begin.
Learning objectives
By the end of today you can: - Explain what Python is and why it is used in cybersecurity. - Use variables, data types, and a loop. - Navigate a Linux terminal and read your first hidden password in OverTheWire Bandit.
Vocabulary (acronyms expanded and defined)
- Python: a popular, easy-to-read programming language (named after the comedy group Monty Python, not the snake).
- CLI = Command Line Interface: a text-only way to control a computer by typing commands.
- OS = Operating System: the software that runs a computer, such as Windows, macOS, or Linux.
- Linux: a free, open-source operating system that runs most web servers, phones (Android), and supercomputers.
- SSH = Secure Shell: a tool to safely log in to another computer over the network.
- IDE = Integrated Development Environment: an app for writing and running code.
- Syntax: the grammar rules of a programming language.
- Variable: a named box that stores a value.
Picture it
YOU type a command -> [ TERMINAL ] -> the computer obeys
ls shows your files
cd Desktop moves into a folder
cat secret.txt prints a file
A loop is like telling a robot: "take a step, repeat 5 times."
In the news (real and verifiable)
Python is consistently ranked among the most popular programming languages in the world in the annual Stack Overflow Developer Survey and the TIOBE index. Security teams love it because you can automate boring tasks in a few lines. Most websites you visit run on Linux servers, which is why learning the terminal is a real career skill.
PART 2 OF 6
Learn the basics
Now go deeper: the core ideas step by step, with quick knowledge checks.
This part is 25 slides. Press Next to begin.
What is Python?
The language of automation
- A popular, easy-to-read programming language.
- Named after the comedy group Monty Python, not the snake.
- Security teams use it to automate tasks in just a few lines.
print("Hello, CyberQuest!")Syntax: the grammar of code
Rules the computer follows
Syntax means the rules a language expects. Python cares about spelling, punctuation, and indentation (spaces at the start of a line).
for step in range(3):
print(step) # indented = inside the loopVariables: labeled boxes
Storing information
A variable stores a value so you can reuse it. = means store the value on the right into the name on the left.
agent_name = "Ada" missions = 3 print(agent_name, missions)
Knowledge check
A variable is best described as...
Data types
The kinds of values
- str (string): text in quotes, like a password.
- int (integer): whole numbers like 42.
- float: decimals like 3.14.
- bool (boolean): True or False.
Knowledge check
What data type is the value 42 ?
Loops repeat work
Do it again, automatically
A loop runs the same block many times. Moving a hero through a maze in CodeCombat is just a loop of steps.
for i in range(5):
print("Mission", i, "ready")Knowledge check
How many times does for i in range(3): repeat?
How Python runs your code
Illustration
Readable code goes in, the interpreter runs it immediately, and you see the result. No slow compile step.
Your first commands
print and comments
The print function shows text. A # starts a comment, a note for humans that Python ignores.
# this is a comment
print("Hello, CyberQuest!")Getting input
Talking to the user
input pauses and waits for the user to type. What it returns is always text (a str).
name = input("Your name: ")
print("Welcome", name)The four data types
Reference table
| Type | Holds | Example |
|---|---|---|
| str | text | "admin" |
| int | whole numbers | 80 |
| float | decimals | 3.14 |
| bool | True or False | True |
Doing math
Arithmetic operators
| Operator | Means | Example |
|---|---|---|
| + - * / | add, subtract, multiply, divide | 7 + 5 is 12 |
** | power | 2 ** 8 is 256 |
| % | remainder | 17 % 5 is 2 |
Knowledge check
What is 2 ** 8 ?
Comparisons and booleans
Asking yes or no questions
Comparisons give a bool. == means equal, != not equal, > greater than, < less than.
print(5 > 3) # True print(5 == 6) # False
Making decisions
The if statement
An if runs code only when a condition is True. else covers the other case.
pw = "sunshine"
if len(pw) < 12:
print("Too short")
else:
print("Good length")How an if statement decides
Illustration
The condition is checked once. Exactly one branch runs.
Lists
Storing many values
A list holds many values in order, written in square brackets.
ports = [22, 80, 443] print(ports[0]) # 22 (first item) print(len(ports)) # 3
Indexing and slicing
Reaching into text and lists
Counting starts at 0. You can grab one item or a range.
word = "flag" print(word[0]) # f print(word[1:3]) # la
A loop, step by step
Illustration
Check, run the block, update the counter, repeat until the condition is false.
While loops
Repeat until a condition changes
A while loop repeats as long as its condition stays True. Be sure something changes, or it never stops.
tries = 0
while tries < 3:
print("attempt", tries)
tries = tries + 1Knowledge check
How many times does for i in range(5) run?
SSH: logging in safely
Illustration
SSH encrypts the whole session, so passwords and commands cannot be read on the network.
Linux commands you will use
Quick reference
| Command | Does |
|---|---|
ls | list files |
cd folder | move into a folder |
pwd | show where you are |
cat file | print a file |
ssh user@host -p 2220 | log in to another computer |
When code breaks
Reading errors
Errors are normal. Python prints the line and the problem. A SyntaxError means a typo in the grammar; a NameError means you used a name that does not exist yet. Read the last line first.
Python functions
Python primer — reusable code blocks
Reusable blocks of code
A function is a named block that runs when you call it. Use def to define it, then call it by name. Functions stop repetition and make code readable.
def greet(name):
message = "Hello, " + name
return message
print(greet("Ada")) # Hello, Ada
Python file I/O
Python primer — reading and writing files
Reading and writing files
open() returns a file object. Use with so the file closes automatically even if an error happens.
# write a file
with open("log.txt", "w") as f:
f.write("scan started\n")
# read it back
with open("log.txt", "r") as f:
print(f.read()) # scan started
| Mode | Meaning |
|---|---|
"r" | read (file must exist) |
"w" | write (overwrites) |
"a" | append (adds to end) |
Knowledge check
What keyword starts a function definition in Python?
The OSI model
A 7-layer map of how data travels
Data travels DOWN the layers when sending, UP when receiving. Each layer adds a header (encapsulation).
What happens when you type a URL?
DNS to TLS in 5 steps
Step 3 (TLS) only happens for HTTPS. Without it, anyone on the same Wi-Fi can read the data.
The Linux filesystem tree
Everything is a file
/ (root, the top of everything) ├── etc/ (configuration files: passwd, hosts) ├── home/ (each user's personal folder) │ └── ada/ ├── var/ (logs, changing data) │ └── log/ ├── tmp/ (temporary files, wiped on reboot) ├── bin/ (basic programs: ls, cat, cp) └── usr/ (installed software)
| Directory | Analogy |
|---|---|
/etc | Settings drawer |
/home | Your bedroom |
/var/log | Security camera recordings |
/tmp | Sticky notes (erased on restart) |
Pipes and redirection
Connecting commands together
The pipe | sends one command's output into another. Redirection > sends output to a file.
# find lines containing "root" in the password database cat /etc/passwd | grep root # save those matches to a file cat /etc/passwd | grep root > found.txt # count how many matches cat /etc/passwd | grep -c "bash"
Numeric: IPv4 address space
How many addresses exist?
An IPv4 address is 4 bytes (32 bits). Total unique addresses:
2^32 = 4,294,967,296 (about 4.3 billion)
A /24 subnet (like your home Wi-Fi 192.168.1.x) gives:
2^8 = 256 total addresses 256 - 2 = 254 usable (subtract network + broadcast)
| Subnet | Host bits | Usable hosts |
|---|---|---|
| /24 | 8 | 254 |
| /16 | 16 | 65,534 |
| /8 | 24 | 16,777,214 |
This is why IPv6 was invented: 4.3 billion addresses ran out with billions of phones and IoT devices online.
Knowledge check
Which OSI layer handles IP addresses and routing?
PART 3 OF 6
Code along
Run Modules 1 to 4 in the notebook.
This part is 1 slide. Press Next to begin.
Code along: open the notebook
Day1.ipynb (upload to Google Colab at colab.research.google.com, or open in Jupyter) and run Modules 1 to 4 with Shift + Enter.The main course deck (Interactive_Slides.html) will also tell you exactly when to run each module. After the notebook, return to the main deck.
PART 4 OF 6
Play the free tools
Practice for real on two free, fun sites.
This part is 3 slides. Press Next to begin.
Play the free tools
Activity 1: CodeCombat (Python through a game)
Open https://codecombat.com/ and start Computer Science 1 (free levels).
1. Create a free account or play as a guest.
2. Move your hero with code like hero.moveRight().
3. When you repeat moves, use a loop, the same idea as the notebook.
Aim to clear the first 5 to 8 levels.
Activity 2: OverTheWire Bandit (Linux terminal levels)
Open https://overthewire.org/wargames/bandit/bandit0.html
- Bandit Level 0: log in with SSH. On Windows use the built-in Terminal or PowerShell; on Mac use Terminal.
- Command: ssh bandit0@bandit.labs.overthewire.org -p 2220
- Password: bandit0
- Bandit Level 0 to 1: read the file named readme.
- Command: cat readme (this prints the password for the next level)
- Commands you will use a lot: ls (list files), cd (change directory), cat (print a file), pwd (where am I).
Write each password you find in a safe note so you can keep climbing.
PART 5 OF 6
Test yourself
Numericals, multiple choice, and the knowledge bank. Answer key included.
This part is 4 slides. Press Next to begin.
Numericals (do these in the notebook)
- How many times does
for i in range(7):repeat? - What is
2 ** 10(two to the power ten)? - What is
25 % 4(the remainder)?
Multiple choice (MCQ)
- A variable is best described as: a) a type of virus b) a named box that stores a value c) a website
- Which command prints the contents of a file in Linux?
a)
catb)runc)open - SSH stands for: a) Super Secure Hardware b) Secure Shell c) System Service Host
Knowledge Evaluation Bank (Embedded Assessments)
Multiple-Choice Questions (MCQ)
-
An analyst intercepts network traffic and reads user passwords in plain text. What unencrypted protocol was the target web application using?
- A) HTTPS
- B) HTTP
- C) SSH
- Answer Key: B. HTTP transmits payloads without cryptographic protection layers.
-
Which Linux CLI command displays the contents of a text file on the terminal screen?
- A) mkdir
- B) pwd
- C) cat
- Answer Key: C.
catreads and outputs file contents to standard output.
Numerical Exercise
A network router receives an unfragmented IP packet with a total payload of 4,500 bytes. The path MTU is 1,500 bytes, but each IPv4 fragment must carry a 20-byte IP header, leaving 1,480 bytes of usable data per fragment. Calculate the minimum number of fragments the router must produce. * Solution Step: Usable payload = 1,500 - 20 = 1,480 bytes/fragment. Fragments = 4,500 / 1,480 = 3.04, rounded up = 4 fragments.
Answer key
Answer key. Numericals: 1) 7 times, 2) 1024, 3) 1. MCQ: 1-b, 2-a, 3-b.
PART 6 OF 6
Wrap up
Recap what you learned and reflect.
This part is 1 slide. Press Next to begin.
Reflection and homework
Write two sentences: what does a loop in code have in common with a maze in CodeCombat? Try one more Bandit level at home if you want a head start.