Skip to main content

🌐 Network & Operating Systems

"Understanding the infrastructure helps you build better applications."

Networks and operating systems form the foundation that all applications run on. Knowledge here helps debug complex issues and optimize performance.


🔗 Network Protocols

TCP/IP Stack

TCP Three-Way Handshake

TCP vs UDP

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryBest effort
OrderingMaintainedNot guaranteed
SpeedSlower (overhead)Faster
Use CaseHTTP, FTP, EmailDNS, Video streaming, Gaming

HTTP/HTTPS

VersionFeatures
HTTP/1.1Persistent connections, pipelining
HTTP/2Multiplexing, header compression, server push
HTTP/3QUIC (UDP-based), reduced latency
HTTPS = HTTP + TLS/SSL
- Encrypts data in transit
- Verifies server identity
- Prevents man-in-the-middle attacks

🐧 Linux Essentials

Essential Commands

CategoryCommands
File Systemls, cd, cp, mv, rm, find, grep
Processps, top, htop, kill, nohup, &
Networknetstat, ss, curl, wget, ping, traceroute
Diskdf, du, mount, lsblk
Systemsystemctl, journalctl, dmesg

Process Management

# View all processes
ps aux | grep java

# Real-time process monitoring
top -u $(whoami)

# Run in background
nohup java -jar app.jar > app.log 2>&1 &

# View open files/ports by process
lsof -i :8080
lsof -p <pid>

# Network connections
ss -tlnp # TCP listening ports
netstat -an | grep ESTABLISHED

File Permissions

# Format: rwx rwx rwx
# user group others

chmod 755 script.sh # rwxr-xr-x
chmod 600 secret.key # rw-------

# Ownership
chown user:group file

💾 Memory & Process

Process States

Memory Concepts

ConceptDescription
Virtual MemoryAbstraction over physical memory
PagingFixed-size memory blocks
Page FaultAccessing memory not in RAM
SwapUsing disk as extended memory
Memory-mapped I/OFile access via memory addresses

Concurrency Primitives

PrimitiveDescriptionUse Case
MutexMutual exclusion lockCritical sections
SemaphoreCounting resource accessResource pools
Condition VariableWait for conditionProducer-consumer
Read-Write LockMultiple readers, single writerRead-heavy scenarios

📝 Detailed Topics


🔧 Debugging Toolkit

# Network debugging
tcpdump -i eth0 port 80 # Capture HTTP traffic
curl -v https://api.example.com # Verbose HTTP request
dig example.com # DNS lookup

# System debugging
strace -p <pid> # Trace system calls
vmstat 1 # Virtual memory stats
iostat -x 1 # I/O statistics

# Log analysis
tail -f /var/log/syslog # Follow system logs
journalctl -u nginx -f # Follow service logs

Key Takeaways
  1. TCP for reliability, UDP for speed
  2. HTTPS should be default for all web traffic
  3. Master grep, awk, sed for log analysis
  4. Understand process states for debugging hangs
  5. Use strace when all else fails