FOUNDATIONS: ZERO TO OPERATOR
Operating systems · Linux command line · Networking · The web · Windows · Security concepts · Safe labs & the law · Learning paths
How Computers and Operating Systems Work
- A computer is a CPU executing instructions on data held in memory; storage keeps data when the power is off, RAM does not.
- The kernel is the privileged core of the OS. Programs run in user space and must ask the kernel, through system calls, to touch hardware, files or the network.
- A process is a running program with its own virtual memory, a PID, an owner and a set of open files. Threads share one process's memory.
- Every process runs as some user, and that user's identity decides what it may read, write and execute. Root (UID 0) on Linux and SYSTEM on Windows sit above normal checks.
- Most attacks are about changing which user your code runs as, or reaching memory and files you were never meant to see. Understanding this model is the foundation for everything else.
- What a CPU, RAM and storage each do — and why it matters to an attacker
- What an operating system and its kernel actually manage
- What a system call is — the single gate between your program and the hardware
- How processes, memory and files work, and where attacks hide inside them
- The user and permission model — the lock-and-key system behind every hack and every defence
► Why Start Here
Every hack is just a computer doing exactly what it was told. Attackers win when they understand the machine better than the people who set it up. So before any tool, get the mental model: what a computer is, what the OS does, and how it decides who is allowed to do what.
► The Hardware in Plain Terms
Think of a computer as a kitchen. The CPU (Central Processing Unit) is the chef: it can only do simple things, such as add two numbers, compare them, copy a value from one place to another, or jump to a different instruction, but it does billions of them per second. Each simple operation is an instruction, and a program is just a long list of instructions. A modern CPU has several cores, which are independent chefs working in parallel, and each core holds a handful of tiny, ultra-fast storage slots called registers. One register, the instruction pointer, always holds the address of the next instruction to run. Remember that: much of exploit development (MOD-04) is about seizing control of that one register.
RAM (Random Access Memory) is the kitchen counter. It is fast, the chef can reach anything on it instantly, and it is wiped clean when the power goes off. Storage (an SSD or hard disk) is the pantry: much larger, much slower, and it keeps its contents without power. When you open a program, its instructions are copied from storage into RAM so the CPU can run them. Between the CPU and RAM sit several layers of cache, small pockets of very fast memory that keep recently used data close to the chef. Attacks such as Spectre and Meltdown abused the way caches and speculative execution leak timing information, so even these details matter to security.
| Component | Analogy | Speed | Survives Power Off? | Security Relevance |
|---|---|---|---|---|
| CPU registers | The chef's hands | Fastest | No | Hijacking the instruction pointer = code execution |
| CPU cache | Spice rack beside the stove | Very fast | No | Side-channel attacks (Spectre, Meltdown) |
| RAM | The counter | Fast | No | Holds passwords, keys, tokens while in use; memory forensics |
| SSD / HDD | The pantry | Slow | Yes | Files, logs, deleted-data recovery, disk forensics |
Think of RAM like the cash in a duka's till during the day: fast to reach, but counted out and emptied every closing time. Storage is the owner's bank account — slower to get to, but your money is still there tomorrow. Opening an app just carries it from the "bank" (storage) to the "till" (RAM) so the CPU can work fast. Cut the power and RAM vanishes like the till at closing — which is exactly why investigators rush to capture a machine's memory while it is still on (MOD-18).
► What an Operating System Does
Hardware on its own is useless to a normal program. A web browser does not know how to talk to a specific Wi-Fi chip or a specific SSD controller, and it should not have to. The operating system (OS) is the software layer that manages hardware and offers programs a clean, consistent interface to it. Linux, Windows, macOS, Android and iOS are all operating systems.
The heart of the OS is the kernel. The kernel runs in a privileged CPU mode (often called ring 0 or kernel mode) where it can touch any memory and any device. Everything else, including your browser, your shell and even most system tools, runs in user space (ring 3), where the CPU itself blocks direct hardware access. When a user-space program wants to open a file, send a network packet or start another program, it must politely ask the kernel through a system call (syscall). The kernel checks whether the request is allowed, does the work, and returns the result. This boundary is the single most important security wall in a computer: a bug that lets user code run inside the kernel gives the attacker total control.
+-----------------------------------------------------------+ | USER SPACE (ring 3) | | bash firefox sshd python3 nginx | | | | | | | | | +--------+---- system calls ---------+ | | (open, read, write, execve, socket ...) | +-----------------------------------------------------------+ | KERNEL SPACE (ring 0) | | process scheduler memory manager file systems | | network stack device drivers security checks | +-----------------------------------------------------------+ | HARDWARE | | CPU cores RAM SSD network card USB | +-----------------------------------------------------------+
Here is a peek under the hood. Do not worry about the exact text — you are not expected to type any of this yet. Just look at it the way you would watch a mechanic open an engine: you are seeing that a conversation happens, not memorising the parts.
► Processes, Threads and Virtual Memory
A program is a file on disk; a process is that program actually running. Same recipe, different meals.
- PID — every process has a unique Process ID. Open three terminals and you get three bash processes from one file
- Owner — every process runs as some user, and that decides what it may touch
- Thread — a separate line of work inside a process; threads share memory (fast, but one can corrupt the others)
- Virtual memory — each process thinks it owns all the RAM; the kernel keeps them walled off from one another
- Stack / heap / code — the regions of a process's memory. Overwrite the stack's saved return address and you control where the CPU jumps next — that one sentence is the whole classic buffer overflow (MOD-04)
- Dumping another process's memory (e.g. Windows LSASS, MOD-05) needs high privilege: you must ask the kernel to break the wall for you
A matatu route — say Route 46 to Ng'ando — is the program: the plan, written down. A specific matatu actually plying that route right now is the process. Ten matatus can run Route 46 at once, just like ten processes run from one program file — each with its own passengers (memory) and its own conductor deciding who boards (the user it runs as). Forcing your way onto someone else's matatu to see their passengers is memory dumping; the kernel is the traffic marshal who normally won't allow it.
► Files and File Systems
A file system is the scheme the OS uses to organise data on storage into named files and folders (directories). Linux commonly uses ext4, XFS or Btrfs; Windows uses NTFS; macOS uses APFS. Underneath the names, a file system keeps metadata about every file: its size, owner, permissions, and timestamps for when it was created, modified and accessed. On Linux each file is described by an inode, a record holding that metadata and pointers to the data blocks.
Linux follows a famous design idea: everything is a file. Ordinary documents are files, but so are devices (your disk is /dev/sda or /dev/nvme0n1), kernel information (/proc and /sys), and even network connections, which a process holds through numbered handles called file descriptors. Descriptors 0, 1 and 2 are always standard input, standard output and standard error. This uniformity is powerful: the same small tools that read text files can read process details or device information, which is why the command line (next chapter) is so effective.
► Users and the Permission Model
An OS is a shared building; the permission model is its lock-and-key system.
- User account — every person or service has one, identified by a number: UID on Linux, SID on Windows
- Groups — bundle users so you can grant access to many at once
- Every process runs as a user; every file is owned by a user and group
- On each access the kernel checks identity against the file's permissions and allows or denies — millions of times a day
- Super-user skips most checks:
root(UID 0) on Linux; Administrator and the even-higher SYSTEM account on Windows - Services run as low-privilege accounts (like
www-data) so a hacked service only hands over limited rights
Picture a plot (apartment block). Each tenant has a key to their own door only — that is a user and their permissions. The caretaker holds a master key to the shared areas — a group privilege. The landlord has every key and answers to no one — that is root / SYSTEM. Nearly every attack in the later modules is one quiet move: a tenant trying to become the landlord.
| Concept | Linux | Windows |
|---|---|---|
| User identifier | UID (number, root = 0) | SID (e.g. S-1-5-21-...-1001) |
| Super-user | root | Administrator, and above it SYSTEM |
| Account database | /etc/passwd and /etc/shadow | SAM registry hive (local), Active Directory (domain) |
| Typical service account | www-data, mysql, nobody | LocalService, NetworkService, virtual service accounts |
| Run one command as admin | sudo | Run as administrator (UAC prompt) |
| Kernel | Linux kernel (monolithic, modules) | NT kernel (ntoskrnl.exe) |
► How This Maps to Attacks
With just this model, you can already describe most of offensive security — one line each:
- Initial access — get your code running as some user on the target
- Privilege escalation — climb from a low user (like
www-data) to root/SYSTEM via a misconfig or kernel bug - Credential access — read secrets from files or memory you should not reach
- Persistence — arrange to run again after a reboot (for example, as a service)
- Defenders watch processes, files, users and syscalls for exactly these moves — every later module goes deep on one
- A computer is a CPU executing instructions on data held in memory; storage keeps data when the power is off, RAM does not.
- The kernel is the privileged core of the OS. Programs run in user space and must ask the kernel, through system calls, to touch hardware, files or the network.
- A process is a running program with its own virtual memory, a PID, an owner and a set of open files. Threads share one process's memory.
- Every process runs as some user, and that user's identity decides what it may read, write and execute. Root (UID 0) on Linux and SYSTEM on Windows sit above normal checks.
- Most attacks are about changing which user your code runs as, or reaching memory and files you were never meant to see. Understanding this model is the foundation for everything else.