Week 1 • Day 1100% FREE

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?

  1. 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.
  2. 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):

text
+-----------------------------------------------------------------------+ | 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

ComponentReal-World AnalogySpeed & VolatilityRole in AI Engineering
1. Disk (SSD / NVMe)The Filing Cabinet / WarehouseSlowest (~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 DeskVery 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 CalculatorsUltra-Fast Memory Bandwidth (~500–3,000 GB/s). Has its own dedicated memory called VRAM.Neural networks and LLMs are giant matrix multiplications (Y=W⋅X+bY = W \cdot X + b). 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 →\rightarrow 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 MemoryError or OOMKilled!


Part 2: Processes, Environment Variables & The PATH

2.1 What is a Process?

  • A Program (python.exe or script.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, or LLM_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!

  • PATH is 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 finds python.exe.
  • If python.exe is not in any folder listed in PATH, the terminal throws: python: The term 'python' is not recognized... (Windows) or command 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:

GoalWindows PowerShellLinux / macOS Bash (and works as alias in PowerShell!)Explanation
Where am I right now?Get-Location or pwdpwdPrints the Print Working Directory (e.g., D:\Spark\AI_Engineer).
List files in current folderGet-ChildItem or ls or dirls -laShows all files and folders in your current directory.
Move into a foldercd folder_namecd folder_nameChange Directory into folder_name.
Move UP one parent foldercd ..cd ... means "current folder", .. means "parent folder".
Go to home directorycd ~cd ~~ is a shortcut for your user home folder (C:\Users\YourName).
Create a new foldermkdir my_foldermkdir -p my_folderMake Directory.
Create an empty fileNew-Item test.txttouch test.txtCreates a blank file named test.txt.
Read a file's contentsGet-Content file.md or cat file.mdcat file.mdPrints the text inside file.md to the terminal screen.
Copy a filecp source.txt dest.txtcp source.txt dest.txtCopies source.txt to dest.txt.
Move or Rename a filemv old.txt new.txtmv old.txt new.txtMoves or renames a file.
Delete a filerm test.txtrm test.txtWarning: Terminal rm deletes permanently (bypasses Recycle Bin!).
Find where a command livesGet-Command python or where.exe pythonwhich pythonShows the exact file path of the python executable in your PATH.
Print an Environment Variable$env:PATHecho $PATHDisplays 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.logpython script.py > output.logOverwrites 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:

  1. Check your current directory:
    powershell
    pwd
  2. 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
  3. 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

  1. Disk is permanent storage; RAM is fast volatile workspace; CPU handles sequential logic/servers; GPU (VRAM) handles parallel matrix math for AI.
  2. Every running script is an OS Process with a PID and isolated Environment Variables.
  3. Never print raw API keys to terminal logs—always mask secrets (mask_secret("AIzaSy123456789") →\rightarrow "AIza***6789").
  4. Check out Tab 3: Interview Questions to test yourself on the exact questions interviewers ask about OS, memory, and environment variables!
Become an AI Engineer — 24-Week (6-Month) Zero-to-Production Roadmap (2026-2027) · DataArena