Computer Basics — How Machines Really Work
What you'll learn
- What actually happens inside a computer (CPU, RAM, storage)
- Why everything is 1s and 0s (binary) — and you'll convert some yourself
- Hexadecimal — the shorthand security tools use for everything from hashes to file signatures
- What an operating system does
- The words every security professional uses daily
Security is about protecting computers, so first you must understand what a computer is.
The kitchen analogy 🍳
A computer is like a kitchen:
- CPU (processor) = the chef. Does all the actual work, one step at a time — but incredibly fast (billions of steps per second).
- RAM (memory) = the countertop. Fast workspace for what you're cooking right now. Turn off the power and it's wiped clean.
- Storage (SSD/hard drive) = the fridge/pantry. Keeps things permanently, even when off — but slower to reach than the countertop.
- Operating System (Windows, Linux, macOS) = the kitchen manager. Decides who uses the chef, how the countertop is shared, and who's allowed in.
Why binary? A computer is millions of tiny switches. A switch is either ON (1) or OFF (0). That's it. Every photo, song, and password is ultimately a huge pattern of ON/OFF switches. We group 8 switches into a byte, and a byte can represent one letter.
Counting in binary is just like normal counting, but with only two digits (0 and 1) instead of ten:
Decimal: 0 1 2 3 4 5 6 7 8
Binary: 0 1 10 11 100 101 110 111 1000
Each position is a power of 2: …, 8, 4, 2, 1. So 101 = 4 + 0 + 1 = 5.
Run this Python (the environment loads the first time — ~10 seconds). bin() shows the switches, int(x, 2) reads them back. Change the number and re-run.
# Python can convert between decimal and binary instantly
number = 5
print("5 in binary is:", bin(number)) # 0b101
# and back again
print("Binary 1010 is:", int("1010", 2)) # 10
# a byte holds 8 bits -> values 0 to 255
print("Max value of one byte:", 2**8 - 1) # 255Write Python that:
- Stores your age in a variable
age - Prints its binary form using
bin(age) - Prints how many bytes it takes to store the number 300 as a variable
bytes_needed— hint: one byte holds up to 255, so 300 needs 2.
Hexadecimal — binary's shorthand 🔢
Binary is precise but painfully long — a single byte is 8 characters (11010110). Security tools almost never show you raw binary; they show hexadecimal (base 16) instead, because 2 hex digits pack exactly one byte:
Binary: 11010110 → Hex: D6
Hex uses 16 symbols: 0-9 then A-F (where A=10, B=11, … F=15). You'll recognize hex everywhere in security work:
- MAC addresses:
3C:A6:F6:1E:2B:9D— each pair is one byte in hex - File signatures ("magic bytes"): every file type starts with a fixed hex pattern regardless of its extension — a JPEG always starts
FF D8 FF, a PDF starts25 50 44 46. Malware analysts rename suspicious files and check these bytes, because an attacker can label a program "photo.jpg" but can't hide its true magic bytes. - Hashes (like MD5, SHA-256) are always displayed as long hex strings.
- Colors in web design (
#FF5733) are hex too — same system, different use.
Python converts to hex just as easily as binary:
print(hex(214)) # '0xd6'
print(int("d6", 16)) # 214
Write Python that:
- Converts the number
255to hex and stores the string result inhex_value - Converts the hex string
"ff"back to a decimal number, stored indecimal_value
(Use hex(x) and int(x, 16) — the same pattern you used for binary.)
Question 1 of 6
Which part loses its contents when the power goes off?
Question 2 of 6
What is the decimal value of binary 110?
Question 3 of 6
How many bits are in one byte?
Question 4 of 6
What does the operating system do?
Question 5 of 6
Why do security tools display data in hex instead of raw binary?
Question 6 of 6
Why do malware analysts check a file's 'magic bytes' instead of trusting its file extension?
Summary
- CPU = chef, RAM = countertop (volatile), Storage = pantry (permanent), OS = manager
- Everything is binary: switches grouped into bytes (8 bits = 1 character)
- Hexadecimal is binary's compact shorthand — used in MAC addresses, hashes, and file signatures
- You converted numbers with Python's
bin()/int(x, 2)andhex()/int(x, 16)
Next: Networking — how these computers talk to each other, and where attackers try to listen in.
Practice
Reading is not learning until you run something. Pick one.