Day 1:How Computers, Operating Systems & The Terminal Actually Work
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Week 1 — Day 1: How Computers, Operating Systems & The Terminal Actually Work
Mentor's Note (10+ YOE Staff AI Engineer POV): Why do we start an AI Engineering curriculum with CPU, RAM, Disk, Environment Variables, and Terminal Commands?
- For Complete Beginners: If you don't know where your files live on your hard drive, what
cd ..means, or why an error says'python' is not recognized as an internal or external command, you will feel stuck every single day. Today removes that fear forever.- For Senior AI Engineer Interviews: When an interviewer asks: "Our 8-Billion parameter LLM crashes with an Out-Of-Memory (OOM) error on startup—explain the difference between Disk storage, System RAM, and GPU VRAM, and how processes load model weights," your answer comes directly from today's lesson!
Part 1: How a Computer Actually Runs AI Programs (Hardware & OS)
Whenever you run a Python script or an AI model, four hardware components work together under the supervision of your Operating System (Windows, macOS, or Linux):
+-----------------------------------------------------------------------+
| OPERATING SYSTEM (Windows / Linux / macOS) |
| |
| +------------------+ Loads into +-------------------------+ |
| | DISK (SSD) | ================> | RAM (Memory) | |
| | Permanent Files | | Fast Temporary Workspace| |
| | - script.py | | - Running Python Process| |
| | - model.safetensors (16 GB) | - Active Variables/Data | |
| +------------------+ +------------+------------+ |
| | |
| Processes | |
| Instructions v |
| +----------------------------------------------------+------------+ |
| | CPU (Central Processing Unit) vs GPU (Graphics/AI Processor) | |
| | - 8 to 32 Smart Cores - 5,000+ Tiny Math Cores | |
| | - Great for Sequential Logic, - Built for Massive Matrix | |
| | Web Servers, File I/O, SQL Multiplication (LLMs/DL) | |
| +-----------------------------------------------------------------+ |
+-----------------------------------------------------------------------+
1.1 The 4 Hardware Pillars Explained Simply
| Component | Real-World Analogy | Speed & Volatility | Role in AI Engineering |
|---|---|---|---|
| 1. Disk (SSD / NVMe) | The Filing Cabinet / Warehouse | Slowest (~3–7 GB/s). Permanent (keeps files when power is off). | Stores your .py files, SQLite/Postgres databases, and downloaded LLM weight files (.gguf, .safetensors). |
| 2. RAM (Random Access Memory) | Your Office Desk | Very Fast (~50–100 GB/s). Temporary/Volatile (wiped clean when power turns off or script exits!). | Every variable (x = [1, 2, 3]), Pandas DataFrame, or in-memory Vector Index (HNSW) lives in RAM while your Python script is running. |
| 3. CPU (Central Processing Unit) | A Brilliant Professor (8–16 cores) | Executes complex if/else branching, network calls, and OS tasks one step after another. | Runs your Python interpreter, FastAPI web server, JSON validation (Pydantic), and database queries. |
| 4. GPU + VRAM (Graphics Processing Unit) | An Army of 10,000 Calculators | Ultra-Fast Memory Bandwidth (~500–3,000 GB/s). Has its own dedicated memory called VRAM. | Neural networks and LLMs are giant matrix multiplications (). GPUs calculate thousands of matrix numbers simultaneously! |
[!IMPORTANT] Senior Interview Golden Rule: A CPU cannot directly compute on data sitting on your SSD Disk! First, the Operating System reads the file from Disk RAM (or VRAM for GPUs), and then the CPU/GPU processes it. If you try to load a 32 GB dataset or model into 16 GB of RAM all at once, your program crashes with
MemoryErrororOOMKilled!
Part 2: Processes, Environment Variables & The PATH
2.1 What is a Process?
- A Program (
python.exeorscript.py) is just a dead recipe sitting on your Disk. - A Process is a live, running instance of that program in RAM, assigned a unique PID (Process ID) by the Operating System.
- Every process gets its own isolated box of RAM and its own Environment Variables (a dictionary of key-value text settings like
USER,PATH, orLLM_API_KEY).
2.2 What is the PATH Environment Variable? (Why 'python' is not recognized happens!)
When you type python or git in your terminal and press Enter, how does your computer know where python.exe is hidden among 500,000 files on your hard drive?
It checks an Environment Variable called PATH!
PATHis simply a list of folder paths separated by;(on Windows) or:(on macOS/Linux).- The terminal checks Folder #1 in
PATH, then Folder #2, then Folder #3... until it findspython.exe. - If
python.exeis not in any folder listed inPATH, the terminal throws:python: The term 'python' is not recognized...(Windows) orcommand not found: python(macOS/Linux).
Part 3: Complete Terminal Command Cheat Sheet (PowerShell & Bash)
As an AI Engineer, you will work on Windows (PowerShell) locally and Linux (Bash) inside Docker containers and cloud servers. Here are the essential commands in both:
| Goal | Windows PowerShell | Linux / macOS Bash (and works as alias in PowerShell!) | Explanation |
|---|---|---|---|
| Where am I right now? | Get-Location or pwd | pwd | Prints the Print Working Directory (e.g., D:\Spark\AI_Engineer). |
| List files in current folder | Get-ChildItem or ls or dir | ls -la | Shows all files and folders in your current directory. |
| Move into a folder | cd folder_name | cd folder_name | Change Directory into folder_name. |
| Move UP one parent folder | cd .. | cd .. | . means "current folder", .. means "parent folder". |
| Go to home directory | cd ~ | cd ~ | ~ is a shortcut for your user home folder (C:\Users\YourName). |
| Create a new folder | mkdir my_folder | mkdir -p my_folder | Make Directory. |
| Create an empty file | New-Item test.txt | touch test.txt | Creates a blank file named test.txt. |
| Read a file's contents | Get-Content file.md or cat file.md | cat file.md | Prints the text inside file.md to the terminal screen. |
| Copy a file | cp source.txt dest.txt | cp source.txt dest.txt | Copies source.txt to dest.txt. |
| Move or Rename a file | mv old.txt new.txt | mv old.txt new.txt | Moves or renames a file. |
| Delete a file | rm test.txt | rm test.txt | Warning: Terminal rm deletes permanently (bypasses Recycle Bin!). |
| Find where a command lives | Get-Command python or where.exe python | which python | Shows the exact file path of the python executable in your PATH. |
| Print an Environment Variable | $env:PATH | echo $PATH | Displays the value of an environment variable. |
| Set a temporary Env Variable | $env:MY_VAR="hello" | export MY_VAR="hello" | Sets an environment variable for the current terminal session only. |
Redirect output to a file (>) | python script.py > output.log | python script.py > output.log | Overwrites output.log with the script's printed output (>> appends!). |
Pipe output to another command (|) | cat app.log | Select-String "ERROR" | cat app.log | grep "ERROR" | Sends the output of Command 1 as the input to Command 2! |
Part 4: Hands-On Lab — Running Our First Diagnostic Script (sys_inspector.py)
We have written a real-world Python diagnostic utility in src/sys_inspector.py (in Tab 2: Codes — click Run in Browser to execute) that inspects your Operating System, CPU cores, Python runtime, current working directory, PATH entries, and safely masks secret API keys (like sk-proj-... or AIzaSy...) so they never leak in terminal logs!
Step-by-Step Commands to Run:
- Check your current directory:
powershell
pwd - Run the Day 1 System Inspector script:
powershell
python week01_computer_terminal_git_python_basics/day01_how_computers_os_terminal_work/src/sys_inspector.py - Run the Day 1 Automated Tests:
powershell
python -m unittest discover -s week01_computer_terminal_git_python_basics/day01_how_computers_os_terminal_work/tests -v
Part 5: Day 1 Summary & Key Takeaways
- Disk is permanent storage; RAM is fast volatile workspace; CPU handles sequential logic/servers; GPU (VRAM) handles parallel matrix math for AI.
- Every running script is an OS Process with a PID and isolated Environment Variables.
- Never print raw API keys to terminal logs—always mask secrets (
mask_secret("AIzaSy123456789")"AIza***6789"). - Check out Tab 3: Interview Questions to test yourself on the exact questions interviewers ask about OS, memory, and environment variables!