How to explain to students
Start by asking: "When you visit Netflix, GitHub, or Google — what OS do you think is running those servers?" The answer is almost always Linux. Explain that over 96% of web servers run Linux. DevOps is about automating those servers, so Linux is non-negotiable.
Use the analogy: "Windows is like an automatic car. Linux is a manual — harder to learn, but gives you full control over every gear."
Practical: Inspecting a real server
When you SSH into a fresh cloud VM (AWS EC2, DigitalOcean, GCP), these are the first commands every DevOps engineer runs to "check the vitals".
🎯 Practice Questions
uname -a on your machine. Identify the kernel version, machine hardware architecture, and operating system from the single line of output.PRETTY_NAME line from it.Show Answer
/etc/os-release. To extract just the pretty name:grep PRETTY_NAME /etc/os-releaseOr to strip the variable name and quotes:
. /etc/os-release && echo "$PRETTY_NAME"
How to explain to students
Compare the terminal to a GPS for your computer. pwd is "where am I?", ls is "what's around me?", and cd is "go there". Give students a real folder structure to navigate.
Live demo: Create a fake project structure on screen and let students replicate it. Nothing teaches mkdir and cp faster than actually using them.
Practical: Finding and inspecting files like a DevOps engineer
In production you almost never cd blindly — you find, grep, and tail your way to the answer. These four commands solve 80% of "where is X?" and "what's happening right now?" questions.
🎯 Practice Questions
find to locate every .conf file under /etc that was modified in the last 7 days. Show the command.cd - do? Try it after navigating between two different directories — describe what you observe./var/log/syslog and follow new lines as they arrive. Write the exact one-line command.Show Answer
tail -n 50 -f /var/log/syslog-n 50 sets how many existing lines to print first; -f ("follow") keeps the file open and streams new lines as they're appended. Press Ctrl+C to stop.
project/{src,test,docs,config} in a single mkdir command (no loops, no semicolons)..log files from the current directory into an archive/ folder while preserving their original modification timestamps. Why might preserving timestamps matter for an audit log?mv already preserves mtime — but think about what changes if you used cp instead./var, sorted from biggest to smallest, in human-readable form.How to explain permissions
Use the apartment analogy: A file is an apartment. The owner has a key. The group is like the floor — neighbors with shared access. Others are strangers. Permissions (rwx) decide what each can do.
Teach chmod with the numeric system. It clicks instantly once students see 7 = 4+2+1 = read+write+execute.
sudo or docker.sudo = one command as root. su = switch user entirely. Prefer sudo.Practical: Real EC2 SSH workflow + troubleshooting
This is the exact sequence used to connect to an AWS EC2 instance — including the most common error beginners hit and how to fix it.
🎯 Practice Questions
deploy.sh so the owner can read/write/execute, the group can read/execute, and others have no access. What is the numeric permission and the chmod command?0644? What is the minimum fix?Show Answer
0644 is "world-readable" — anyone can copy the key. SSH refuses to load it as a security measure.Fix:
chmod 600 ~/.ssh/id_ed25519 (owner read/write only). The parent ~/.ssh folder must also be 700.
deploy to the docker group so they can run docker without sudo, then verify the change. What two commands do you run?t in drwxrwxrwt on /tmp) does. What problem would exist on a multi-user server without it?chmod -R 777 /var/www/html "to fix a permissions error." List three concrete reasons this is dangerous in production.How to explain to students
Compare apt to the App Store — but for the terminal, and way faster. Ask students: "Imagine installing Photoshop just by typing one command." That's what package managers do.
Emphasize that in DevOps, servers must be kept updated for security. Outdated packages are a top cause of breaches. apt upgrade is like pressing "Update All" on your phone.
Practical: Installing Docker from the official repository
Most production tools (Docker, Node.js, Postgres, Kubernetes) are not in the default Ubuntu repos — or the version there is too old. The standard pattern is: add GPG key → add repo → update → install. Memorise this flow once and you can install almost anything.
🎯 Practice Questions
apt update before apt install? What concretely goes wrong if you skip it?Show Answer
apt update refreshes the local package index — the list of "what packages and what versions exist in each configured repo."If you skip it: apt may try to install a version that has since been removed from the mirror (404), or quietly install an older, vulnerable version because it doesn't know a newer one is available. After adding a new repo (like Docker's),
apt update is mandatory — without it, apt has no idea the new repo's packages exist.
dig command is missing. Find which package provides it (without Googling).apt-file or the command apt search can both help.apt remove pkg and apt purge pkg? Give a real scenario where you'd choose each./boot fills up because old kernels keep accumulating. Which single command removes packages that are no longer needed?How to explain to students
Tell students: "Every time you do something more than twice in the terminal, write a script." Scripts are just saved commands. Start with a simple "Hello, World" script, then build up to variables, if-else, and loops.
The shebang line #!/bin/bash is magic — explain it tells the OS which interpreter to use. Without it, the script might not run.
"$VAR" not $VAR to avoid word-splitting bugs with spaces.set -x at the top to print each command as it runs — great for debugging.set -e to stop the script immediately if any command fails.Practical: A real "git pull and restart" deploy script
Many startups still deploy to a single VM with a script like this. It's small, real, and battle-tested — it pulls the latest code, installs dependencies, restarts the service, and reports status.
🎯 Practice Questions
.log files exist under /var/log recursively (including subdirectories)."$@" and "$*" in a bash script? Show a 3-line script that demonstrates the difference../args.sh foo bar prints 1: foo and 2: bar.Show Answer
#!/bin/bashi=1for arg in "$@"; doecho "$i: $arg"((i++))doneThe quoting
"$@" matters — it preserves arguments that contain spaces. $@ without quotes would split "hello world" into two iterations.
set -euo pipefail. Explain in one line each what -e, -u, and -o pipefail protect against.log() that prefixes every message with the current ISO-8601 timestamp and writes to both stdout and /var/log/myscript.log in a single call.tee -a command can split a stream to a file and the terminal at the same time.npm ci --omit=dev. Why npm ci instead of npm install in a deployment context?How to explain to students
Teach students that AI is a force multiplier, not a replacement. The goal is to know enough Linux to verify and modify what AI generates. Bad prompt = bad script. Good prompt = great starting point.
Show a before/after: a vague prompt gives a generic script, a detailed prompt gives a production-ready one. Teach students to always read, test, and understand AI output before running it on a server.
Practical: Using AI to analyse a real log file
A common DevOps task: "Why did the API spike at 2am last night?" Instead of grepping by hand, you can paste a log snippet to AI and ask it to summarise. The trick is in the framing.
🎯 Practice Questions
Show Answer
Rule: always replace secrets with placeholders like
<DB_URL> or <API_KEY> in your prompt, then substitute the real value locally before running the script.
eval $USER_INPUT. Should you ship it? Why or why not?How to explain to students
This is where everything comes together. Walk through the script line by line before asking students to build it. Emphasize: this is the kind of script that runs on real production servers at companies like Amazon and Netflix.
crontab -e and schedule this script every 5 minutes automatically.logrotate — logs need to be rotated or they fill the disk you're monitoring!Practical: Extending the monitor with CPU + memory checks
Once disk monitoring works, students should layer on CPU and memory checks. Same shape, different commands. This is the modular pattern real observability scripts use — one function per metric.
🎯 Practice Questions
disk_monitor.sh to also report which mount point is the culprit when usage is over the threshold. df can show all mounts — adapt the parsing.tee -a "$LOG_FILE" instead of >> "$LOG_FILE"? Both append. What does tee give you that >> doesn't?*/5 * * * *. Write the new cron expression.Show Answer
0 9 * * 1-5 /usr/local/bin/disk_monitor.shField-by-field:
0 minute, 9 hour, * any day-of-month, * any month, 1-5 Monday through Friday. Use crontab.guru to sanity-check expressions.
/var/log/disk_monitor.log using logrotate. Where does the config file live, and what's the minimum set of directives you need (rotate count, frequency, compression)?$PATH, the working directory, and where stdout goes when there's no terminal.Sample quiz questions (interactive)
chmod 644 file.txt mean?set -e do in a bash script?Fill-in-the-command
script.sh executable by the owner only?How to explain to students
Frame this as a real job task: "Your manager asks you to set up an automated nightly backup for the /var/www/html folder. It must log success or failure. You have 24 hours." This mirrors what junior DevOps engineers actually do in their first week.
📋 Assignment Requirements
- Accept a source folder as a script argument (e.g.,
./backup.sh /var/www/html) - Create a timestamped
.tar.gzbackup in/backups/directory - Log success or failure with timestamps to
/var/log/backup.log - Handle edge cases: source not found, backup dir doesn't exist, disk full
- Use functions, variables, and proper error handling (
set -e) - Bonus: Delete backups older than 7 days automatically
- Bonus: Send an email alert on failure
🎯 Practice Questions (Stretch)
rsync --link-dest. Why is this dramatically more space-efficient than full .tar.gz snapshots?aws s3 cp). What permissions must the EC2 instance role have?cron. Write the full crontab line and the path you'd put it under.Show Answer
crontab -e and add:0 2 * * * /usr/local/bin/backup.sh /var/www/html >> /var/log/backup-cron.log 2>&1Or for a system-wide schedule, drop a file at
/etc/cron.d/backup with the same line plus a username field: 0 2 * * * root /usr/local/bin/backup.sh /var/www/html. Always redirect stdout+stderr to a log so silent failures are catchable.
/backups is full. Make the script self-healing — before creating a new backup, ensure there's at least 1 GB free, deleting the oldest backups until there is.verify.sh that picks the latest backup, untars it into a temporary directory, and confirms the file count matches the source.find … | wc -l on both sides + mktemp -d for the temp folder.