Linux Hour 9 (optional): 50 Production Problems + 50 Interview Questions

Build two skills from the first seven hours: when you see a Linux error, know which layer it comes from (shell, permissions, systemd, filesystem, network stack, cloud agent or kernel) and what the first command to run is. In an interview, explain in two minutes how a command, a boot, a packet and an OOM event happen.
A: 50 production problemsB: 50 interview questionsUbuntu 26.04 LTS · Rocky/Alma 10.2Verified 2026-11-17
Overall learning goals
  • Given the exact error text, work out which area it belongs to: files/permissions/users/packages, services/logs/storage/networking, Linux in the cloud (Azure / AWS), or security/performance/kernel, and give the first diagnostic command.
  • Understand the mechanisms: the permission and interpreter checks in execve(); the decision order DAC → ACL → capabilities → LSM; the apt/dpkg locks and state machine; systemd jobs and result codes (203/EXEC, start-limit-hit, oom-kill); the dependency chain block device → filesystem → mount → fstab; socket → route → NIC → DNS; cloud-init stages and the metadata service; and the OOM killer and cgroup limits.
  • Reproduce, diagnose, fix and clean up 16 typical faults on linuxlab (Ubuntu Server 26.04 LTS, user labadmin) and the sample service myapp.service. For faults that need a cloud account, the diagnostic commands and expected output are given.
  • Answer 50 Senior Cloud / DevOps Engineer level Linux interview questions using the structure “30-second answer → principle → commands/configuration → production lessons”, and handle follow-up questions.
  • Mock interview (timed, self-scored) to measure how well you know each topic and to find weak modules.

1-hour timetable

#TimeModuleCore contentAnimation · interactionLab
0Before classInstructions and fault lab environmentTake a snapshot of linuxlab; create ~/linuxlab/lab8.sh (inject faults with drop-ins, loop disks, cleanup); confirm myapp.service is running normallyEnvironment self-checkGenerate lab8.sh
100–08A · Files, permissions, users and packagesProblems 1–12: script without execute permission / noexec, CRLF interpreter, immutable attribute, directory traversal permissions, sudoers and its syntax, SSH public keys and directory permissions, changed host keys, dpkg lock, interrupted dpkg, NO_PUBKEY, dnf metadataSimulator for the execve() and permission checks of one ./deploy.sh runExecute permission and noexec · CRLF · directory traversal · dpkg lock
208–16A · Services, logs, storage and networkingProblems 13–25: 203/EXEC, starting too often, daemon-reload, 217/USER, logs not persisted, deleted but still in use, inode exhaustion, mount failure, emergency mode, LVM extension not taking effect, port in use, connection refused, temporary DNS failureTroubleshooting tree: “service won't start / can't connect”203/EXEC · start rate limiting · inode exhaustion · port conflicts and listen addresses
316–24A · Linux in the cloud: Azure and AWSProblems 26–38: Entra sign-in disabled, AADSSHLoginForLinux exit code, Azure fstab emergency mode, temporary disk data loss, cloud-init not applied, VM agent not ready, AMA with no data, EC2 publickey, IMDSv2 401, TargetNotConnected, NVMe device names and resizing, user data not rerun, kernel unable to mount rootTroubleshooting tree: “cloud VM won't connect / won't boot”cloud-init failures (local Multipass) · findmnt pre-check · IMDSv2 tokens · Entra roles
424–30A · Security, performance and kernelProblems 39–50: OOM, fork failure, file descriptor exhaustion, conntrack table full, SYN queue overflow, hung task, soft lockup, high load with low CPU, SELinux, AppArmor, clock skew, ext4 read-only“Memory → process → kernel” resource gate simulatorcgroup OOM · TasksMax · LimitNOFILE
530–37B · Fundamentals and architectureInterview 1–13Mock interview2 scenario questions
637–44B · System administration and networkingInterview 14–25Mock interview2 scenario questions
744–52B · Cloud and automationInterview 26–38Mock interview3 scenario questions
852–60B · Security, performance and scenario designInterview 39–50Mock interview3 scenario questions
—After classQuick reference · Capstone drills50 “error → first command → fix” entries; 50 flashcards; 8 mixed faults; full mock interviewFull mock interview12-question final quiz

Knowledge coverage matrix

Topicm1m2m3m4m5m6m7m8
Shell, processes, execve and exit codes●●—●●—●—
File permissions, ACLs, attributes, users and sudo●—●●●——●
Packages: apt / dpkg / dnf and repository signing●———●—●●
systemd, journald and resource limits—●●●●●—●
Storage: block devices, LVM, filesystems, fstab—●●●—●●—
Networking: sockets, routes, firewall, DNS, conntrack—●●●—●—●
SSH, identity and access (Entra sign-in / SSM / IMDS)●—●——●●●
cloud-init, cloud agents, monitoring and patching——●———●●
Memory, CPU, I/O and kernel logs—●●●●●—●
SELinux / AppArmor, hardening and auditing———●———●

Not covered in this hour (where to learn it)

  • Topic guides: basics and permissions → Hour 1; systemd, logs, storage, networking, SSH → Hour 2; Azure → Hour 3; AWS → Hour 4; scripting and image building → Hour 5; hardening and kernel mechanisms → Hour 6; troubleshooting methodology and performance tools → Hour 7. This hour covers only troubleshooting and interview answers.
  • Container namespaces / cgroups and image problems → Docker 8 hours; Kubernetes failures such as Pod scheduling and CrashLoopBackOff → Kubernetes 8 hours.
  • Large-scale configuration management (writing fixes as idempotent tasks) → Ansible 8 hours; metrics, alerts and dashboards → Prometheus & Grafana 8 hours.
  • Kernel development, driver debugging, and in-depth kdump dump analysis (the crash tool) → see the kernel and distribution documentation. This hour covers only the principles behind them, in the interview questions.

How to use this hour

When troubleshooting (Part A)
  • Open the quick overview for the relevant module and paste the most distinctive word from the error (such as Permission denied, 203/EXEC, No space, TargetNotConnected, Killed process) into the filter box.
  • Click a table row to jump to the problem details, then follow “diagnose → compare with the output → fix”.
  • Not sure which layer it is? Use the animated simulator / decision tree on each page.
Before the interview (Part B)
  • Read the overview first, and pick out the questions you're unsure about by difficulty.
  • Mock interview: random questions, a 2-minute countdown, answer first and then check, self-rate as “answered / partial / didn't know”. Scores are saved in this browser.
  • Answer structure: one-sentence conclusion → principle → commands/configuration → pitfalls you've hit.
After class
  • The quick reference is good to print and pin up at your desk.
  • Capstone drills: 8 mixed faults + full mock interview (50 questions, pick 10) + final quiz.
  • Each question links back to the matching module in Hours 1–7.

Structure of the Part A and Part B entries

Part A · 50 production problems

Symptom → root cause (mechanism) → diagnostic commands → sample expected output → fix → prevention and best practices → see Hour N → reproduction lab. Titles use the exact error text where possible. Entries marked “Verified against source” were checked against the upstream default-branch source of systemd, the Linux kernel, OpenSSH, APT, util-linux, sudo / sudo-rs and gunicorn. Entries marked “Official docs” come from man7.org, learn.microsoft.com and docs.aws.amazon.com. All others are marked “Check on your system”: prefixes, fields and wording vary with version, locale and distribution patch level.

Part B · 50 interview questions

Question → 30-second answer → in-depth answer (principles, commands/code) → common follow-ups → extra credit points → common wrong answers. Difficulty: JuniorMid-levelSenior. Target roles: Senior Cloud / DevOps / SRE.

How this hour relates to the first seven

HourMost-referenced content in this hour
Hour 1 Core fundamentalsThe full command execution path (parsing → PATH → fork/exec → permission checks → exit code), permissions and ACLs, users and sudo, apt / dnf, the ~/linuxlab working directory, and the manually run myapp
Hour 2 System administration and production readinessmyapp.service (user myapp, /opt/myapp/venv, /etc/myapp/myapp.env, port 5000, /healthz), journald, LVM (loop devices), fstab, ip/ss, SSH hardening, timers
Hour 3 Azure · Hour 4 AWSrg-linux-lab / vm-linux-lab (canadacentral), Entra ID sign-in, AMA and DCR, Update Manager, serial console; Name=linux-lab in ca-central-1 (AL2023), IMDSv2, SSM, CloudWatch Agent, EC2 serial console
Hour 5 · Hour 6 · Hour 7Robust scripts and ShellCheck, Packer golden images; CIS, SELinux/AppArmor, nftables, PAM, auditd, sysctl, cgroups; the USE method, vmstat/iostat/pidstat, tcpdump, boot rescue, strace/perf/bpftrace
Version note This hour is based mainly on Ubuntu Server 26.04 LTS (Resolute Raccoon, released 2026-04-23, standard support until 2031-04, Ubuntu Pro ESM for 10 years in total): GA kernel 7.0, systemd 259, APT 3.1 (apt-key removed), sudo-rs as the default sudo (the original is renamed sudo.ws), core tools from rust-coreutils (cp/mv/rm are still the GNU versions), chrony for time sync on new installs, Dracut as the default initramfs tool, and OpenSSH 10.2. Differences from 24.04 LTS (kernel 6.8, systemd 255, APT 2.7, original sudo, GNU coreutils, systemd-timesyncd, initramfs-tools) are marked separately in the relevant problems. RHEL-family comparison: Rocky Linux / AlmaLinux 10.2 (kernel 6.12 series). Upstream references: kernel.org stable 7.3.4, long-term support 6.18 / 6.12 / 6.6 / 6.1 / 5.15 / 5.10; upstream systemd v262.2. All “expected output” examples are samples; PIDs, IPs, times, UUIDs and so on will differ on your system.

Module 0 · Instructions and fault lab environment

Before class · Reuse linuxlab, ~/linuxlab and myapp.service from Hours 1–2. Take a snapshot first; all service faults are injected through a single removable drop-in.
10 min before classLocal VM is free
Module goals
  • Confirm that linuxlab runs Ubuntu 26.04 LTS (or 24.04; differences are noted per problem), that labadmin has sudo, and that myapp.service is running and /healthz responds normally.
  • Snapshot the lab machine and generate the helper script ~/linuxlab/lab8.sh: inject and remove the myapp.service fault drop-in, create loop disks, view recent service and kernel logs, and clean up in one step.
  • Safety rule: create faults only on linuxlab (and the temporary VM lab8ci). Use only the hour 3 and hour 4 cloud resources for cloud labs, and restore them when you're done.

Prerequisites

  • Complete Hour 1 Module 0: the Multipass lab machine linuxlab (multipass launch --name linuxlab --cpus 2 --memory 4G --disk 20G; no image is specified, so the current LTS is used; Multipass is currently 1.17.1), the administrator labadmin, and the working directory ~/linuxlab.
  • Complete Hour 2 Module 1: the system user myapp, code in /opt/myapp/app (app.py; venv at /opt/myapp/venv), config in /etc/myapp/myapp.env (root:myapp 0640), and the unit myapp.service (Type=exec, WorkingDirectory=/opt/myapp/app, SyslogIdentifier=myapp, so log lines start with myapp[PID]:), running gunicorn on 0.0.0.0:5000, depending on redis-server.service, with logs going to journald.
  • The Module 3 cloud labs need resources from hour 3 (rg-linux-lab, vm-linux-lab, canadacentral) or hour 4 (ca-central-1, tag Name=linux-lab, AL2023). Without a cloud account, you can still do the other labs (reading the diagnosis and expected output only).
  • An optional RHEL-family comparison machine rhellab (Rocky / Alma 10.2) is needed only for the labs for #12 and #47.

Step 1: environment self-check and snapshot

multipass version
multipass info linuxlab | grep -E 'State|Release|IPv4'
multipass stop linuxlab && multipass snapshot linuxlab --name pre-lab8 && multipass start linuxlab
multipass shell linuxlab
. /etc/os-release; echo "$PRETTY_NAME"; uname -r
systemctl --version | head -1
sudo --version | head -1  # 26.04: sudo-rs; 24.04: Sudo version 1.9.x
systemctl is-active myapp redis-server
curl -fsS http://127.0.0.1:5000/healthz; echo
Ubuntu 26.04 LTS
7.0.0-15-generic
systemd 259 (259.x-…ubuntu…)
sudo-rs 0.2.x
active
active
{"status":"ok","redis":true}

Snapshots require stopping the instance first (Multipass 1.13 and later support snapshot / restore). To restore: multipass stop linuxlab && multipass restore linuxlab.pre-lab8. Version numbers and output formats depend on your setup. For Hyper-V / VirtualBox, use their own checkpoints or snapshots. WSL2 has no snapshots, but you can back it up with wsl --export. Its systemd must be enabled in /etc/wsl.conf, and the disk and kernel are managed by WSL, so results for the storage and kernel labs (#20–#22, #44–#50) will differ.

Step 2: helper script lab8.sh

All service faults are written to /etc/systemd/system/myapp.service.d/lab8.conf; deleting that file and running daemon-reload restores the service. All storage faults use loop images under /var/tmp/lab8, so the system disk is not touched.

mkdir -p ~/linuxlab && cat > ~/linuxlab/lab8.sh <<'EOF'
# Usage: source ~/linuxlab/lab8.sh
L8=/var/tmp/lab8; DROP=/etc/systemd/system/myapp.service.d/lab8.conf
# Inject drop-in: reads [Service] etc. from stdin
l8_inject() { sudo mkdir -p "${DROP%/*}" && sudo tee "$DROP" >/dev/null && sudo systemctl daemon-reload && echo "injected: $DROP"; }
# Heal: remove the fault, clear the failure count, restart
l8_heal() { sudo rm -f "$DROP"; sudo systemctl daemon-reload; sudo systemctl reset-failed myapp; sudo systemctl restart myapp; systemctl is-active myapp; }
# Last N lines of service / kernel logs
l8_log()  { journalctl -u "${2:-myapp}" -n "${1:-15}" --no-pager -o short-iso; }
l8_klog() { sudo journalctl -k -n "${1:-15}" --no-pager -o short-iso; }
# Create a loop disk: l8_loop <name> <size, e.g. 200M>; prints the device name
l8_loop() { sudo mkdir -p $L8 && sudo truncate -s "${2:-200M}" "$L8/$1.img" && sudo losetup -fP --show "$L8/$1.img"; }
# Clean up: unmount /mnt/lab8*, release loop devices, delete the images and the drop-in
l8_clean() {
  for m in $(findmnt -rno TARGET | grep '^/mnt/lab8'); do sudo umount -l "$m"; done
  losetup -nO NAME,BACK-FILE | awk -v p="$L8" 'index($2,p){print $1}' | xargs -r -n1 sudo losetup -d
  sudo rm -rf "$L8" /mnt/lab8*; l8_heal >/dev/null; echo "lab8 cleaned"
}
EOF
source ~/linuxlab/lab8.sh && type l8_inject | head -1
l8_inject is a function

Step 3: record a baseline

systemctl cat myapp | grep -E '^(Type|User|WorkingDirectory|EnvironmentFile|SyslogIdentifier|ExecStart|Restart)='
stat -c '%U:%G %a %n' /etc/myapp/myapp.env
df -hT / ; df -i / | tail -1
ss -ltnp | grep -E ':5000|:6379'
resolvectl status | grep -E 'Current DNS|DNS Servers' | head -2
Type=exec
User=myapp
WorkingDirectory=/opt/myapp/app
EnvironmentFile=/etc/myapp/myapp.env
SyslogIdentifier=myapp
ExecStart=/opt/myapp/venv/bin/gunicorn -w 2 -b 0.0.0.0:5000 app:app
Restart=on-failure
root:myapp 640 /etc/myapp/myapp.env
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda1      ext4   19G  2.9G   16G  16% /
/dev/sda1      1245184 98123 1147061    8% /
LISTEN 0  2048   0.0.0.0:5000  0.0.0.0:*  users:(("gunicorn",pid=1234,fd=5),…)
LISTEN 0  511  127.0.0.1:6379  0.0.0.0:*  users:(("redis-server",pid=987,fd=6))
Current DNS Server: 10.122.0.1
       DNS Servers: 10.122.0.1

Link from the previous hour

  • Reuse the hour 7 methodology: the USE method (utilization, saturation, errors), the “60-second analysis” commands (uptime, dmesg -T | tail, vmstat 1, mpstat -P ALL 1, pidstat 1, iostat -xz 1, free -m, sar -n DEV 1, sar -n TCP,ETCP 1, top), strace -f, and bpftrace.
  • The hour 7 fault toolkit ~/linuxlab/faults/ (inject.sh / reset.sh / status.sh / blindbox.sh; the disk faults use a loop ext4 at /mnt/faultdisk) does not interfere with this hour. Before you start, run ~/linuxlab/faults/status.sh to confirm nothing is left over, and run ~/linuxlab/faults/reset.sh if needed. This hour uses only /mnt/lab8*, /var/tmp/lab8 and the drop-in lab8.conf.
  • Four troubleshooting questions: who (process / user / unit) → what (exact error text, exit code, errno) → where (which layer: shell / permissions / systemd / filesystem / network / cloud / kernel) → when (after a change? after a reboot? at peak load?).

Lab safety rules

Create faults only in the lab machine. Do not run the “create fault” steps of this hour on production machines (exhausting inodes, triggering OOM, editing sudoers, editing fstab). For the sudoers lab (#6), open a second root session (sudo -i) before you make changes. For the fstab lab (#21), use only the findmnt --verify and systemd-analyze pre-checks; do not reboot. For all cloud labs, write down the cost and the cleanup commands. If something goes wrong: multipass restore linuxlab.pre-lab8.
source ~/linuxlab/lab8.sh && l8_clean
multipass delete --purge lab8ci 2>/dev/null  # On the local machine: delete the temporary VM from problem #30
sudo systemctl status myapp --no-pager | head -3

Self-check list

Module 1 · Part A: Files, permissions, users and packages (problems 1–12)

00:00 – 08:00 · execve and interpreters, permission checks, file attributes, sudo / sudo-rs, SSH authentication, apt / dpkg state machine and repository signing, dnf
8 minexecve → permission checks → package managers12 problems
Learning goals
  • Explain the checks the kernel makes when you run ./deploy.sh: the x (search) permission on each directory in the path → the noexec mount option → the file's own x permission (owner / group / other, ACLs) → recognizing #! and then execve of the interpreter → LSM (AppArmor / SELinux). Each failing step maps to an errno: EACCES, ENOENT, EPERM.
  • Tell authentication failures (SSH public key, sudo password) apart from authorization failures (sudoers rules, file permissions), and cover the cases where even root is refused (immutable attributes, read-only mounts, LSM).
  • apt/dpkg locks and state machine: the front-end lock lock-frontend, the database lock lock, half-configured states and dpkg --configure -a. With APT 3.1, repository signing uses signed-by + deb822 .sources files.

Type a keyword from the error (such as Permission denied, interpreter, sudoers, publickey, lock, NO_PUBKEY) to filter; click a line to jump to its details.

#1 bash: ./deploy.sh: Permission denied (still refused after chmod +x)
labadmin@linuxlab:~/linuxlab$ ./deploy.sh
-bash: ./deploy.sh: Permission denied
labadmin@linuxlab:~/linuxlab$ ls -l deploy.sh
-rw-r--r-- 1 labadmin labadmin 412 Nov 17 09:12 deploy.sh

Symptom: A script pulled from Git or copied with scp cannot be run directly. More subtle: after chmod +x, you still get Permission denied in /tmp or on a data disk, yet bash deploy.sh works.

Root cause: execve() requires: ① the caller has x (search) permission on every directory in the path; ② the caller has x permission on the file (root also needs at least one x bit); ③ the filesystem is not mounted with noexec. CIS baselines often set /tmp, /var/tmp and /dev/shm to noexec. Git records only 100755 / 100644, and files committed from Windows often lose the executable bit. bash deploy.sh works because it is /usr/bin/bash that gets executed, and the script is only read. So noexec is not a security boundary; it only prevents accidental execution.

Diagnostic commands
ls -l deploy.sh; namei -l "$PWD/deploy.sh"  # check directory and file permissions level by level
findmnt -no TARGET,OPTIONS -T deploy.sh  # mount point and options (look for noexec)
getfacl -p deploy.sh 2>/dev/null | grep -v '^#'
git ls-files -s deploy.sh  # mode recorded in the repo: 100644 / 100755
-rwxr-xr-x 1 labadmin labadmin 412 Nov 17 09:12 deploy.sh
f: /tmp/deploy.sh
drwxr-xr-x root     root     /
drwxrwxrwt root     root     tmp
-rwxr-xr-x labadmin labadmin deploy.sh
/tmp rw,nosuid,nodev,noexec,relatime
100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0	deploy.sh
Fix
chmod +x deploy.sh && git update-index --chmod=+x deploy.sh && git commit -m "make deploy.sh executable"
# noexec mount: don't remove noexec; move the script to a suitable location
install -m 0755 deploy.sh ~/linuxlab/bin/deploy.sh  # or /usr/local/bin (needs sudo)
Prevention
  • In the repository, lock the executable bit with git update-index --chmod=+x; check it with test -x in CI.
  • Programs that need to run code from a temporary directory (some installers, Python wheel builds) should set TMPDIR to a private directory without noexec. Don't remove the noexec setting on /tmp.
  • systemd services can control this precisely with NoExecPaths= / ExecPaths=.

See Hour 1 Module 3: file permissions, ownership and ACLs and Hour 6 Module 1: hardening baseline (CIS).

#2 bash: ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory
$ ./deploy.sh
-bash: ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory
$ ./healthcheck.sh            # when the first line is #!/usr/bin/env bash
/usr/bin/env: 'bash\r': No such file or directory

Symptom: The script was edited on Windows or converted by a tool, and now it won't run. /bin/bash exists, yet the error says it can't be found.

Root cause: The file uses CRLF line endings. The kernel takes everything after #! up to \n as the interpreter path, so it tries to run the nonexistent /bin/bash\r. execve returns ENOENT, and bash shows “bad interpreter”; ^M is the carriage return \r. Similar causes: a wrong interpreter path (#!/bin/python), or distributions such as Alpine that don't ship bash.

Diagnostic commands
head -1 deploy.sh | od -c | head -2  # look for \r \n
file deploy.sh
grep -c $'\r' deploy.sh  # count the lines containing CR
0000000   #   !   /   b   i   n   /   b   a   s   h  \r  \n
deploy.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
17
Fix
sed -i 's/\r$//' deploy.sh  # or: sudo apt install dos2unix && dos2unix deploy.sh
printf '*.sh text eol=lf\n' >> .gitattributes && git add --renormalize . && git commit -m "normalize line endings"
Prevention
  • Pin eol=lf in the repository with .gitattributes; set the editor to LF; run ShellCheck in CI (it reports SC1017 “Literal carriage return”).
  • #!/usr/bin/env bash is more portable, but it is affected by CRLF in the same way.

See Hour 1 Module 2: shell and the filesystem hierarchy, Bash course hour 7 Module 2: ShellCheck, and Git 8 hours (line endings).

#3 rm: cannot remove 'app.log': Operation not permitted (root can't delete it either)
$ sudo rm /var/log/myapp/app.log
rm: cannot remove '/var/log/myapp/app.log': Operation not permitted
$ sudo truncate -s0 /var/log/myapp/app.log
truncate: cannot open '/var/log/myapp/app.log' for writing: Operation not permitted

Symptom: root's delete, rename or write to a file returns EPERM (not EACCES), even though the permission bits look normal.

Root cause: the file has the extended attribute i (immutable: it can't be changed, deleted or linked) or a (append-only: it can only be appended to). The filesystem enforces this, so even root is bound by it; only a process holding CAP_LINUX_IMMUTABLE can clear it. Common sources: “tamper-proofing” scripts, security hardening, and log-shipping agents. If a directory has i, no files can be created or deleted in it. Other reasons root gets EPERM / EROFS: a read-only mount, an overlay lower layer, or an LSM denial.

Diagnostic commands
lsattr /var/log/myapp/app.log /var/log/myapp -d
findmnt -no OPTIONS -T /var/log/myapp
sudo journalctl -k --since -10min | grep -iE 'apparmor|avc' | tail -3
----i---------e------- /var/log/myapp/app.log
--------------e------- /var/log/myapp
rw,relatime
Fix
sudo chattr -i /var/log/myapp/app.log && sudo rm /var/log/myapp/app.log
# Log tamper protection: use append-only rather than immutable; logrotate's prerotate/postrotate removes and re-adds the attribute
Prevention
  • Document attribute protection in your operations docs and manage it in configuration management (have Ansible tasks explicitly manage attributes); otherwise, rotation and upgrades will fail.
  • Real tamper protection comes from centralized logging (journald forwarding, CloudWatch / Log Analytics) and auditd, not from local file attributes.

See Hour 1 Module 3 and Hour 6 Module 5: auditing.

#4 PermissionError: [Errno 13] Permission denied: '/opt/myapp/data/counter.db' (file mode 666)
$ journalctl -u myapp -n 3 --no-pager
myapp[2210]:   File "/opt/myapp/app/app.py", line 31, in save
myapp[2210]:     with open(DATA, "a") as f:
myapp[2210]: PermissionError: [Errno 13] Permission denied: '/opt/myapp/data/counter.db'

Symptom: The file is -rw-rw-rw-, yet the myapp user still can't open it; or it can read the file but can't create new files.

Root cause: To reach a path, you need x (search) permission on every parent directory. Creating, deleting or renaming an entry in a directory requires w+x on that directory, regardless of the file's own permissions. Typical case: a deployment script creates /opt/myapp/data as root:root 0750, or a root shell with umask 077 creates the directory. Evaluation order: owner → named-user ACL → group / named-group ACL (limited by the mask) → other. Only the first matching class applies; if the owner bits are more restrictive, “other” is not checked either.

Diagnostic commands
sudo -u myapp namei -l /opt/myapp/data/counter.db
sudo -u myapp test -w /opt/myapp/data && echo dir-writable || echo dir-NOT-writable
getfacl -p /opt/myapp/data
id myapp
f: /opt/myapp/data/counter.db
drwxr-xr-x root  root  /
drwxr-xr-x root  root  opt
drwxr-xr-x myapp myapp myapp
drwxr-x--- root  root  data
                       counter.db - Permission denied
dir-NOT-writable
uid=998(myapp) gid=998(myapp) groups=998(myapp)
Fix
sudo install -d -o myapp -g myapp -m 0750 /opt/myapp/data
# Better: let systemd manage the writable directory (created automatically, owner set)
sudo systemctl edit myapp  # under [Service], add StateDirectory=myapp, and have the code use $STATE_DIRECTORY (/var/lib/myapp)
Prevention
  • Keep the code directory root:root and read-only. Put writable data in /var/lib/<app> (StateDirectory=), logs in journald, and caches with CacheDirectory=.
  • When troubleshooting permissions, first run sudo -u <service user> namei -l <path>; don't check as root.
  • Don't “fix” it with chmod -R 777: that widens the attack surface and doesn't help with the parent directories.

See Hour 1 Module 3 and Hour 2 Module 1: systemd.

#5 bob is not in the sudoers file. / I'm sorry bob. I'm afraid I can't do that (sudo-rs)
# 24.04 (original sudo 1.9.x)
$ sudo systemctl restart myapp
[sudo] password for bob:
bob is not in the sudoers file.
# 26.04 (sudo-rs is the default sudo)
$ sudo systemctl restart myapp
[sudo: authenticate] Password:
sudo: I'm sorry bob. I'm afraid I can't do that

Symptom: A new colleague's password is correct, but sudo still refuses. They were just added with usermod -aG sudo bob, yet their terminal is still refused.

Root cause: Authentication (the password is correct) and authorization (whether a matching sudoers rule exists) are two separate steps. Ubuntu's default rule is %sudo ALL=(ALL:ALL) ALL (on the RHEL family it's %wheel). Group membership is determined at login: an existing session does not pick up a new group, so you have to log in again (or use newgrp / su - bob). Another cause: the user was added to admin / wheel rather than the group this distribution uses. The original sudo logs the “incident”; sudo-rs prints different messages and writes a different log format, so scripts should not grep for the exact wording.

Diagnostic commands
id bob; getent group sudo
sudo -l -U bob  # run by an administrator who has permission
sudo grep -rhE '^\s*%?(sudo|wheel|admin)\b' /etc/sudoers /etc/sudoers.d/ 2>/dev/null
sudo journalctl _COMM=sudo -n 5 --no-pager
uid=1001(bob) gid=1001(bob) groups=1001(bob)
sudo:x:27:labadmin
User bob is not allowed to run sudo on linuxlab.
%sudo	ALL=(ALL:ALL) ALL
Fix
sudo usermod -aG sudo bob  # takes effect after bob logs in again; verify: id shows 27(sudo)
# Manage only myapp: grant minimal privileges, not full sudo
echo 'bob ALL=(root) /usr/bin/systemctl restart myapp, /usr/bin/journalctl -u myapp *' | sudo tee /etc/sudoers.d/50-bob-myapp
sudo chmod 0440 /etc/sudoers.d/50-bob-myapp && sudo visudo -cf /etc/sudoers.d/50-bob-myapp
Prevention
  • Grant access by group, push sudoers snippets through configuration management, and validate them in CI with visudo -c.
  • In the cloud, prefer centralized identity: on Azure, use Entra ID sign-in and the “Virtual Machine Administrator Login” role (#26); on AWS, use SSM Session Manager (#35). That way you don't have to maintain local users on each instance.
  • 26.04's sudo-rs does not support every sudoers directive in the original sudo (such as the LDAP backend and some Defaults). Test on a test machine before migrating, and if needed install sudo.ws (check the release notes).

See Hour 1 Module 4: users, groups and sudo and Hour 6 Module 4: PAM and sudo policy.

#6 sudo: parse error in /etc/sudoers.d/myapp near line 1 — after editing sudoers, nobody can use sudo
$ sudo -i
/etc/sudoers.d/myapp:1:28: syntax error
myapp ALL=(root) NOPASSWD systemctl restart myapp
                           ^~~~~~~~~
sudo: parse error in /etc/sudoers.d/myapp near line 1
sudo: no valid sudoers sources found, quitting

Symptom: Someone wrote a rule straight into the file with echo ... >> /etc/sudoers.d/myapp, and afterwards nobody can use sudo. A cloud VM has no root password, so they locked themselves out.

Root cause: sudo parses all sudoers files at startup (including @includedir /etc/sudoers.d), and a syntax error in any one snippet invalidates the whole policy (the default for the original sudo). In the example above, NOPASSWD: is missing a colon, and the command is not an absolute path. Another common mistake: the file permissions are not 0440, or the owner is not root; the original sudo refuses unsafe files.

Diagnostic commands
sudo visudo -c  # if sudo is already broken, run this from the recovery path below
ls -l /etc/sudoers.d/
pkexec visudo -c 2>/dev/null || echo "pkexec is unavailable (servers usually have no polkit agent)"
Fix (choose a recovery path based on what is available)
  • Still have a root session: run visudo -f /etc/sudoers.d/myapp directly to correct the file or delete it.
  • Local VM: multipass exec linuxlab -- sudo ... also goes through sudo, so it won't work; use snapshot restore, or enter recovery mode from GRUB / systemd.unit=rescue.target.
  • Azure: az vm run-command invoke --command-id RunShellScript --scripts "rm /etc/sudoers.d/myapp" (runs as root through the VM agent), the serial console, or the VMAccess extension. AWS: SSM Run Command (AWS-RunShellScript, runs as root) or the EC2 serial console.
sudo visudo -f /etc/sudoers.d/myapp
# Contents: myapp ALL=(root) NOPASSWD: /usr/bin/systemctl restart myapp
sudo visudo -cf /etc/sudoers.d/myapp && sudo chmod 0440 /etc/sudoers.d/myapp
Prevention
  • Write sudoers files only with visudo -f or through configuration management (Ansible community.general.sudoers / template with validate: visudo -cf %s).
  • Before changing sudo, PAM or sshd, keep one logged-in root session open, then open a new session to verify after the change.
  • In the cloud, keep an out-of-band channel (Run Command / SSM / serial console) and actually use it once in a drill.

See Hour 1 Module 4, Hour 3 Module 7: serial console, and Hour 4 Module 7.

#7 labadmin@10.0.0.4: Permission denied (publickey). — server log: Authentication refused: bad ownership or modes for directory
$ ssh labadmin@10.0.0.4
labadmin@10.0.0.4: Permission denied (publickey).
# server journalctl -u ssh:
sshd[1532]: Authentication refused: bad ownership or modes for directory /home/labadmin/.ssh

Symptom: The key is in authorized_keys, yet login fails; or one day nobody can log in to a machine.

Root cause: sshd defaults to StrictModes yes: if the home directory, ~/.ssh, or authorized_keys can be written by anyone other than the owner (and root), it refuses the keys in that file. Common triggers: chmod -R 777 /home/labadmin, creating .ssh as root (wrong owner), or restoring a backup after the UID changed. Other causes: the client did not offer the right private key (check with ssh -v for “Offering public key”), the server policy rejects the key type (OpenSSH 10 has removed DSA), AllowUsers / AllowGroups restrictions, or a locked account.

Diagnostic commands
ssh -v labadmin@10.0.0.4 2>&1 | grep -E 'Offering|Authentications that can continue|Server accepts'
# On the server (via the console or another session):
sudo journalctl -u ssh -n 20 --no-pager | grep -iE 'refused|invalid|Accepted'
namei -l /home/labadmin/.ssh/authorized_keys
sudo sshd -T | grep -E 'strictmodes|pubkeyauthentication|allowusers|authorizedkeysfile'
debug1: Offering public key: /home/me/.ssh/id_ed25519 ED25519 SHA256:… explicit
debug1: Authentications that can continue: publickey
drwxr-xr-x root     root     /
drwxr-xr-x root     root     home
drwxrwxrwx labadmin labadmin labadmin
drwx------ labadmin labadmin .ssh
-rw------- labadmin labadmin authorized_keys
strictmodes yes
Fix
sudo chmod 755 /home/labadmin  # or 750; the key is to remove group/other write permission
sudo chown -R labadmin:labadmin /home/labadmin/.ssh
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
Prevention
  • Don't turn off StrictModes. Distribute keys with ssh-copy-id or cloud-init's ssh_authorized_keys.
  • At scale, switch to SSH certificates (TrustedUserCAKeys) or cloud identity (Entra sign-in, EC2 Instance Connect, SSM) so you don't have scattered long-lived public keys.

See Hour 2 Module 6: SSH keys, configuration and hardening and Hour 6 Module 4: SSH certificates.

#8 @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
…
Offending ED25519 key in /home/me/.ssh/known_hosts:7
Host key verification failed.

Symptom: After rebuilding vm-linux-lab or an EC2 instance and reusing the same IP / DNS name, SSH refuses connections, and CI deployments fail too.

Root cause: On first boot of a new instance, cloud-init generates new host keys (unique per instance, which is normal). The client's known_hosts still holds the old key, and SSH can't tell a rebuilt machine from a man-in-the-middle attack, so it refuses.

Diagnostic commands
ssh-keygen -F 10.0.0.4  # fingerprint recorded locally
ssh-keyscan -t ed25519 10.0.0.4 2>/dev/null | ssh-keygen -lf -
# Get the new host's real fingerprint out-of-band (Azure boot diagnostics / AWS console output; cloud-init prints it)
aws ec2 get-console-output --instance-id i-0abc… --latest --output text | grep -A3 'BEGIN SSH HOST KEY FINGERPRINTS'
Fix
ssh-keygen -R 10.0.0.4  # delete the old record only after the fingerprint matches
ssh labadmin@10.0.0.4  # accept again (or pre-populate known_hosts)
Prevention
  • Don't use StrictHostKeyChecking=no in CI. Use SSH host certificates (@cert-authority), or take the fingerprint from the console output or metadata when the instance is created and distribute it.
  • For immutable infrastructure where instances are rebuilt often, prefer SSM / az ssh vm or other channels that don't depend on known_hosts.

See Hour 2 Module 6 and Hour 4 Module 4: access methods.

#9 E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1873 (unattended-upgr)
$ sudo apt install -y jq
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1873 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

Symptom: On a new VM, apt install in cloud-init / user data fails now and then; running it manually also reports a lock.

Root cause: apt/dpkg uses fcntl record locks so that only one front end modifies the package database at a time. After a new machine boots, unattended-upgrades, apt-daily.service and cloud-init's package_update are often running. A lock is a kernel object held by a process and released when the process exits. Deleting the lock file does not unlock anything; it only lets two processes write the database at once and corrupt it (#10).

Diagnostic commands
sudo fuser -v /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock
ps -o pid,etime,cmd -p 1873
systemctl list-jobs; systemctl status apt-daily.service apt-daily-upgrade.service --no-pager | grep -E 'Active|Main PID'
cloud-init status
                     USER        PID ACCESS COMMAND
/var/lib/dpkg/lock-frontend: root  1873 F.... unattended-upgr
    PID     ELAPSED CMD
   1873       03:12 /usr/bin/python3 /usr/bin/unattended-upgrade
status: running
Fix
# Wait for the lock instead of deleting it: APT supports a lock-wait timeout
sudo apt-get -o DPkg::Lock::Timeout=600 install -y jq
# cloud-init: use the packages: module, or run cloud-init status --wait before runcmd
Prevention
  • For automation, use DPkg::Lock::Timeout consistently (the Ansible apt module has lock_timeout).
  • When building images, have Packer finish upgrades as the last build step, and leave patching after boot to Azure Update Manager / SSM Patch Manager so they don't compete with boot scripts for the lock.

See Hour 1 Module 6: package management and Hour 5 Module 5: patch automation.

#10 E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
$ sudo apt upgrade
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Symptom: During an upgrade the SSH session drops, the VM reboots, or the OOM killer strikes; afterwards every apt command errors. Sometimes a package sits in the iF (half-installed) state, and its service won't start.

Root cause: dpkg installs a package in two steps, unpack and configure (which runs the maintainer scripts), and records each package's state in /var/lib/dpkg/status. If the process is interrupted, the state stops at half-installed / unpacked / half-configured, and apt refuses to continue on an inconsistent database. If postinst itself fails (for example, a bad service configuration makes systemctl start fail), rerunning it still fails, so the root cause must be fixed first.

Diagnostic commands
dpkg --audit
dpkg -l | awk '$1 !~ /^(ii|rc)$/ && NR>5'
sudo tail -20 /var/log/dpkg.log; sudo tail -30 /var/log/apt/term.log
The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 redis-server         Persistent key-value database with network interface
iF  redis-server  5:8.x  amd64  Persistent key-value database …
Fix
sudo dpkg --configure -a
sudo apt-get -f install  # fix dependencies
# If postinst keeps failing: check the errors in term.log, fix the configuration, then rerun; don't hand-edit /var/lib/dpkg/status
Prevention
  • Run interactive upgrades inside tmux / screen. In production, have Update Manager / Patch Manager run upgrades during a maintenance window.
  • Take a snapshot before upgrading (cloud disk snapshot / Multipass snapshot), and include an empty dpkg --audit result in your post-upgrade health checks.

See Hour 1 Module 6.

#11 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY …
$ sudo apt update
Err:5 https://packages.example.com/apt stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4A3B2C1D0E9F8A7B
E: The repository 'https://packages.example.com/apt stable InRelease' is not signed.

Symptom: After adding a third-party repository, apt update fails. Following an old tutorial and running apt-key adv --recv-keys reports that the command doesn't exist on 26.04.

Root cause: APT uses gpgv to verify the InRelease signature, and the key must be in a keyring that the repository is allowed to use. 26.04 (APT 3.1) has removed apt-key. The modern approach: put the public key in /etc/apt/keyrings/ (or /usr/share/keyrings/), and bind it to that repository with Signed-By: in a deb822 .sources file, so the third-party key cannot sign for other repositories. Another cause: the vendor rotated its signing key and the local key file is outdated.

Diagnostic commands
grep -rn . /etc/apt/sources.list.d/*.sources | grep -E 'URIs|Suites|Signed-By'
gpg --show-keys --with-subkey-fingerprints /etc/apt/keyrings/example.gpg 2>/dev/null | grep -E '^(pub|sub)|expires|expired'
apt-config dump | grep -i 'Signed-By' | head -3
Fix
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://packages.example.com/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/example.gpg
sudo tee /etc/apt/sources.list.d/example.sources >/dev/null <<'EOF'
Types: deb
URIs: https://packages.example.com/apt
Suites: stable
Components: main
Signed-By: /etc/apt/keyrings/example.gpg
EOF
sudo apt update
Prevention
  • Check the key fingerprint published by the vendor; don't bypass verification with [trusted=yes].
  • Manage third-party repositories centrally in your Packer images, and run apt update in CI to catch key rotations early.

See Hour 1 Module 6: package management: apt, dnf and repositories.

#12 rhellab: Errors during downloading metadata for repository 'appstream' … Curl error (6): Couldn't resolve host name
$ sudo dnf install -y redis
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for https://mirrors.rockylinux.org/mirrorlist?arch=x86_64&repo=AppStream-10 [Could not resolve host: mirrors.rockylinux.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name …

Symptom: Package installation fails on the RHEL-family lab machine while an Ubuntu machine on the same subnet works; or you get Curl error (28): Timeout was reached or a GPG check failure.

Root cause: dnf first downloads the metadata (repomd.xml) for every enabled repository, choosing mirrors through mirrorlist / metalink, and if any enabled repository fails, the whole operation aborts (unless skip_if_unavailable=True). Check layer by layer: DNS (#25) → egress / proxy (for a corporate proxy, set proxy= in /etc/dnf/dnf.conf) → a firewall that allows only some mirrors → a clock error causing TLS failures (#49) → a repository that is disabled or end-of-life.

Diagnostic commands
dnf repolist -v 2>/dev/null | grep -E 'Repo-id|Repo-mirrors|Repo-baseurl' | head
getent hosts mirrors.rockylinux.org || echo DNS-FAIL
curl -sSI https://mirrors.rockylinux.org/ | head -1
grep -E '^(proxy|skip_if_unavailable)' /etc/dnf/dnf.conf; timedatectl | grep -E 'synchronized|Local time'
Fix
sudo resolvectl status | head; sudo systemctl restart systemd-resolved  # or fix the DNS settings in NetworkManager
sudo dnf clean all && sudo dnf makecache
# Internal network: use an internal mirror (baseurl) or Satellite / Pulp; dnf config-manager --set-disabled to temporarily disable unreachable repositories
Prevention
  • In production, use internal repository mirrors with pinned snapshots, so builds are reproducible and work offline.
  • Package management comparison, Ubuntu vs. RHEL family: apt update ↔ dnf makecache, apt-cache policy ↔ dnf info / dnf repoquery, dpkg -S ↔ rpm -qf. Fedora already defaults to dnf5; for the dnf version on RHEL 10 series, check the release notes.

See Hour 1 Module 6 and Hour 2 Module 5: DNS resolution.

What the kernel checks, in order, when you run ./deploy.sh, and the typical failure at each step① Path resolutionx permission on each directory② Mount optionsnoexec · nosuid③ DAC + ACLowner / group / other / mask④ Format detectionELF / #! interpreter⑤ LSMAppArmor / SELinux⑥ RunOpen file · write to directoryEACCES#4 no x on parent directoryENOENT wrong pathEACCES#1 /tmp noexecEROFS #50EACCES#1 missing x bitACL mask truncationENOENT#2 bash\r does not existENOEXEC no #!EACCES (audit log)#47 avc denied#48 apparmor DENIEDEPERM #3 chattr +iEACCES #4 directory not writableEMFILE #41Use the errno to tell which kind of failure it is: EACCES = permission or policy, EPERM = the operation itself is not allowed (attributes, capabilities), ENOENT = the path or the interpreter does not existstrace -f -e trace=execve,openat ./deploy.sh shows the failed system calls and their errno directly
Figure 1-1: first work out which step the failure happened at. The order is simplified; the implementation in the kernel's fs/exec.c and fs/namei.c is authoritative.
apt / dpkg locks and state machineapt updategpgv verifies InRelease #11lock-frontend · lockfcntl lock, released when the process exits #9unpack → configuremaintainer scriptsii installed/var/lib/dpkg/statusInterrupted: iU / iF half-configureddpkg --configure -a #10Deleting the lock file does not unlock anything; it only lets two processes write the status database at the same time
Figure 1-2: the lock ensures only one writer at a time; the status file records how far each package has got

Simulator for the execution and permission checks of one ./deploy.sh run

Pick a case and click “Run” to see which step fails, which errno you get, and what the terminal shows. Order (simplified): shell → fork() → execve() → kernel checks → run.

$ Waiting to run…
Environment linuxlab, with source ~/linuxlab/lab8.sh already run. All files go in ~/linuxlab/lab8 and /var/tmp/lab8; run the cleanup step at the end.

Lab 1-A: executable bit and noexec (#1)

mkdir -p ~/linuxlab/lab8 && cd ~/linuxlab/lab8
printf '#!/bin/bash\necho "deploy ok from $PWD"\n' > deploy.sh
./deploy.sh; echo "exit=$?"
-bash: ./deploy.sh: Permission denied
exit=126

126 = found but not executable; 127 = command not found.

Use a loop device to make a noexec mount, and verify that the x bit can't rescue it:
chmod +x deploy.sh && ./deploy.sh
DEV=$(l8_loop ne 64M) && sudo mkfs.ext4 -q "$DEV" && sudo mkdir -p /mnt/lab8ne && sudo mount -o noexec "$DEV" /mnt/lab8ne
sudo install -m 0755 -o labadmin deploy.sh /mnt/lab8ne/ && /mnt/lab8ne/deploy.sh; bash /mnt/lab8ne/deploy.sh
deploy ok from /home/labadmin/linuxlab/lab8
-bash: /mnt/lab8ne/deploy.sh: Permission denied
deploy ok from /home/labadmin/linuxlab/lab8
Use strace to see the failed system call:
strace -f -e trace=execve /mnt/lab8ne/deploy.sh 2>&1 | tail -2
execve("/mnt/lab8ne/deploy.sh", ["/mnt/lab8ne/deploy.sh"], 0x7ffd… /* 24 vars */) = -1 EACCES (Permission denied)

Lab 1-B: CRLF and bad interpreter (#2)

cd ~/linuxlab/lab8 && printf '#!/bin/bash\r\necho hi\r\n' > crlf.sh && chmod +x crlf.sh
./crlf.sh; file crlf.sh
-bash: ./crlf.sh: /bin/bash^M: bad interpreter: No such file or directory
crlf.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
sed -i 's/\r$//' crlf.sh && ./crlf.sh
hi

Lab 1-C: directory traversal permissions (#4) and immutable attributes (#3)

Access a file as myapp when a parent directory has no x permission:
sudo install -d -o root -g root -m 0700 /var/tmp/lab8/secret
echo 42 | sudo tee /var/tmp/lab8/secret/counter.db >/dev/null && sudo chmod 666 /var/tmp/lab8/secret/counter.db
sudo -u myapp cat /var/tmp/lab8/secret/counter.db
sudo -u myapp namei -l /var/tmp/lab8/secret/counter.db | tail -2
cat: /var/tmp/lab8/secret/counter.db: Permission denied
drwx------ root root secret
                     counter.db - Permission denied

The cat in 26.04 comes from rust-coreutils, so the error prefix wording may differ slightly from GNU; check your system.

Grant access precisely with an ACL (not 777), then see root being unable to delete an immutable file:
sudo setfacl -m u:myapp:x /var/tmp/lab8/secret && sudo -u myapp cat /var/tmp/lab8/secret/counter.db
sudo chattr +i /var/tmp/lab8/secret/counter.db && sudo rm /var/tmp/lab8/secret/counter.db; lsattr /var/tmp/lab8/secret/counter.db
sudo chattr -i /var/tmp/lab8/secret/counter.db
42
rm: cannot remove '/var/tmp/lab8/secret/counter.db': Operation not permitted
----i---------e------- /var/tmp/lab8/secret/counter.db

Lab 1-D: dpkg lock (#9)

Simulate unattended-upgrades with a process that holds an fcntl record lock (APT locks with fcntl(F_SETLK) and checks the holder with F_GETLK; flock(1) is a different kind of lock that APT can't see):
sudo python3 -c 'import fcntl,time; f=open("/var/lib/dpkg/lock-frontend","w"); fcntl.lockf(f, fcntl.LOCK_EX); time.sleep(30)' &
sleep 1; sudo apt-get install -y jq 2>&1 | grep -E '^E:' | head -2
sudo fuser -v /var/lib/dpkg/lock-frontend
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4321 (python3)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
                     USER        PID ACCESS COMMAND
/var/lib/dpkg/lock-frontend: root  4321 F.... python3
The correct way to wait:
sudo apt-get -o DPkg::Lock::Timeout=120 install -y jq >/dev/null && jq --version
jq-1.8.x
Cleanup:
sudo umount /mnt/lab8ne; l8_clean; rm -rf ~/linuxlab/lab8

Instructional video (title and channel verified via YouTube oEmbed)

▶
Linux Crash Course - Understanding File & Directory Permissions — Learn Linux TV
English · file and directory permissions (#1, #4)
▶
How to use chmod | Manage File Permissions in Linux — Akamai Developers
English · chmod and permission bits
▶
Fix Could Not Get Lock on Ubuntu 24.04: apt and dpkg — SERVER LAB
English · dpkg lock (#9); stick to “wait / find the process holding the lock” and don't delete the lock file
▶
FIXED: User is not in the sudoers file. This incident will be reported — GEEKrar Guides
English · the original sudo prompt (#5); the wording in 26.04's sudo-rs is different

No verified video specifically covering CRLF interpreters, chattr immutable attributes, or the APT 3 signing migration was found. Here is a 3-minute storyboard you can record yourself:

Shot 1 (0:00) In the terminal, run ./deploy.sh to get Permission denied and exit code 126; strace -e execve shows EACCES; switch to findmnt -T to point out noexec.
Shot 2 (0:45) Use od -c to zoom in on \r, explaining that the kernel treats /bin/bash\r as the interpreter path.
Shot 3 (1:30) Use sudo -u myapp namei -l to walk through the parent directory that was refused, then use setfacl -m u:myapp:x to fix it precisely.
Shot 4 (2:15) fuser -v /var/lib/dpkg/lock-frontend finds unattended-upgr; demonstrates DPkg::Lock::Timeout.

Official documentation

or score ≥ 70% on the quiz

Module 2 · Part A: Services, Logs, Storage and Networking (questions 13–25)

08:00 – 16:00 · systemd jobs and result codes, unit reloads, execution environment, journald persistence, disk space and inodes, mounts and fstab, LVM, ports and listen addresses, connection refused and timeouts, DNS
8 minUnit → process → filesystem → socket13 questions
Learning goals
  • Read the three layers of systemd information: the job result returned by systemctl ("Job for … failed because …"), the unit Result (exit-code, start-limit-hit, oom-kill…), and the main process exit status (203/EXEC, 217/USER, and 200/CHDIR are failures systemd hits before exec; 1, 2, and 3 are the application exiting on its own).
  • "Disk full" has three causes: blocks exhausted, inodes exhausted, or a deleted file still held open by a process. "Cannot mount" has these causes: the device does not exist, a filesystem type or superblock problem, or an fstab dependency that drops the system into emergency mode.
  • "Cannot connect" has three causes: Connection refused (the packet reached the host, but nothing listens on the port, or it was rejected by REJECT), timeout (packets are dropped: firewall DROP, routing, or a security group), and name resolution failure (DNS).

Filter by error keyword (for example 203, too quickly, daemon-reload, No space, emergency, refused, or resolution). Click a row to jump to the details.

#13 Job for myapp.service failed because the control process exited with error code. — status=203/EXEC
$ sudo systemctl restart myapp
Job for myapp.service failed because the control process exited with error code.
See "systemctl status myapp.service" and "journalctl -xeu myapp.service" for details.
$ systemctl status myapp --no-pager | sed -n '3,6p'
     Active: failed (Result: exit-code) since Mon 2026-11-17 10:02:11 UTC; 3s ago
    Process: 3120 ExecStart=/opt/myapp/venv/bin/gunicorn … (code=exited, status=203/EXEC)
   Main PID: 3120 (code=exited, status=203/EXEC)

Symptom: after you rebuild the venv, upgrade Python, or change ExecStart, the service won't start. Running the same command by hand in the shell works.

Root cause: 203/EXEC: systemd calls execve() after the fork, and the call fails, so the application code never runs. Common causes: the path does not exist (the venv was deleted or rebuilt with a different Python version, so the #! line of a script in the venv points to an interpreter that is gone), no execute (x) bit, a non-absolute ExecStart path (required by older versions), a noexec mount, or a wrong SELinux label. The log shows the specific errno. Related exit codes: 200/CHDIR (WorkingDirectory does not exist), 217/USER (#16), and 226/NAMESPACE (a sandboxing option refers to a path that does not exist).

Diagnostic commands
journalctl -u myapp -b -n 20 --no-pager -o cat | grep -iE 'exec|failed|error'
systemctl show myapp -p ExecStart -p WorkingDirectory -p User --no-pager
ls -l /opt/myapp/venv/bin/gunicorn; head -1 /opt/myapp/venv/bin/gunicorn
sudo -u myapp /opt/myapp/venv/bin/gunicorn --version
myapp.service: Unable to locate executable '/opt/myapp/venv/bin/gunicorn': No such file or directory
myapp.service: Failed at step EXEC spawning /opt/myapp/venv/bin/gunicorn: No such file or directory
myapp.service: Main process exited, code=exited, status=203/EXEC
myapp.service: Failed with result 'exit-code'.
Fix
sudo -u myapp python3 -m venv /opt/myapp/venv && sudo -u myapp /opt/myapp/venv/bin/pip install -r /opt/myapp/app/requirements.txt
sudo systemctl restart myapp && systemctl is-active myapp
Prevention
  • When you deploy, build the new venv in a versioned directory, verify it, then switch the symlink (an atomic release). Do not delete and rebuild in place.
  • Run systemd-analyze verify myapp.service on the unit file in CI. After deployment, run a smoke test against /healthz and roll back automatically if it fails.

See Hour 2 Module 1 systemd: Units, Services and Dependencies.

#14 myapp.service: Start request repeated too quickly. — Job … failed because start of the service was attempted too often.
$ journalctl -u myapp -n 6 --no-pager -o cat
myapp.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
myapp.service: Failed with result 'exit-code'.
myapp.service: Scheduled restart job, restart counter is at 5.
myapp.service: Start request repeated too quickly.
myapp.service: Failed with result 'start-limit-hit'.
$ sudo systemctl start myapp
Job for myapp.service failed because start of the service was attempted too often.

Symptom: the service crashes repeatedly within a few seconds and then stops for good, and Restart=on-failure no longer brings it back. Even after you fix the configuration, systemctl start is still refused.

Root cause: start rate limiting. By default, at most StartLimitBurst=5 starts are allowed within StartLimitIntervalSec=10s (the defaults come from DefaultStartLimit*). If the limit is exceeded, the unit enters the start-limit-hit failed state until the interval passes or you run reset-failed by hand. The real root cause is the first failure. In the example above, gunicorn exited with status 3, which is typically caused by a worker import failure, a Redis connection failure, or a configuration error.

Diagnostic commands
journalctl -u myapp -b --no-pager -o cat | grep -m1 -B2 -A8 'Traceback\|Error\|error'  # find the first failure
systemctl show myapp -p NRestarts -p Result -p StartLimitBurst -p StartLimitIntervalUSec -p RestartUSec
NRestarts=5
Result=start-limit-hit
StartLimitBurst=5
StartLimitIntervalUSec=10s
RestartUSec=100ms
Fix
sudoedit /etc/myapp/myapp.env  # fix the root cause (for example, a wrong REDIS_URL)
sudo systemctl reset-failed myapp && sudo systemctl start myapp
Prevention
  • Set a reasonable RestartSec=2s to 5s, and set StartLimitIntervalSec/StartLimitBurst in the [Unit] section. This prevents a storm of fast failures from filling the logs and overloading dependencies.
  • For dependencies, use After=redis-server.service with Wants= or Requires=, and have the application retry dependencies with backoff. Set an alert on start-limit-hit (for example, send a notification with OnFailure=).

See Hour 2 Module 1.

#15 Warning: The unit file, source configuration file or drop-ins of myapp.service changed on disk. Run 'systemctl daemon-reload' to reload units.
$ sudo vim /etc/systemd/system/myapp.service      # change -w 2 to -w 4
$ sudo systemctl restart myapp
Warning: The unit file, source configuration file or drop-ins of myapp.service changed on disk. Run 'systemctl daemon-reload' to reload units.
$ systemctl show myapp -p ExecStart | grep -o '\-w [0-9]'
-w 2

Symptom: you changed the unit file, but the behavior does not change after a restart. Or you changed a drop-in, but the service still uses the old environment variables.

Root cause: systemd (PID 1) keeps the parsed units in memory, so changes to files on disk take effect only after daemon-reload. The file that EnvironmentFile= points to is read at every start, so changing it only requires a service restart. Unit files and drop-ins require daemon-reload.

Diagnostic commands
systemctl show myapp -p NeedDaemonReload -p FragmentPath -p DropInPaths
systemctl cat myapp  # what is on disk (including drop-ins)
systemd-delta --type=extended,overridden | grep myapp
NeedDaemonReload=yes
FragmentPath=/etc/systemd/system/myapp.service
DropInPaths=/etc/systemd/system/myapp.service.d/override.conf
Fix
sudo systemctl daemon-reload && sudo systemctl restart myapp
# Better: run systemctl edit myapp to edit the drop-in; it runs daemon-reload automatically
Prevention
  • Do not edit distribution units under /usr/lib/systemd/system/ directly, because upgrades overwrite them. Write a drop-in with systemctl edit instead.
  • In configuration management, chain "unit change → daemon-reload → restart" with a handler (the daemon_reload: true option of the Ansible systemd_service module).

See Hour 2 Module 1.

#16 Works by hand, fails under systemd: status=217/USER, 200/CHDIR, or KeyError: 'REDIS_URL'
myapp.service: Failed to determine user credentials: No such process
myapp.service: Failed at step USER spawning /opt/myapp/venv/bin/gunicorn: No such process
myapp.service: Main process exited, code=exited, status=217/USER
# another case:
myapp[3301]: KeyError: 'REDIS_URL'

Symptom: a developer runs gunicorn app:app in their own shell and it works, but it fails when handed to systemd.

Root cause: a systemd service runs in a different environment from an interactive shell. It does not read ~/.bashrc or ~/.profile, PATH is a minimal set, and it does not pick up settings from HOME. Environment variables come only from Environment= and EnvironmentFile=. The working directory defaults to /, and the user is set by User=. 217/USER: the user named by User= does not exist (for example, myapp was never created on the new machine, or the name is misspelled). If EnvironmentFile= points to a missing file and has no - prefix, the unit fails to start. A misspelled variable name makes the application raise a KeyError.

Diagnostic commands
getent passwd myapp
systemctl show myapp -p User -p Group -p WorkingDirectory -p EnvironmentFiles -p Environment
sudo systemd-run --pty --uid=myapp -p EnvironmentFile=/etc/myapp/myapp.env -p WorkingDirectory=/opt/myapp/app env | sort | head
sudo cat /proc/$(systemctl show -p MainPID --value myapp)/environ | tr '\0' '\n'  # actual environment of the running process
Fix
sudo useradd --system --home-dir /opt/myapp --shell /usr/sbin/nologin myapp  # if the user is missing
echo 'REDIS_URL=redis://127.0.0.1:6379/0' | sudo tee -a /etc/myapp/myapp.env
sudo systemctl restart myapp
Prevention
  • Debug with systemd-run --pty in the same environment as the service, not in your own shell.
  • Consider DynamicUser=yes (no need to pre-create the user), or declare the system user with sysusers.d. Have the application validate its required configuration at startup and report a clear error.

See Hour 2 Module 1 and Hour 1 Module 4 Users and Groups.

#17 Logs are gone after a reboot: journalctl -b -1 shows nothing / logs fill /var
$ journalctl --list-boots
IDX BOOT ID                          FIRST ENTRY                 LAST ENTRY
  0 6b1f…                            Mon 2026-11-17 09:00:02 UTC Mon 2026-11-17 10:15:40 UTC
$ journalctl -b -1
-- No entries --
$ journalctl --disk-usage
Archived and active journals take 3.9G in the file system.

Symptom: the server rebooted overnight, and you want to see what happened before the reboot, but only the current boot's logs are there. Or the opposite: /var/log/journal takes up several GB.

Root cause: journald's Storage= defaults to auto. Logs persist only if /var/log/journal exists. Otherwise they go to /run/log/journal, which is held in memory and is lost on reboot. Some minimal images and containers do not have this directory. The persistent size limit is controlled by settings such as SystemMaxUse= (by default 10% of the filesystem, up to 4G). The journal grows when an application logs heavily at debug level or when rate limiting is turned off.

Diagnostic commands
ls -ld /var/log/journal /run/log/journal 2>&1
systemd-analyze cat-config systemd/journald.conf | grep -vE '^#|^$'
journalctl --disk-usage; journalctl -p warning -b -1 -n 20 --no-pager 2>/dev/null | tail -5
journalctl -b -o json --output-fields=_SYSTEMD_UNIT | jq -r ._SYSTEMD_UNIT | sort | uniq -c | sort -rn | head
Fix
sudo mkdir -p /etc/systemd/journald.conf.d
printf '[Journal]\nStorage=persistent\nSystemMaxUse=1G\nMaxRetentionSec=1month\n' | sudo tee /etc/systemd/journald.conf.d/50-lab.conf
sudo systemctl restart systemd-journald
sudo journalctl --vacuum-size=1G  # reclaim now
Prevention
  • Local logs are only a buffer. In production, collect them centrally with Azure Monitor Agent + DCR (#32) or the CloudWatch Agent, and base alerts on the central logs.
  • Make the application's log level configurable, and do not leave DEBUG on in production. Keep journald's RateLimitIntervalSec/RateLimitBurst settings.

See Hour 2 Module 2 Logs: journald, rsyslog and log rotation.

#18 No space left on device: you deleted a large log, but df still shows 100%
myapp[2210]: OSError: [Errno 28] No space left on device
$ df -h /var
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        19G   19G     0 100% /
$ sudo rm /var/log/myapp/debug.log   # 12 GB
$ df -h /var | tail -1
/dev/sda1        19G   19G     0 100% /

Symptom: the disk is full. You deleted the largest log file, but no space was freed. The total reported by du is much smaller than the used space reported by df.

Root cause: deleting a file only removes its directory entry (unlink). As long as a process still has the file open, the inode and data blocks are not freed. du cannot see them, but df still counts them. The most common case: an application keeps a log open and writes to it, and someone runs rm on it instead of rotating it. Or logrotate renames the file, but the application does not reopen it. Other reasons why df and du disagree: a mount point hides files in the original directory, and ext4 reserved blocks (5% by default, reserved for root).

Diagnostic commands
sudo lsof -nP +L1 | awk 'NR==1 || $7>100000000'  # files with link count 0 that are still open
sudo du -xhd1 / 2>/dev/null | sort -h | tail -5; df -h /
sudo tune2fs -l /dev/sda1 | grep -E 'Reserved block count|Block count'
COMMAND   PID  USER  FD  TYPE DEVICE     SIZE/OFF NLINK  NODE NAME
gunicorn 2210 myapp   7w  REG    8,1 12884901888     0 26219 /var/log/myapp/debug.log (deleted)
Fix
sudo truncate -s0 /proc/2210/fd/7  # truncate the deleted file (does not interrupt the process)
sudo systemctl restart myapp  # or make the process reopen the log file
# to empty a log, use truncate or : > file, not rm; if the program cannot reopen files, use copytruncate with logrotate
Prevention
  • Send service logs to stdout/stderr so journald collects them. This avoids self-managed log files at the source.
  • Alert on usage and growth rate of / and /var (for example at 80% and 90%). Put data and logs on separate filesystems or data disks.

See Hour 2 Module 2 and Hour 7 Module 4 Disk and filesystem problems.

#19 No space left on device, but df -h shows 60% free (inodes exhausted) / Argument list too long
$ touch /var/lib/myapp/sessions/new
touch: cannot touch '/var/lib/myapp/sessions/new': No space left on device
$ df -i /var | tail -1
/dev/sda1      1245184 1245184     0  100% /
$ rm /var/lib/myapp/sessions/*
-bash: /usr/bin/rm: Argument list too long

Symptom: there is plenty of space, but you cannot create files. When you clean up, rm * fails.

Root cause: the number of ext4 inodes is fixed by mkfs according to the bytes-per-inode ratio. A huge number of small files (sessions, caches, mail queues, and some package manager caches) uses up the inodes first. Argument list too long is E2BIG from execve(): after the shell expands *, the total argument length exceeds the kernel limit (related to ARG_MAX and the stack size). XFS allocates inodes dynamically, so this is rare, but it has an imaxpct limit.

Diagnostic commands
df -i / /var
sudo find /var -xdev -type f | cut -d/ -f2-4 | sort | uniq -c | sort -rn | head -5
getconf ARG_MAX
Filesystem      Inodes   IUsed IFree IUse% Mounted on
/dev/sda1      1245184 1245184     0  100% /
1102417 var/lib/myapp
  48211 var/lib/dpkg
2097152
Fix
sudo find /var/lib/myapp/sessions -type f -mmin +60 -delete  # bypasses shell expansion
# or: find … -print0 | xargs -0 rm; use systemd-tmpfiles for periodic cleanup:
echo 'e /var/lib/myapp/sessions - - - 1h' | sudo tee /etc/tmpfiles.d/myapp.conf
Prevention
  • Monitor block and inode usage together (using node_filesystem_files_free from node_exporter).
  • For small-file workloads, store sessions in Redis or a database instead. If you really need many small files, use mkfs.ext4 -i 4096 or XFS.

See Hour 2 Module 3 Storage and Hour 7 Module 4.

#20 mount: /data: wrong fs type, bad option, bad superblock on /dev/vdb1, missing codepage or helper program, or other error.
$ sudo mount /dev/vdb1 /data
mount: /data: wrong fs type, bad option, bad superblock on /dev/vdb1, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

Symptom: a newly added data disk, a disk restored from a snapshot, or a disk moved from another machine fails to mount.

Root cause: libmount shows a generic message for errors such as EINVAL returned by mount(2). The real cause is in the kernel log. Common causes: (1) the partition has no filesystem (you forgot mkfs, or you tried to mount the whole disk when the filesystem is on a partition); (2) the wrong type, or missing userspace tools (-t nfs needs nfs-common, and xfs needs xfsprogs); (3) a duplicate XFS UUID (two disks cloned from the same snapshot are mounted together, which needs -o nouuid or xfs_admin -U generate); (4) filesystem corruption that needs fsck; (5) wrong options.

Diagnostic commands
lsblk -f /dev/vdb; sudo blkid /dev/vdb1
sudo dmesg -T | tail -5
sudo file -s /dev/vdb1
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
vdb
└─vdb1 xfs                5c0e…-…
[Mon Nov 17 10:21:03 2026] XFS (vdb1): Filesystem has duplicate UUID 5c0e… - can't mount
Fix
sudo mount -o nouuid /dev/vdb1 /data  # temporary fix (duplicate XFS UUID)
sudo umount /data && sudo xfs_admin -U generate /dev/vdb1 && sudo mount /dev/vdb1 /data
# no filesystem: confirm the disk is empty (lsblk -f, wipefs -n) before mkfs, or you will destroy data
Prevention
  • Before you run mkfs or wipefs, run lsblk -f twice to confirm the device. In automation, use stable device identifiers (Azure: /dev/disk/azure/scsi1/lun0; AWS: /dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_vol…).
  • When you clone from a snapshot, plan for UUIDs (use xfs_admin -U for XFS and tune2fs -U for ext4).

See Hour 2 Module 3 Storage: Disks, Partitions, LVM and Filesystems and Hour 2 Module 4 Mounts and fstab.

#21 You are in emergency mode. After logging in, type "journalctl -xb" to view system logs … (a disk listed in fstab is missing)
[ TIME ] Timed out waiting for device dev-disk-by\x2duuid-5c0e….device.
[DEPEND] Dependency failed for /data.
[DEPEND] Dependency failed for Local File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, or "exit"
to continue bootup.
Give root password for maintenance
(or press Control-D to continue):

Symptom: after a reboot, SSH does not work, and the console shows emergency mode. This is usually because a data disk was detached, the UUID in fstab is wrong, or the fstab entry uses a name that can change, such as /dev/sdc.

Root cause: systemd-fstab-generator turns each fstab line into a .mount unit. By default it is a Requires dependency of local-fs.target. If the device does not appear within 90 seconds (DefaultDeviceTimeoutSec), the mount fails, local-fs.target fails, and the default OnFailure=emergency.target takes effect. Adding nofail turns the dependency into a Wants dependency, so a failure does not block boot. Cloud VMs usually have no root password, so you cannot log in while in emergency mode. Your options are the serial console with single-user mode, or offline repair (#28).

Diagnostic commands (pre-reboot check, the most important step)
sudo findmnt --verify --verbose 2>&1 | tail -5
sudo systemctl daemon-reload && systemctl list-units --type=mount --all | grep -E 'data|not-found'
sudo mount -a && echo "mount -a OK"
/data
   [E] unreachable source: UUID=5c0e…-…
   [W] recommended root FS passno is 1 (current is 0)
1 parse error, 1 error, 1 warning
Fix
# in emergency mode or the serial console:
mount -o remount,rw /
vi /etc/fstab  # comment out the line, or change it to: UUID=<correct value> /data xfs defaults,nofail,x-systemd.device-timeout=10s 0 2
systemctl daemon-reload && systemctl default
Prevention
  • Always use UUID= and nofail for data disks. Add _netdev to network filesystems. After you edit fstab, run findmnt --verify and mount -a before you reboot.
  • The cloud-init mounts module on Ubuntu cloud images adds nofail automatically. Manage fstab with cloud-init or Ansible, and do not edit it by hand.

See Hour 2 Module 4 Mounts, fstab and Swap and Hour 7 Module 6 Boot failures and rescue mode.

#22 lvextend succeeds, but df -h shows the same size (you forgot to grow the filesystem) / Insufficient free space
$ sudo lvextend -L +5G /dev/vgdata/lvdata
  Size of logical volume vgdata/lvdata changed from 10.00 GiB (2560 extents) to 15.00 GiB (3840 extents).
  Logical volume vgdata/lvdata successfully resized.
$ df -h /data | tail -1
/dev/mapper/vgdata-lvdata  9.8G  9.3G  0.5G  95% /data

Symptom: the LV has grown, but the application still reports a full disk. After you expand a cloud data disk, lsblk shows the new size, but pvs does not change.

Root cause: storage is layered as disk → partition → PV → VG → LV → filesystem, and each layer must be grown in turn. lvextend grows only the LV. The filesystem needs resize2fs (ext4) or xfs_growfs (XFS; the argument is the mount point, and XFS can only grow, not shrink). After you expand a cloud disk, you also need growpart to grow the partition and pvresize to grow the PV. When the VG has too little free space, lvextend reports Insufficient free space.

Diagnostic commands
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS /dev/vdb
sudo pvs; sudo vgs; sudo lvs vgdata
df -hT /data
Fix
sudo lvextend -r -L +5G /dev/vgdata/lvdata  # -r (--resizefs) grows the LV and the filesystem in one step
# if you already grew the LV:
sudo resize2fs /dev/vgdata/lvdata  # ext4; for XFS: sudo xfs_growfs /data
# after a cloud disk expansion: sudo growpart /dev/vdb 1 && sudo pvresize /dev/vdb1
Prevention
  • Always use lvextend -r to expand. Keep some free space in the VG for snapshots and emergency growth.
  • Base capacity alerts on "days remaining" (growth rate), not on a single percentage. Take a snapshot before you expand.

See Hour 2 Module 3.

#23 [ERROR] Connection in use: ('0.0.0.0', 5000) — Address already in use
myapp[4012]: [2026-11-17 10:30:01 +0000] [4012] [ERROR] Connection in use: ('0.0.0.0', 5000)
myapp[4012]: [2026-11-17 10:30:01 +0000] [4012] [ERROR] Retrying in 1 second.
…
myapp[4012]: [2026-11-17 10:30:06 +0000] [4012] [ERROR] Can't connect to ('0.0.0.0', 5000)

Symptom: restarting the service fails, or a second instance will not start. Similar errors: bind() to 0.0.0.0:80 failed (98: Address already in use) (nginx), and Python OSError: [Errno 98] Address already in use.

Root cause: a socket is already LISTENing on the address and port (EADDRINUSE). Possible causes: the old process did not fully exit (KillMode= set incorrectly, or it was started by hand with nohup), two services use the same port, or a copy is still running in tmux. TIME_WAIT usually does not prevent LISTEN, because most servers set SO_REUSEADDR.

Diagnostic commands
sudo ss -ltnp 'sport = :5000'
ps -o pid,ppid,user,lstart,cmd -p $(sudo ss -ltnpH 'sport = :5000' | grep -oP 'pid=\K[0-9]+' | sort -u | paste -sd,)
systemctl status myapp --no-pager | grep -E 'Main PID|CGroup' ; sudo systemd-cgls -u myapp.service | head
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0      2048         0.0.0.0:5000      0.0.0.0:*     users:(("gunicorn",pid=2875,fd=5))
    PID    PPID USER     STARTED                  CMD
   2875       1 labadmin Mon Nov 17 08:12:44 2026 /opt/myapp/venv/bin/python3 /opt/myapp/venv/bin/gunicorn …
Fix
kill 2875  # the copy started by hand (owned by labadmin, not in the myapp.service cgroup)
sudo systemctl restart myapp && sudo ss -ltnp 'sport = :5000'
Prevention
  • Let systemd manage the service only, and do not use nohup. By default, KillMode=control-group cleans up the whole group of processes when the service stops.
  • For zero-downtime restarts, use socket activation or a graceful reload with gunicorn HUP/USR2, not stop + start.

See Hour 2 Module 5 Networking and Hour 1 Module 5 Processes.

#24 curl: (7) Failed to connect to 10.0.0.4 port 5000 … Couldn't connect to server (curl works locally)
$ curl -m 5 http://10.0.0.4:5000/healthz
curl: (7) Failed to connect to 10.0.0.4 port 5000 after 2 ms: Couldn't connect to server
$ curl -m 5 http://10.0.0.4:5000/healthz           # another client
curl: (28) Connection timed out after 5001 milliseconds

Symptom: curl 127.0.0.1:5000 works inside the VM, but access from outside fails. Sometimes it fails immediately, and sometimes it times out.

Root cause: an immediate failure (RST / ECONNREFUSED) means the packet reached the host, but either (1) no process listens on that address (the application binds only to 127.0.0.1, often because the default was not overridden with -b 0.0.0.0:5000), or (2) the firewall sent REJECT. A timeout means the packet was silently dropped: a host firewall DROP (ufw's default deny incoming is a DROP), a cloud security group or NSG, asymmetric routing, or a middlebox.

Diagnostic commands
# on the server
sudo ss -ltnp 'sport = :5000'  # listening on 127.0.0.1 or 0.0.0.0?
sudo ufw status verbose 2>/dev/null | head; sudo nft list ruleset | grep -nE 'dport 5000|policy' | head
sudo tcpdump -ni any 'tcp port 5000' -c 6  # did the packets arrive? did an RST come back?
# on the client
ip route get 10.0.0.4; nc -vz -w3 10.0.0.4 5000
LISTEN 0 2048  127.0.0.1:5000  0.0.0.0:*  users:(("gunicorn",pid=3911,fd=5))
10:41:02.112 eth0 In  IP 10.0.0.9.51544 > 10.0.0.4.5000: Flags [S], seq …
10:41:02.112 eth0 Out IP 10.0.0.4.5000 > 10.0.0.9.51544: Flags [R.], seq 0, ack …
Fix
sudo systemctl edit myapp  # change -b in ExecStart to 0.0.0.0:5000 (or keep 127.0.0.1 if it sits behind nginx)
sudo ufw allow from 10.0.0.0/24 to any port 5000 proto tcp
# on the cloud, also check the NSG (Azure) or the security group and NACL (AWS)
Prevention
  • Troubleshoot in this order: listening sockets (ss), then the host firewall, then packet capture, then the cloud network, then client routing. Find the hop where the packet disappears.
  • Have the application listen only on the addresses it needs. Expose it externally through a reverse proxy or load balancer, and manage security groups in IaC.

See Hour 2 Module 5, Hour 6 Module 3 Firewall, and Hour 7 Module 5 Network troubleshooting.

#25 Temporary failure in name resolution
$ curl https://pypi.org
curl: (6) Could not resolve host: pypi.org
$ python3 -c 'import socket; socket.getaddrinfo("pypi.org", 443)'
socket.gaierror: [Errno -3] Temporary failure in name resolution

Symptom: you can ping IP addresses, but every domain name fails to resolve. Or only some (internal) domain names fail.

Root cause: on Ubuntu, /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf. Queries go to 127.0.0.53, and systemd-resolved forwards them upstream (the upstream servers come from netplan or DHCP). Common failures: a script overwrote resolv.conf with a regular file or pointed it at an invalid server, systemd-resolved is stopped, the upstream DNS server is unreachable (port 53 is blocked by a security group or firewall), or split DNS is not configured (internal domain names should go to the internal DNS). On RHEL-family systems, NetworkManager usually writes resolv.conf directly.

Diagnostic commands
ls -l /etc/resolv.conf; cat /etc/resolv.conf | grep -v '^#'
resolvectl status | sed -n '1,15p'
resolvectl query pypi.org
dig +short @10.122.0.1 pypi.org; systemctl is-active systemd-resolved
-rw-r--r-- 1 root root 22 Nov 17 10:50 /etc/resolv.conf
nameserver 10.9.9.9
pypi.org: resolve call failed: All attempts to contact name servers or networks failed
;; communications error to 10.9.9.9#53: timed out
Fix
sudo ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved && resolvectl query pypi.org
# Pin DNS: write it to netplan (nameservers:) or /etc/systemd/resolved.conf.d/, then run netplan apply
Prevention
  • Do not let applications or scripts rewrite /etc/resolv.conf. Leave DNS to netplan, cloud-init, or NetworkManager.
  • In the cloud: Azure uses Azure DNS at 168.63.129.16 by default. AWS uses the Route 53 Resolver for the VPC (VPC CIDR +2). If you use custom DNS, make sure forwarding and security rules are correct.

See Hour 2 Module 5 and Hour 7 Module 5 Network troubleshooting.

The three result layers of systemctl start myapp: job → unit Result → process exit statusJobJob for … failed because …fork → set up the execution environmentUser · directory · environment · sandboxexecve(ExecStart)Application starts runningactive (running)Restart= monitoringsystemd-side failure217/USER #16 · 200/CHDIR226/NAMESPACEexec failure203/EXEC #13ENOENT · EACCESApplication exits on its ownstatus=1/3 · oom-kill #39Repeated → start-limit-hit #14Exit codes 200–2xx mean systemd failed before or during exec (see "Process Exit Codes" in systemd.exec(5)). The application log shows no output at all.The unit file changed but daemon-reload was not run (#15): PID 1 still runs this chain with the old definition.
Figure 2-1: first check which stage the exit code belongs to, then decide whether to look at the systemd logs or the application logs.
Storage stack and connection path: every layer can cause "full", "cannot mount", or "cannot connect".Disk / cloud diskPartitionPV → VG → LVFilesystemMount · fstabBlocks · inodes · open filesgrowpartpvresize · lvextend #22mkfs · UUID #20nofail #21#18 #19DNS resolution #25Routing · cloud networkHost firewallLISTEN socketApplication accept()EAI_AGAINTimeoutDROP = timeout · REJECT = refusedNo listener = refused #24 · port in use #23Queue full #43"Refused immediately" means the packet reached the host. "Timeout" means the packet was dropped along the way. This one distinction can cut the troubleshooting scope in half.
Figure 2-2: troubleshoot storage and networking one layer at a time

Interactive troubleshooting tree: "service won't start / can't connect / disk full"

Choose the first symptom you see, step by step. The tree ends with a conclusion and the matching question numbers.

Environment myapp.service on linuxlab. All service faults are injected through a drop-in with l8_inject, and l8_heal restores them. The inode exhaustion in lab 2-C happens only on a 64 MB loopback filesystem.

Lab 2-A: 203/EXEC and daemon-reload (#13, #15)

source ~/linuxlab/lab8.sh
printf '[Service]\nExecStart=\nExecStart=/opt/myapp/venv/bin/gunicorn-typo -b 0.0.0.0:5000 app:app\n' | l8_inject
sudo systemctl restart myapp; systemctl show myapp -p Result -p ExecMainStatus; l8_log 4
Job for myapp.service failed because the control process exited with error code.
See "systemctl status myapp.service" and "journalctl -xeu myapp.service" for details.
Result=exit-code
ExecMainStatus=203
… myapp.service: Failed at step EXEC spawning /opt/myapp/venv/bin/gunicorn-typo: No such file or directory

An empty ExecStart= clears the original value. This is the standard way for a drop-in to override a list-type setting.

Edit the drop-in file directly (without reload), and watch for the systemd warning:
sudo sed -i 's/gunicorn-typo/gunicorn/' /etc/systemd/system/myapp.service.d/lab8.conf
sudo systemctl restart myapp 2>&1 | head -1; systemctl show myapp -p NeedDaemonReload
sudo systemctl daemon-reload && sudo systemctl restart myapp && systemctl is-active myapp
Warning: The unit file, source configuration file or drop-ins of myapp.service changed on disk. Run 'systemctl daemon-reload' to reload units.
NeedDaemonReload=yes
active
Restore: l8_heal

Lab 2-B: start rate limiting (#14)

Make the service fail on start, and observe that it is rate-limited after 5 restarts:
printf '[Service]\nExecStart=\nExecStart=/bin/sh -c "echo boom; exit 3"\nRestart=always\nRestartSec=200ms\n' | l8_inject
sudo systemctl restart myapp; sleep 3
systemctl show myapp -p Result -p NRestarts; l8_log 3
Result=start-limit-hit
NRestarts=5
… myapp.service: Scheduled restart job, restart counter is at 5.
… myapp.service: Start request repeated too quickly.
… myapp.service: Failed with result 'start-limit-hit'.
After the fix, if you do not run reset-failed, the start may still be refused. This depends on whether the rate-limit interval has passed:
sudo rm /etc/systemd/system/myapp.service.d/lab8.conf && sudo systemctl daemon-reload
sudo systemctl start myapp 2>&1 | head -1; sudo systemctl reset-failed myapp && sudo systemctl start myapp && systemctl is-active myapp
Job for myapp.service failed because start of the service was attempted too often.
active

Lab 2-C: inode exhaustion and argument list too long (#19)

DEV=$(l8_loop inode 64M) && sudo mkfs.ext4 -q -N 2048 "$DEV" && sudo mkdir -p /mnt/lab8i && sudo mount "$DEV" /mnt/lab8i
sudo install -d -o labadmin /mnt/lab8i/s && cd /mnt/lab8i/s
for i in $(seq 1 3000); do : > f$i 2>/dev/null || { echo "failed at $i"; break; }; done
df -h /mnt/lab8i | tail -1; df -i /mnt/lab8i | tail -1
failed at 2038
/dev/loop1       55M   24K   51M   1% /mnt/lab8i
/dev/loop1      2048  2048     0  100% /mnt/lab8i
Clean up with find. Here there are only a few files, so rm * also works. E2BIG is triggered only with millions of files:
find /mnt/lab8i/s -type f -name 'f1*' -delete && df -i /mnt/lab8i | tail -1
cd ~ && sudo umount /mnt/lab8i
/dev/loop1      2048   936  1112   46% /mnt/lab8i

Lab 2-D: port in use and listen address (#23, #24)

Start a stray process by hand on port 5000, then restart the service:
python3 -m http.server 5000 --bind 0.0.0.0 >/dev/null 2>&1 & ROGUE=$!
sudo systemctl restart myapp; sleep 6; l8_log 3; sudo ss -ltnp 'sport = :5000' | tail -1
… [ERROR] Connection in use: ('0.0.0.0', 5000)
… [ERROR] Retrying in 1 second.
… [ERROR] Can't connect to ('0.0.0.0', 5000)
LISTEN 0 5 0.0.0.0:5000 0.0.0.0:* users:(("python3",pid=5120,fd=3))
Kill the stray process. Then change the service to bind only to 127.0.0.1, and observe the "refused" result when you connect from your computer:
kill $ROGUE
printf '[Service]\nExecStart=\nExecStart=/opt/myapp/venv/bin/gunicorn -w 2 -b 127.0.0.1:5000 app:app\n' | l8_inject && sudo systemctl restart myapp
curl -s 127.0.0.1:5000/healthz; echo; hostname -I | awk '{print $1}'
{"status":"ok","redis":true}
10.122.0.57
curl -m 5 http://10.122.0.57:5000/healthz
curl: (7) Failed to connect to 10.122.0.57 port 5000 after 3 ms: Couldn't connect to server
Clean up everything: l8_clean

Teaching videos (titles and channels verified with YouTube oEmbed)

▶
journalctl Basics: How to Easily Check Your Linux Logs — Learn Linux TV
English · common journalctl filters (#13–#17)
▶
fixing broken systemd services — Bo Morgan Tech
English · fixing failed systemd services (#13–#16)
▶
Linux Inode Exhaustion 🚨 | No Space Left on Device Even With Free Disk Space | SRE Incident — Incidentverse Tech
English · inode exhaustion (#19)
▶
How to get your Linux system out of emergency mode — Mike's Tech Tips
English · emergency mode and fstab (#21)
▶
Linux Networking Troubleshooting Simply Explained (ip, ss, ufw) — DevOps Made Simple
English · ip / ss / ufw (#23–#24)

No verified teaching video covers "deleted but still open files" or layered LVM expansion. Storyboard:

Shot 1 (0:00) df at 100%, still at 100% after rm on a large log. lsof +L1 shows (deleted). After truncate /proc/PID/fd/N, the space comes back.
Shot 2 (1:00) Draw disk → partition → PV → VG → LV → filesystem, and demonstrate lvextend -r doing it in one step.
Shot 3 (2:00) The same curl: one run is refused immediately, and one run times out. In tcpdump, compare an RST with "only SYN, no response".

Official documentation

or score ≥ 70% on the quiz

Module 3 · Part A: Linux in the Cloud: Azure and AWS (questions 26–38)

16:00 – 24:00 · Entra ID sign-in and VM extensions, out-of-band repair, temporary disks, cloud-init and the metadata service, VM agent, AMA and DCR, EC2 sign-in, IMDSv2, SSM, EBS NVMe, user data, kernel and boot
8 minFirmware → kernel → cloud-init → agent → sign-in13 questions
Learning goals
  • The first-boot chain of a cloud VM: firmware/boot → kernel and initramfs → systemd → cloud-init (local / network / config / final), which gets its configuration from the metadata service → cloud agent (walinuxagent / amazon-ssm-agent) registers → sign-in works. Each stage fails with different symptoms and needs different out-of-band tools.
  • The "can't get into the machine" toolkit for both clouds. Azure: boot diagnostics, the serial console, az vm run-command, and az vm repair. AWS: console output and screenshots, the EC2 serial console, SSM Run Command, and attaching the root volume to a rescue instance.
  • How identity reaches the instance: Entra sign-in relies on the VM's system-assigned managed identity plus an RBAC data-plane role. AWS instances use IMDSv2 (tokens and a hop limit) to get temporary credentials from the instance profile, and SSM Agent uses them to register.

Filter by keyword (for example Connection closed, exit code, emergency, /mnt, cloud-init, 401, TargetNotConnected, or nvme). Click a row to jump to the details.

#26 az ssh vm: Connection closed by 10.0.0.4 port 22 (Entra ID sign-in; the local key is fine)
$ az ssh vm -g rg-linux-lab -n vm-linux-lab
Connection closed by 10.0.0.4 port 22

Symptom: in hour 3, Entra ID sign-in was enabled (AADSSHLoginForLinux extension). A new colleague runs az login successfully, but az ssh vm is closed immediately, even though they are a Contributor on the subscription.

Root cause: Entra sign-in is authorized by the RBAC data-plane role Virtual Machine Administrator Login (which allows sudo) or Virtual Machine User Login (a regular user). Owner and Contributor do not include login rights. The control plane and data plane are separated on purpose and audited. The same applies when the VM's system-assigned managed identity is turned off. Role assignments take time to propagate.

Diagnostic commands
ME=$(az ad signed-in-user show --query id -o tsv)
az role assignment list --assignee "$ME" --all --query "[?contains(roleDefinitionName,'Virtual Machine')].{role:roleDefinitionName,scope:scope}" -o table
az vm show -g rg-linux-lab -n vm-linux-lab --query identity.type -o tsv
az vm extension list -g rg-linux-lab --vm-name vm-linux-lab --query "[].{name:name,state:provisioningState}" -o table
(empty: no Virtual Machine * Login role)
SystemAssigned
Name                 State
-------------------  ---------
AADSSHLoginForLinux  Succeeded
Fix
RG=$(az group show -n rg-linux-lab --query id -o tsv)
az role assignment create --role "Virtual Machine User Login" --assignee "$ME" --scope "$RG"
sleep 60 && az ssh vm -g rg-linux-lab -n vm-linux-lab
Prevention
  • Assign roles to Entra groups at the resource group or subscription level (the official recommendation, which avoids the per-subscription role assignment limit). Give Administrator Login only to people who need sudo.
  • Combine with Conditional Access (MFA, compliant devices) and PIM for just-in-time elevation. Use Azure Policy to audit VMs that do not have Entra sign-in enabled.

See Hour 3 Module 4 Identity and access.

#27 AADSSHLoginForLinux extension stays in Transitioning: Non-zero exit code 22 / 23
$ az vm extension show -g rg-linux-lab --vm-name vm-linux-lab -n AADSSHLoginForLinux --query "{state:provisioningState,msg:instanceView.statuses[0].message}"
{ "state": "Failed", "msg": "… Non-zero exit code: 22 …" }

Symptom: you add the Entra sign-in extension to an existing VM. In the portal, the status stays at Transitioning for a long time, then fails.

Root cause: according to the documentation, exit code 22 means the VM has no system-assigned managed identity, which the extension uses to prove its identity to Entra. Exit code 23 means the old AADLoginForLinux extension is still installed. Other prerequisites: at least 1 GB of memory, a working VM agent (#31), and outbound access to packages.microsoft.com, 169.254.169.254, login.microsoftonline.com, and pas.windows.net (TCP 443). If you use a proxy, set the proxy environment variables for walinuxagent.service.

Diagnostic commands
az vm show -g rg-linux-lab -n vm-linux-lab --query "{identity:identity.type, size:hardwareProfile.vmSize}" -o table
az vm extension list -g rg-linux-lab --vm-name vm-linux-lab --query "[].name" -o tsv
# inside the VM:
sudo tail -30 /var/log/azure/Microsoft.Azure.ActiveDirectory.AADSSHLoginForLinux/*.log 2>/dev/null | tail -5
curl -s -o /dev/null -w '%{http_code}\n' https://pas.windows.net
Fix
az vm extension delete -g rg-linux-lab --vm-name vm-linux-lab -n AADSSHLoginForLinux
az vm identity assign -g rg-linux-lab -n vm-linux-lab  # exit code 22
az vm extension delete -g rg-linux-lab --vm-name vm-linux-lab -n AADLoginForLinux 2>/dev/null  # exit code 23
az vm extension set -g rg-linux-lab --vm-name vm-linux-lab --publisher Microsoft.Azure.ActiveDirectory --name AADSSHLoginForLinux
Prevention
  • When you create the VM, include --assign-identity and the extension in the same template (Bicep/Terraform). Use the Azure Policy DeployIfNotExists effect to remediate automatically.
  • In restricted outbound environments, allow the extension endpoints in advance (or use Private Link or a proxy), and record them in the network baseline document.

See Hour 3 Module 2 cloud-init and extensions and Hour 3 Module 4.

#28 Azure VM: SSH does not work after a reboot. Boot diagnostics shows Dependency failed for /data … Welcome to emergency mode!
[ TIME ] Timed out waiting for device dev-incorrect.device.
[DEPEND] Dependency failed for /data.
[DEPEND] Dependency failed for Local File Systems.
…
Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" to try again to boot into default mode.
Give root password for maintenance
(or type Control-D to continue)

Symptom: you added a data disk to vm-linux-lab and wrote /dev/sdc1 in fstab. After a maintenance reboot, the VM became unreachable. The portal shows "Running", and the resource health is normal.

Root cause: the same fstab dependency problem as #21, plus two cloud factors. (1) Device names such as /dev/sdX on Azure are not guaranteed to be stable. Use a UUID or /dev/disk/azure/scsi1/lunN instead. (2) Cloud images have no root password, so you cannot get in through "Give root password" in emergency mode. Microsoft's documentation lists these common causes: using a device name instead of a UUID, a wrong UUID, a missing nofail on a disk that might not be attached, and an incorrect entry format.

Diagnostic commands
az vm boot-diagnostics get-boot-log -g rg-linux-lab -n vm-linux-lab | tail -20
az serial-console connect -g rg-linux-lab -n vm-linux-lab  # requires the serial-console extension and boot diagnostics
Fix (choose one)
  • Online: use the serial console to enter single-user mode (add systemd.unit=rescue.target or init=/bin/bash to the kernel line in GRUB), edit /etc/fstab, then run reboot -f.
  • Offline, automated: ALAR script az extension add -n vm-repair; az vm repair repair-button --button-command 'fstab' --verbose -g rg-linux-lab -n vm-linux-lab (creates a temporary repair VM and a copy of the OS disk, and comments out the data mounts that are not needed to boot).
  • Offline, manual: attach a copy of the OS disk to a rescue VM, edit fstab in a chroot, then swap the OS disk back.
ls -l /dev/disk/azure/scsi1/  # lun0 -> ../../../sdc
UUID=5c0e…  /data  xfs  defaults,nofail  0  2
Prevention
  • Enable boot diagnostics (a managed storage account is enough) and the serial console, and practice using them once. Set a password for a break-glass local account and store it in Key Vault, or rely only on run-command or ALAR.
  • Hand data disk mounts to cloud-init (disk_setup / fs_setup / mounts) or to configuration management, and use nofail consistently.

See Hour 3 Module 7 Troubleshooting in the cloud and Hour 3 Module 3 Managed disks.

#29 After stop (deallocate) or a size change, all data in /mnt is gone (Azure temporary disk)
$ ls /mnt
DATALOSS_WARNING_README.txt  lost+found
$ ls /mnt/redis-backup
ls: cannot access '/mnt/redis-backup': No such file or directory

Symptom: to save money, you stopped (deallocated) the VM overnight, and in the morning the Redis backups under /mnt were gone. The same happens after a resize, platform maintenance, or a redeploy.

Root cause: most Azure sizes include a temporary disk (local to the host, not a managed disk). According to the official documentation, its data can be lost during maintenance events, redeployments, or when the VM is stopped. A normal reboot keeps it. On Linux, it is usually /dev/disk/azure/resource, and Ubuntu images have cloud-init mount it at /mnt. Sizes whose names do not include a "d" have no temporary disk.

Diagnostic commands
ls -l /dev/disk/azure/ ; findmnt /mnt
lsblk -o NAME,SIZE,MOUNTPOINTS,MODEL
az vm show -g rg-linux-lab -n vm-linux-lab --query hardwareProfile.vmSize -o tsv
lrwxrwxrwx 1 root root  9 Nov 17 08:00 resource -> ../../sdb
lrwxrwxrwx 1 root root 10 Nov 17 08:00 resource-part1 -> ../../sdb1
TARGET SOURCE    FSTYPE OPTIONS
/mnt   /dev/sdb1 ext4   rw,relatime
Standard_D2ds_v5
Fix
  • Lost data can only be restored from backup. Move persistent data to a managed data disk (or Azure Files or Blob). Use the temporary disk only for swap, caches, and files that can be rebuilt.
az vm disk attach -g rg-linux-lab --vm-name vm-linux-lab --name vm-linux-lab-data --new --size-gb 32 --sku StandardSSD_LRS
# swap on the temporary disk: on Ubuntu, use cloud-init (mounts/swap); on RHEL-family systems, use ResourceDisk.EnableSwap in waagent.conf (see the documentation)
Prevention
  • Mark which paths are temporary storage in the architecture review checklist. Application data directories must not point to /mnt.
  • AWS instance store works the same way: data is lost when you stop, hibernate, or terminate the instance.

See Hour 3 Module 3 Temporary disks and Hour 4 Module 3 Instance store.

#30 cloud-init status: error. The custom data / user data contains the myapp install steps, but after the VM starts, nothing is installed
$ cloud-init status --long
status: error
extended_status: error - done
boot_status_code: enabled-by-generator
detail: DataSourceAzure [seed=/dev/sr0]
errors:
	- (scripts_user) Failed to run module scripts_user (scripts in /var/lib/cloud/instance/scripts)
recoverable_errors:
WARNING:
	- cloud-config failed schema validation! You may run 'sudo cloud-init schema --system' to check the details.

Symptom: the VM is created, but myapp is not installed. Or only part of the steps run (the user was created, but the service did not start).

Root cause: on first boot, cloud-init runs the cloud-config modules in four stages (local → network → config → final). Common failures: (1) YAML indentation or type errors, or the first line is not #cloud-config, so the file is treated as plain text and ignored; (2) a runcmd command fails because the network is not ready, the apt lock is held (#9), or there is a typo; (3) a script assumes an interactive environment (a sudo prompt, or $HOME). runcmd and scripts_user run as root in the final stage.

Diagnostic commands
cloud-init status --long
sudo cloud-init schema --system --annotate | head -30
sudo grep -nE 'WARNING|Traceback|Failed' /var/log/cloud-init.log | tail -10
sudo tail -40 /var/log/cloud-init-output.log  # stdout/stderr of runcmd and scripts
cloud-init analyze show | tail -15  # time spent in each stage
Fix
sudo cloud-init schema -c ./user-data.yaml --annotate  # validate locally first
# after the fix, rerun on a test VM (this reruns all first-boot modules, so use caution in production):
sudo cloud-init clean --logs && sudo reboot
Prevention
  • Validate cloud-config locally with Multipass (multipass launch --cloud-init user-data.yaml). Run cloud-init schema in CI.
  • Keep cloud-init to minimal bootstrapping (users, repositories, and pulling configuration). Put complex logic in Ansible or in images pre-built with Packer. End with a health check, and write the result to logs or tags.

See Hour 3 Module 2 cloud-init, Hour 4 Module 2, and Hour 5 Module 3 Packer.

#31 VM agent status: Not Ready. Extensions, run-command, and Update Manager assessments all time out
$ az vm get-instance-view -g rg-linux-lab -n vm-linux-lab --query "instanceView.vmAgent.statuses[0].{code:code,msg:message}"
{ "code": "ProvisioningState/Unavailable", "msg": "VM Agent is unresponsive." }
$ az vm run-command invoke -g rg-linux-lab -n vm-linux-lab --command-id RunShellScript --scripts "uptime"
(times out after a long wait)

Symptom: you can SSH into the VM, but everything that depends on extensions fails or times out. This includes the Entra sign-in extension, AMA, run-command, and Update Manager patch assessment and installation.

Root cause: the Azure Linux agent (walinuxagent; on Ubuntu the service name is walinuxagent, and on RHEL-family systems it is waagent) reports status and pulls extensions through 168.63.129.16 (WireServer). Common causes: the agent is disabled or removed, a host firewall or custom route blocks 168.63.129.16, its Python dependency is broken, a full disk (#18) prevents it from writing status, or the image is outdated and its agent version is no longer supported.

Diagnostic commands
systemctl status walinuxagent --no-pager | head -5; waagent --version
sudo tail -30 /var/log/waagent.log | grep -iE 'error|exception|goal state'
curl -s -m5 -o /dev/null -w '%{http_code}\n' http://168.63.129.16/?comp=versions
sudo nft list ruleset | grep -n '168.63.129.16'; df -h /var
Fix
sudo systemctl enable --now walinuxagent
sudo apt-get install --only-upgrade -y walinuxagent  # RHEL-family: dnf update WALinuxAgent
# allow 168.63.129.16 (TCP 80/32526), delete the blocking rules, then go to Update Manager and "Check for updates"
Prevention
  • CIS hardening and custom firewall baselines must allow 168.63.129.16 and 169.254.169.254. Do not disable the agent in the image.
  • Handle patching with Azure Update Manager (periodic assessment plus maintenance configurations). Use Azure Resource Graph to query for VMs whose agent is unavailable, and alert on them.

See Hour 3 Module 2 and Hour 3 Module 6 Azure Update Manager.

#32 AMA extension shows Succeeded, but Log Analytics has no Syslog or Heartbeat data for vm-linux-lab
// Log Analytics
Heartbeat | where Computer == "vm-linux-lab" | take 5
(no results)
Syslog | where Computer == "vm-linux-lab" | summarize count() by Facility
(no results)

Symptom: Azure Monitor Agent was installed in hour 3. Alerts never fire, and the workspace has no data at all for this VM.

Root cause: the data collection rule (DCR), not the AMA, decides what is collected and which workspace receives it. The VM also needs an association with the DCR (DCRA) before configuration is delivered. Other causes: the VM has no managed identity (AMA uses it to authenticate), outbound access to *.handler.control.monitor.azure.com and to the workspace data ingestion endpoint is blocked, the DCR's Syslog facility or level filters out the logs you need, or a leftover legacy Log Analytics agent (MMA/OMS, now retired) conflicts with it.

Diagnostic commands
VMID=$(az vm show -g rg-linux-lab -n vm-linux-lab --query id -o tsv)
az monitor data-collection rule association list --resource "$VMID" -o table
az vm extension show -g rg-linux-lab --vm-name vm-linux-lab -n AzureMonitorLinuxAgent --query provisioningState -o tsv
# inside the VM:
systemctl status azuremonitoragent --no-pager | head -3
sudo ls /etc/opt/microsoft/azuremonitoragent/config-cache/configchunks/ 2>/dev/null | head
Fix
az monitor data-collection rule association create --name dcra-linux-lab --resource "$VMID" \
  --rule-id "$(az monitor data-collection rule show -g rg-linux-lab -n dcr-linux-lab --query id -o tsv)"
# a few minutes later: Heartbeat | where Computer == "vm-linux-lab" | top 1 by TimeGenerated
Prevention
  • Use the built-in Azure Policy initiative to deploy AMA and the DCR association together. Alert when Heartbeat is missing for more than 15 minutes (monitor the monitoring system).
  • Manage DCRs as code (Bicep/Terraform) and reuse them across environments.

See Hour 3 Module 5 Azure Monitor Agent and DCR.

#33 ubuntu@3.98.x.x: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). (EC2)
$ ssh -i ~/.ssh/linux-lab.pem ubuntu@3.98.12.34
ubuntu@3.98.12.34: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Symptom: the AL2023 instance linux-lab from hour 4 cannot be reached by SSH. Trying several different keys does not help.

Root cause, listed by frequency: (1) wrong username. AL2023 defaults to ec2-user, Ubuntu AMIs use ubuntu, and RHEL uses ec2-user. (2) The key pair chosen at launch does not match your private key (cloud-init writes it only on first boot). (3) The private key permissions are too open, so the client refuses to use it (UNPROTECTED PRIVATE KEY FILE!). (4) The permissions on ~/.ssh inside the instance were changed incorrectly (#7). A security group or NACL problem shows up as a timeout, not as Permission denied.

Diagnostic commands
aws ec2 describe-instances --region ca-central-1 --filters Name=tag:Name,Values=linux-lab \
  --query 'Reservations[].Instances[].{id:InstanceId,key:KeyName,ami:ImageId,state:State.Name}' -o table
aws ec2 describe-images --region ca-central-1 --image-ids <ami-id> --query 'Images[0].Name' -o text
ssh -v -i ~/.ssh/linux-lab.pem ec2-user@3.98.12.34 2>&1 | grep -E 'Offering|Server accepts|Authentications'
Fix
chmod 600 ~/.ssh/linux-lab.pem && ssh -i ~/.ssh/linux-lab.pem ec2-user@3.98.12.34
# If the key is lost, skip SSH and use SSM Session Manager (#35) or EC2 Instance Connect to push a temporary public key:
aws ec2-instance-connect send-ssh-public-key --region ca-central-1 --instance-id i-0abc… --instance-os-user ec2-user --ssh-public-key file://~/.ssh/id_ed25519.pub
Prevention
  • In production, close inbound port 22 and use SSM Session Manager for all access (session auditing, no keys needed). When you need SSH, use SSM port forwarding or the EC2 Instance Connect Endpoint.

See Hour 4 Module 4 SSM, EC2 Instance Connect and SSH.

#34 curl http://169.254.169.254/latest/meta-data/ returns 401 (IMDSv2 required). Instance role credentials cannot be retrieved inside a container
$ curl -s -w ' HTTP %{http_code}\n' http://169.254.169.254/latest/meta-data/instance-id
 HTTP 401
$ docker run --rm --network bridge amazon/aws-cli sts get-caller-identity
Unable to locate credentials. You can configure credentials by running "aws configure".

Symptom: an old script that sends a plain GET to the metadata service fails on AL2023. The AWS CLI on the host works, but an older SDK in a Docker bridge network cannot get credentials.

Root cause: according to the official documentation, instances launched from the AL2023 AMI use only IMDSv2 by default (IMDSv1 is turned off), with a hop limit of 2 (set through the AMI's imds-support=v2.0). IMDSv2 first calls PUT /latest/api/token to get a session token (valid for 1 second to 6 hours), then sends requests with the X-aws-ec2-metadata-token header. A GET without a token returns 401. The hop limit controls how many network hops the token response can cross. A container bridge adds one hop, so with a hop limit of 1 the container cannot get a token. Some older SDKs do not support IMDSv2.

Diagnostic commands
aws ec2 describe-instances --region ca-central-1 --instance-ids i-0abc… --query 'Reservations[0].Instances[0].MetadataOptions'
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 300')
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/
{ "State": "applied", "HttpTokens": "required", "HttpPutResponseHopLimit": 2, "HttpEndpoint": "enabled", … }
linux-lab-ssm-role
Fix
  • Change the script to use a token (the two steps above), or use ec2-metadata (included in AL2023) or the SDK.
  • Containers: keep the hop limit at 2 (or raise it as needed). Better still, give containers their own identity (an ECS task role, or EKS Pod Identity / IRSA) instead of using the instance role.
  • Do not set HttpTokens back to optional just to support an old script. IMDSv1 is vulnerable to SSRF, which can be used to steal credentials.
Prevention
  • Set IMDS to default to v2 at the account level, and enforce it with an SCP or IAM condition on ec2:MetadataHttpTokens. Use the MetadataNoToken metric in CloudWatch to find programs that still use v1.

See Hour 4 Module 2 IMDSv2.

#35 An error occurred (TargetNotConnected) when calling the StartSession operation: i-0abc… isn't connected.
$ aws ssm start-session --region ca-central-1 --target i-0abc123def4567890
An error occurred (TargetNotConnected) when calling the StartSession operation: i-0abc123def4567890 isn't connected.
# on the instance, /var/log/amazon/ssm/amazon-ssm-agent.log:
SSM Agent unable to acquire credentials: unexpected error getting instance profile role credentials or calling UpdateInstanceInformation. Skipping default host management fallback: retrieved credentials failed to report to ssm. Error: RequestError: send request failed

Symptom: linux-lab in a private subnet never shows up in Fleet Manager, or it could connect before and suddenly cannot.

Root cause: the AL2023 AMI comes with SSM Agent preinstalled. To come online, it needs: (1) an identity: the instance profile includes AmazonSSMManagedInstanceCore (or Default Host Management Configuration is turned on); (2) network access to the ssm and ssmmessages endpoints (before agent 3.3.40.0, ec2messages is also needed). A private subnet needs a NAT gateway or a VPC interface endpoint, and the endpoint's security group must allow 443. VPC Block Public Access also blocks traffic through the internet gateway (IGW); (3) the agent is running and resources are not exhausted (CPU, memory, or a full root volume). A target in another account or Region also reports this error.

Diagnostic commands
aws ssm describe-instance-information --region ca-central-1 --filters Key=InstanceIds,Values=i-0abc… --query 'InstanceInformationList[].{ping:PingStatus,agent:AgentVersion}'
aws ec2 describe-iam-instance-profile-associations --region ca-central-1 --filters Name=instance-id,Values=i-0abc… --query 'IamInstanceProfileAssociations[].IamInstanceProfile.Arn'
aws ec2 describe-vpc-endpoints --region ca-central-1 --filters Name=vpc-id,Values=vpc-0123… --query 'VpcEndpoints[].ServiceName'
# on the instance (through the EC2 serial console): sudo systemctl status amazon-ssm-agent; sudo tail /var/log/amazon/ssm/amazon-ssm-agent.log
Fix
aws ec2 associate-iam-instance-profile --region ca-central-1 --instance-id i-0abc… --iam-instance-profile Name=linux-lab-ssm-profile
for s in ssm ssmmessages; do aws ec2 create-vpc-endpoint --region ca-central-1 --vpc-id vpc-0123… --vpc-endpoint-type Interface \
  --service-name com.amazonaws.ca-central-1.$s --subnet-ids subnet-0aa… --security-group-ids sg-0endpoint… --private-dns-enabled; done
# on the instance: sudo systemctl restart amazon-ssm-agent
Prevention
  • Create the instance profile and endpoints once in IaC. Turn on Default Host Management Configuration at the account level as a fallback.
  • Alert on managed nodes where PingStatus != Online. SSM is also a prerequisite for Patch Manager and Run Command.

See Hour 4 Module 4 and Hour 4 Module 6 SSM Patch Manager.

#36 The mounted /dev/sdf does not exist (it is actually /dev/nvme1n1); df shows no change after the EBS resize
$ sudo mkfs.xfs /dev/sdf
Error accessing specified device /dev/sdf: No such file or directory
$ lsblk
nvme0n1      259:0  0  20G  0 disk
├─nvme0n1p1  259:1  0  20G  0 part /
nvme1n1      259:4  0  50G  0 disk
$ df -h / | tail -1
/dev/nvme0n1p1   8.0G  7.6G  0.4G  95% /

Symptom: operations using the console device name /dev/sdf fail; or the root volume was grown from 8 GiB to 20 GiB, but the system still shows 8 GiB.

Root cause: on Nitro, EBS appears as NVMe. The kernel names devices nvmeXn1 in discovery order, which has nothing to do with the /dev/sdf given in the API (the name can change after a reboot). AL2023 uses udev rules to create compatibility symlinks; the by-id names include the volume ID. Resizing takes two steps: enlarge the volume (modify-volume; usable once it is in the optimizing state), then grow the partition (growpart) and the filesystem (the AL2023 root defaults to XFS → xfs_growfs; ext4 → resize2fs). The cloud-init in Ubuntu and AL2023 images grows the root partition automatically at boot, so a reboot also works.

Diagnostic commands
ls -l /dev/disk/by-id/ | grep -i 'Elastic_Block_Store' | head
sudo nvme list 2>/dev/null | head -5  # nvme-cli: show volume IDs
aws ec2 describe-volumes-modifications --region ca-central-1 --volume-ids vol-0abc… --query 'VolumesModifications[0].{state:ModificationState,target:TargetSize}'
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
Fix
sudo growpart /dev/nvme0n1 1 && sudo xfs_growfs -d /  # root volume (XFS)
DEV=/dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_vol0abc…  # stable name for the data volume
sudo mkfs.xfs "$DEV" && echo "UUID=$(sudo blkid -s UUID -o value "$DEV") /data xfs defaults,nofail 0 2" | sudo tee -a /etc/fstab
sudo mkdir -p /data && sudo mount -a && df -h /data
Prevention
  • Scripts always address volumes by volume ID or UUID; add nofail to fstab (#21).
  • After an EBS modification, you must wait 6 hours before you can modify the same volume again, so leave headroom in capacity planning.

See Hour 4, Module 3: EBS volumes, Hour 2, Module 3.

#37 Changed user data, but the new script did not run after the instance was restarted
$ aws ec2 modify-instance-attribute --instance-id i-0abc… --attribute userData --value file://user-data-v2.b64   # the instance must be stopped first
$ aws ec2 start-instances --instance-ids i-0abc…
# On the instance:
$ sudo grep -c 'myapp v2' /var/log/cloud-init-output.log
0
$ sudo ls /var/lib/cloud/instance/sem/ | grep -E 'scripts_user|runcmd'
config_runcmd
config_scripts_user

Symptom: you change the user data to update the configuration, then stop, modify and start the instance, and nothing changes. Changing custom data on Azure behaves the same way.

Root cause: most cloud-init modules (including runcmd, scripts_user, users and write_files) run once per instance. cloud-init writes a semaphore under /var/lib/cloud/instance/sem/ keyed by the instance ID, so the same ID never runs them again. Only bootcmd and the scripts under /var/lib/cloud/scripts/per-boot/ run on every boot. User data is first-boot provisioning, not a configuration management channel.

Diagnostic commands
cloud-init query instance_id; cat /var/lib/cloud/data/instance-id
sudo cloud-init query userdata | head -5  # the user data the instance currently sees (the new version)
ls /var/lib/cloud/instance/sem/ /var/lib/cloud/scripts/per-boot/
Fix
  • Change the configuration with SSM Run Command / State Manager, Ansible, or by rebuilding the instance (immutable infrastructure: new user data → new instance → shift traffic).
  • If it must run on every boot, put it in bootcmd or a per-boot script (keep it idempotent). On a test machine, sudo cloud-init clean --logs --reboot makes cloud-init run again as if it were a first boot.
Prevention
  • Auto Scaling groups and VMSS roll out replacement instances from a new launch template or model, instead of changing the user data of running instances.
  • Do not put secrets in user data: any process that can read the instance metadata can read it. Fetch them from Secrets Manager or Key Vault using the instance identity.

See Hour 4, Module 2, Hour 3, Module 2.

#38 Instance status check fails after a kernel upgrade: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.912345] VFS: Cannot open root device "UUID=…" or unknown-block(0,0): error -6
[    1.912400] Please append a correct "root=" boot option; here are the available partitions:
[    1.913001] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Symptom: unattended upgrades installed a new kernel. After the reboot, the EC2 instance status check fails, or the Azure VM cannot be reached. The console output stops at a kernel panic.

Root cause: the kernel cannot find the root filesystem. unknown-block(0,0) is usually caused by a missing initramfs, or an initramfs without the storage driver (NVMe, Hyper-V storvsc/virtio). Typical triggers: the disk was full when the initramfs was generated, /boot is too small, the initramfs tool was changed (26.04 defaults to Dracut instead of initramfs-tools) and the configuration is incomplete, or the kernel was built by hand. Or the UUID in root= is wrong.

Diagnostics (out-of-band)
aws ec2 get-console-output --region ca-central-1 --instance-id i-0abc… --latest --output text | tail -20
aws ec2 describe-instance-status --region ca-central-1 --instance-ids i-0abc… --query 'InstanceStatuses[0].{sys:SystemStatus.Status,inst:InstanceStatus.Status}'
az vm boot-diagnostics get-boot-log -g rg-linux-lab -n vm-linux-lab | grep -iE 'panic|VFS'
# After the fix, check on the machine's kernel:
ls -l /boot/; lsinitrd /boot/initrd.img-$(uname -r) 2>/dev/null | grep -E 'nvme|hv_storvsc|virtio_blk' | head
Fix
  • Online: EC2 or Azure serial console → in GRUB, boot the previous kernel → rebuild the initramfs (26.04: sudo dracut --force --kver <version>; 24.04: sudo update-initramfs -u -k <version>) → sudo update-grub.
  • Offline: stop the instance, attach the root volume to a rescue instance in the same availability zone (Azure: az vm repair create), rebuild the initramfs in a chroot, then attach the volume back.
Prevention
  • Roll patches out to a canary instance first and verify that it reboots correctly. Keep space free in /boot (remove old kernels).
  • The EC2 serial console must be enabled at the account level and needs a local user with a password. The Azure serial console depends on boot diagnostics. Set both up in advance, not during an incident.

See Hour 7, Module 6: boot failures, Hour 4, Module 7: EC2 serial console, Hour 3, Module 7.

Typical failures at each stage of the first-boot chain on cloud LinuxFirmware → GRUBKernel + initramfssystemdfstab · local-fscloud-initlocal → networkMetadata serviceIMDS 169.254.169.254config → finalUsers · packages · runcmdCloud agent · loginwaagent · ssm#38 kernel panicinitramfs missing driverStatus check failed#28 #21 emergency modeDevice name drift#36 NVMe naming#30 schema error#29 temporary disk mounted at /mntgrowpart to expand root#34 IMDSv2 401Hop limitManaged identity token#37 runs only once#9 apt lock#30 runcmd failure#31 agent Not Ready#35 #26 #27 #33#32 AMA no dataOut-of-band tools: when the first three stages fail, SSH and the agents are both unavailableAzure: boot diagnostics · serial console · az vm repair (ALAR) · run-command (needs agent) AWS: console output and screenshot · EC2 serial console · rescue instance · SSM (needs agent)Rule: the earlier the stage that fails, the more you need tools that do not depend on software inside the instance
Figure 3-1: first work out which stage of the boot chain is stuck, then choose an out-of-band tool
How identity reaches the instance: Azure managed identity vs AWS instance profileProcess (az / SDK / agent)Request token or credentials169.254.169.254Azure IMDS · EC2 IMDSv2Entra ID / STSShort-lived token / temporary credentialsCloud APIRBAC / IAM policyAzure: requests must include the Metadata: true headerAWS: first PUT to get a token; hop limit #34No identity assigned → #27 exit code 22No instance profile → #35Missing data-plane role → #26Common to both clouds: credentials are never written to disk, rotate automatically, and are reachable only from inside the instance. That is why SSRF and container escape are the main threats.
Figure 3-2: a program running on the instance does not need any long-term keys

Interactive troubleshooting tree for “cloud VM won't connect or won't start”

Start from the first symptom. Branches are organized by “the earlier the failure, the sooner you need out-of-band tools.”

Environment and costs Labs 3-A and 3-B use only local Multipass (free). Lab 3-C needs the vm-linux-lab from hour 3 (Standard_B2s class, a few cents per hour, billed as used) and permission to assign roles on the resource group (Owner, or User Access Administrator / RBAC Administrator). Lab 3-D needs the linux-lab from hour 4 (t3.micro class, billed as used). Clean up or stop the resources as soon as you finish.

Lab 3-A: reproduce cloud-init failures locally (#30, #37)

On your computer, write a cloud-config with an indentation error and a failing command, then launch a temporary VM:
cat > lab8-ci.yaml <<'EOF'
#cloud-config
packages:
  - redis-server
runcmd:
  - echo "myapp v1 bootstrap" > /var/tmp/bootstrap.txt
  - /opt/myapp/install.sh  # does not exist, fails on purpose
write_files:
- path: /etc/myapp/myapp.env
   content: REDIS_URL=redis://127.0.0.1:6379/0
EOF
multipass launch --name lab8ci --cpus 1 --memory 1G --disk 8G --cloud-init lab8-ci.yaml
multipass exec lab8ci -- cloud-init status --long | head -12
status: error
extended_status: error - done
…
errors:
	- (scripts_user) Failed to run module scripts_user (scripts in /var/lib/cloud/instance/scripts)
Locate the problem: schema validation + output log:
multipass exec lab8ci -- sudo cloud-init schema --system --annotate | head -15
multipass exec lab8ci -- sudo tail -5 /var/log/cloud-init-output.log
/var/lib/cloud/instance/scripts/runcmd: 3: /opt/myapp/install.sh: not found
2026-11-17 11:02:41,123 - cc_scripts_user.py[WARNING]: Failed to run module scripts_user …
Verify “runs only once”: after a reboot, runcmd does not run again, and the semaphore file is still there:
multipass restart lab8ci && multipass exec lab8ci -- ls /var/lib/cloud/instance/sem/ | grep -E 'runcmd|scripts_user'
multipass delete --purge lab8ci
config_runcmd
config_scripts_user

Lab 3-B: pre-check fstab before rebooting (#21, #28)

On linuxlab, temporarily append to fstab an entry that points to a non-existent UUID. Run the pre-check only, without rebooting:
sudo cp /etc/fstab /etc/fstab.lab8.bak
echo 'UUID=00000000-0000-0000-0000-00000000lab8 /mnt/lab8data xfs defaults 0 2' | sudo tee -a /etc/fstab
sudo findmnt --verify 2>&1 | tail -3
sudo systemctl daemon-reload && systemctl show 'mnt-lab8data.mount' -p RequiredBy -p WantedBy
   [E] unreachable source: UUID=00000000-0000-0000-0000-00000000lab8
0 parse errors, 1 error, 0 warnings
RequiredBy=local-fs.target
WantedBy=

RequiredBy=local-fs.target is why the system enters emergency mode after a reboot.

Add nofail and check the dependencies again, then restore the original file:
sudo sed -i 's#xfs defaults 0 2#xfs defaults,nofail 0 2#' /etc/fstab && sudo systemctl daemon-reload
systemctl show 'mnt-lab8data.mount' -p RequiredBy -p WantedBy
sudo cp /etc/fstab.lab8.bak /etc/fstab && sudo rm /etc/fstab.lab8.bak && sudo systemctl daemon-reload && sudo findmnt --verify | tail -1
RequiredBy=
WantedBy=local-fs.target
Success, no errors or warnings detected

Lab 3-C: Entra login missing a role (#26, Azure, costs money)

Confirm that the extension and identity are healthy, then temporarily remove your own login role:
ME=$(az ad signed-in-user show --query id -o tsv); RG=$(az group show -n rg-linux-lab --query id -o tsv)
az role assignment delete --assignee "$ME" --role "Virtual Machine Administrator Login" --scope "$RG"
sleep 120; az ssh vm -g rg-linux-lab -n vm-linux-lab -- -o ConnectTimeout=10 true
Connection closed by 20.151.x.x port 22
Restore the role and verify sudo:
az role assignment create --assignee "$ME" --role "Virtual Machine Administrator Login" --scope "$RG" >/dev/null
sleep 120; az ssh vm -g rg-linux-lab -n vm-linux-lab -- sudo -n true && echo "sudo OK"
sudo OK
Cleanup: az vm deallocate -g rg-linux-lab -n vm-linux-lab (or the az group delete -n rg-linux-lab --yes --no-wait from hour 3)

Lab 3-D: IMDSv2 token and hop limit (#34, AWS, costs money)

Connect to linux-lab through SSM, and compare v1 and v2 requests:
aws ssm start-session --region ca-central-1 --target $(aws ec2 describe-instances --region ca-central-1 --filters Name=tag:Name,Values=linux-lab Name=instance-state-name,Values=running --query 'Reservations[0].Instances[0].InstanceId' -o text)
# inside the session:
curl -s -o /dev/null -w 'v1: %{http_code}\n' http://169.254.169.254/latest/meta-data/instance-id
T=$(curl -sX PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60')
curl -s -H "X-aws-ec2-metadata-token: $T" http://169.254.169.254/latest/meta-data/instance-id; echo
v1: 401
i-0abc123def4567890
Temporarily set the hop limit to 1 and see the token fail to reach a container (on AL2023 you first need sudo dnf install -y docker && sudo systemctl start docker), then set it back to 2:
aws ec2 modify-instance-metadata-options --region ca-central-1 --instance-id i-0abc… --http-put-response-hop-limit 1 --http-tokens required
sudo docker run --rm public.ecr.aws/amazonlinux/amazonlinux:2023 curl -s -m 3 -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' || echo "no token (timeout)"
no token (timeout)
aws ec2 modify-instance-metadata-options --region ca-central-1 --instance-id i-0abc… --http-put-response-hop-limit 2 --http-tokens required
Cleanup: stop the instance with aws ec2 stop-instances --region ca-central-1 --instance-ids i-0abc… (or terminate all resources with the hour 4 cleanup script).

Teaching videos (titles and channels verified with YouTube oEmbed)

▶
Troubleshoot and diagnose Azure Virtual Machines with Serial Console | Azure Friday — Microsoft Developer
English · Serial console (#28, #38)
▶
How to use GRUB and the Azure Serial Console on a Linux Virtual Machine | Azure Tips and Tricks — Microsoft Azure
English · GRUB and single-user mode (#28, #38)
▶
Why can't I connect to my Amazon EC2 Linux instance using SSH? — Amazon Web Services
English · EC2 SSH troubleshooting (#33)
▶
How do I troubleshoot issues with AWS Systems Manager Session Manager? — Amazon Web Services
English · Session Manager troubleshooting (#35)
▶
Getting Started with cloud-init — Learn Linux TV
English · cloud-init introduction (#30, #37)

No verified video covers Entra login roles, AMA/DCR association or IMDSv2 hop limits. Storyboard:

Shot 1 (0:00) az ssh vm returns Connection closed. The portal IAM shows the user as Contributor but without the VM Login role. It succeeds after the role is assigned.
Shot 2 (1:00) Draw DCR → DCRA → AMA → workspace. After the association is deleted, Heartbeat stops.
Shot 3 (2:00) curl inside the instance returns 401; getting the token in two steps succeeds. In the container, hop limit 1 times out and succeeds after it is changed to 2.

Official docs

or score ≥ 70% on the quiz

Module 4 · Part A: Security, performance and kernel (production problems 39–50)

24:00 – 30:00 · OOM and cgroups, process and file limits, conntrack and SYN queue, hung tasks and soft lockups, load and D state, SELinux / AppArmor, clocks, filesystem errors
6 minlimits → kernel log → policy12 problems
Learning objectives
  • For each kind of resource exhaustion: who enforces it and where the evidence is. These are the kernel OOM killer (dmesg: Killed process), cgroup limits (memory.max, pids.max, and systemd's MemoryMax=/TasksMax=), process rlimits (LimitNOFILE=), and kernel tables (conntrack, SYN/accept queues).
  • Kernel warnings such as blocked for more than 120 seconds, soft lockup and Remounting filesystem read-only are symptoms. The root cause is usually in storage, the virtualization host or a driver.
  • Tell DAC denials apart from LSM denials. With an LSM denial the permission bits are all correct and the error is still EACCES; the evidence is in the audit log (avc: denied / apparmor="DENIED"). Never fix it by turning off SELinux or AppArmor.

Filter by keyword (such as Killed process, fork, Too many open files, conntrack, SYN, blocked, avc, read-only). Click a row to jump to its explanation.

#39 Out of memory: Killed process 2210 (gunicorn) total-vm:… anon-rss:… — myapp.service: Failed with result 'oom-kill'.
$ sudo journalctl -k -b | grep -iE 'oom|killed process' | tail -3
kernel: gunicorn invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
kernel: Memory cgroup out of memory: Killed process 2210 (gunicorn) total-vm:1843200kB, anon-rss:1021440kB, file-rss:10240kB, shmem-rss:0kB, UID:998 pgtables:2280kB oom_score_adj:0
$ journalctl -u myapp -n 2 --no-pager -o cat
myapp.service: The kernel OOM killer killed some processes in this unit.
myapp.service: Failed with result 'oom-kill'.

Symptom: the service restarts at random, 502 errors increase, and the application log shows no errors. The process was killed with SIGKILL, so it had no time to write a log.

Root cause: ① global OOM (“Out of memory: Killed process”): memory and swap are exhausted, and the kernel picks a victim by oom_score (mainly RSS, adjusted by oom_score_adj). ② cgroup OOM (“Memory cgroup out of memory”): a unit exceeds MemoryMax= (cgroup v2 memory.max), and the victim is chosen only within that cgroup. 26.04 has removed cgroup v1. systemd-oomd can also kill a whole cgroup based on PSI memory pressure, before the kernel OOM killer acts (log: “killed by systemd-oomd”). Common root causes: memory leaks, too many workers, loading a large file at once, and unbounded caches.

Diagnostic commands
sudo journalctl -k -b --no-pager | grep -A2 -iE 'invoked oom-killer|Killed process' | tail -8
systemctl show myapp -p MemoryMax -p MemoryHigh -p MemoryCurrent -p MemoryPeak -p OOMPolicy
cat /sys/fs/cgroup/system.slice/myapp.service/memory.events
free -m; cat /proc/pressure/memory
MemoryMax=1073741824
MemoryHigh=infinity
MemoryCurrent=1048211456
MemoryPeak=1073741824
OOMPolicy=stop
low 0
high 0
max 1832
oom 3
oom_kill 3
some avg10=12.40 avg60=8.10 avg300=2.03 total=91234567
Fix
sudo systemctl edit myapp  # [Service] MemoryHigh=800M (throttles reclaim first), MemoryMax=1G (hard limit); reduce gunicorn -w, or add --max-requests 1000 --max-requests-jitter 100
sudo systemctl restart myapp
# Find the leak: pidstat -r -p $(pgrep -d, -f gunicorn) 5; for Python, use tracemalloc / py-spy dump
Prevention
  • Set MemoryHigh/MemoryMax on every service so the blast radius stays inside the unit and protects sshd and the proxy. Key system services can set OOMScoreAdjust=-500.
  • Monitor the oom_kill count in memory.events and PSI. Plan capacity by peak RSS, not by average.

See Hour 7, Module 3: memory and OOM, Hour 6, Module 7: cgroups.

#40 -bash: fork: retry: Resource temporarily unavailable (even ls won't run)
$ ls
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
myapp[2210]: RuntimeError: can't start new thread

Symptom: you can SSH in, but almost no command starts, and the application reports that it cannot create threads. Memory and CPU are not under pressure.

Root cause: fork()/clone() returns EAGAIN, which means a task limit has been reached. ① cgroup pids.max (systemd TasksMax=; services use DefaultTasksMax by default, and user sessions are limited by the user slice). ② the user's RLIMIT_NPROC (ulimit -u). ③ the global kernel.pid_max / kernel.threads-max. Typical triggers: thread leaks, fork bombs, scripts that recurse without limit. Threads count as tasks too.

Diagnostic commands
systemctl show myapp -p TasksCurrent -p TasksMax
cat /sys/fs/cgroup/system.slice/myapp.service/pids.events
ps -eLo user | sort | uniq -c | sort -rn | head -3  # count threads per user
cat /proc/sys/kernel/pid_max /proc/sys/kernel/threads-max; ulimit -u
TasksCurrent=4915
TasksMax=4915
max 2317
  4921 myapp
   212 root
Fix
sudo systemctl restart myapp  # restore the service first (the shell cannot fork either: use exec, or switch user / use the console)
# Locate the leaking threads:
sudo py-spy dump --pid $(systemctl show -p MainPID --value myapp) | head -40
# A reasonable limit (not unlimited):
sudo systemctl edit myapp  # [Service] TasksMax=512
Prevention
  • Set a sensible TasksMax for each service, so a runaway service only hurts itself. Monitor the TasksCurrent trend.
  • When the shell cannot fork, built-in commands (echo, kill, read) still work. kill -9 <PID> is a built-in.

See Hour 6, Module 6: sysctl and resource limits, Hour 1, Module 5: processes.

#41 OSError: [Errno 24] Too many open files (ulimit -n is already 65535 in the shell)
myapp[2210]: OSError: [Errno 24] Too many open files
# When the global table is full (ENFILE, rare), the kernel prints:
kernel: VFS: file-max limit 9223372036854775807 reached

Symptom: under high concurrency, accept fails and files cannot be opened. Operators raised nofile in /etc/security/limits.conf and restarted the service, but nothing changed.

Root cause: EMFILE means the per-process RLIMIT_NOFILE has been reached. limits.conf is applied by PAM (pam_limits) to login sessions and has no effect on systemd services. A service's limits come from its unit's LimitNOFILE= (the systemd defaults are a soft limit of 1024 and a hard limit of 524288; the soft limit stays at 1024 for compatibility with old programs that use select()). A program can raise its own soft limit up to the hard limit. Another cause is a file descriptor leak (connections or files that are never closed). Raising the limit only delays the failure.

Diagnostic commands
PID=$(systemctl show -p MainPID --value myapp)
grep 'open files' /proc/$PID/limits
sudo ls /proc/$PID/fd | wc -l
sudo ls -l /proc/$PID/fd | awk '{print $NF}' | sed 's/[0-9]\+/N/g' | sort | uniq -c | sort -rn | head -5  # count by type
cat /proc/sys/fs/file-nr
Max open files            1024                 524288               files
1024
    998 socket:[N]
     14 /dev/null
4352	0	9223372036854775807
Fix
sudo systemctl edit myapp  # [Service] LimitNOFILE=65536
sudo systemctl restart myapp && grep 'open files' /proc/$(systemctl show -p MainPID --value myapp)/limits
# If the socket count keeps rising: check whether the connection pool, keep-alive and Redis connections are being reused
Prevention
  • Write the limits into the unit and keep them under configuration management. Monitor the per-process fd count (node_exporter process metrics or process_open_fds).
  • Three layers: the process rlimit (EMFILE) → the global fs.file-max (ENFILE) → dedicated per-user limits such as inotify (for example, SSM's fs.inotify.max_user_instances).

See Hour 6, Module 6.

#42 nf_conntrack: table full, dropping packet
$ sudo journalctl -k | tail -3
kernel: nf_conntrack: nf_conntrack: table full, dropping packet
kernel: nf_conntrack: nf_conntrack: table full, dropping packet
kernel: net_ratelimit: 1342 callbacks suppressed

Symptom: at peak hours, new connections time out at random (they are not refused), while existing connections work. The machine runs Docker or has a stateful firewall enabled (ufw/nftables/firewalld).

Root cause: once connection tracking is enabled, every flow takes one conntrack entry, including short connections during the TIME_WAIT period. When the table is full, the first packet of a new flow is dropped, and the client waits for retransmission until it times out. The table size is set by net.netfilter.nf_conntrack_max (the default depends on memory). Triggers: bursts of short connections, reverse proxies that do not reuse upstream connections, large numbers of UDP (DNS) queries, DDoS. The “nf_conntrack: ” prefix comes from pr_fmt, so repeated messages are normal.

Diagnostic commands
sudo sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
sudo conntrack -S | head -3  # conntrack-tools: insert_failed / drop counters
sudo conntrack -L 2>/dev/null | awk '{print $1, $4}' | sort | uniq -c | sort -rn | head
net.netfilter.nf_conntrack_count = 262144
net.netfilter.nf_conntrack_max = 262144
cpu=0   found=0 invalid=12 insert=0 insert_failed=0 drop=48211 early_drop=0 …
 201833 tcp TIME_WAIT
Fix
echo 'net.netfilter.nf_conntrack_max = 1048576' | sudo tee /etc/sysctl.d/60-conntrack.conf && sudo sysctl --system >/dev/null
# Also reduce the entries: reuse upstream connections (nginx keepalive), and shorten the TIME_WAIT tracking timeout:
sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_time_wait=30
# Stateless high-traffic ports can be set to notrack in the raw table (use with care, and only together with a firewall)
Prevention
  • Monitor the ratio of nf_conntrack_count / nf_conntrack_max (node_exporter provides the metrics) and alert above 75%.
  • A similar limit exists in the cloud: AWS security groups also have a connection tracking quota. The per-instance conntrack_allowance_exceeded counter is reported by the ENA driver and visible with ethtool -S eth0.

See Hour 6, Module 3: firewall, Hour 7, Module 5.

#43 request_sock_TCP: Possible SYN flooding on port 0.0.0.0:5000. Sending cookies.
kernel: TCP: request_sock_TCP: Possible SYN flooding on port 0.0.0.0:5000. Sending cookies.
$ nstat -az TcpExtListenOverflows TcpExtListenDrops
TcpExtListenOverflows           18322              0.0
TcpExtListenDrops               18322              0.0

Symptom: during traffic peaks (or when traffic is switched back after a release), p99 latency spikes and connections time out now and then. The kernel prints SYN flooding, but there is no attack.

Root cause: a listening socket has two queues. The SYN (half-open) queue and the accept (fully established) queue. If the application calls accept() too slowly (all workers busy, event loop blocked), the accept queue fills up. The kernel then drops handshakes and counts ListenOverflows. If the SYN queue fills, the kernel prints this message and enables SYN cookies. Accept queue length = min(backlog passed to listen(), net.core.somaxconn). gunicorn's default backlog is 2048. See the Send-Q column of ss -ltn.

Diagnostic commands
ss -ltn 'sport = :5000'  # LISTEN line: Recv-Q = currently queued, Send-Q = queue limit
nstat -az | grep -E 'ListenOverflows|ListenDrops|SyncookiesSent'
sysctl net.core.somaxconn net.ipv4.tcp_max_syn_backlog net.ipv4.tcp_syncookies
pidstat -t -p $(pgrep -d, -f gunicorn) 1 3 | tail -5  # are the workers saturated?
State  Recv-Q Send-Q Local Address:Port
LISTEN 2049   2048         0.0.0.0:5000
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_syncookies = 1
Fix
  • The real problem is processing capacity: add workers or async workers, optimize slow requests, scale out horizontally. Queues are only a buffer.
  • Short-term relief: gunicorn --backlog 4096 with net.core.somaxconn ≥ the backlog. Keep tcp_syncookies=1.
Prevention
  • Monitor the increase in ListenOverflows and the Recv-Q of LISTEN sockets. Apply connection rate limiting and slow start at the load balancer (warm up new instances).

See Hour 7, Module 5, Hour 6, Module 6: sysctl.

#44 INFO: task jbd2/sda1-8:245 blocked for more than 122 seconds.
kernel: INFO: task jbd2/sda1-8:245 blocked for more than 122 seconds.
kernel:       Not tainted 7.0.0-15-generic #15-Ubuntu
kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kernel: task:jbd2/sda1-8     state:D stack:0     pid:245   tgid:245   ppid:2      flags:0x00004000

Symptom: the system freezes intermittently for tens of seconds to a few minutes. SSH connects but commands do not return, and every process that writes files hangs. Then the kernel prints hung task messages and call stacks.

Root cause: the hung task detector finds a task in D state (uninterruptible sleep) for longer than hung_task_timeout_secs (default 120 seconds). This is a symptom: the task is waiting for I/O or a lock. Common root causes: storage that is extremely slow or unresponsive (cloud disk IOPS or throughput at its limit and throttled, burst credits used up, host storage failure, unresponsive NFS), dirty pages being written back all at once, and filesystem or driver bugs.

Diagnostic commands
iostat -xz 1 3 | tail -8  # await, %util, aqu-sz
ps -eo state,pid,comm,wchan:32 | awk '$1=="D"'
cat /proc/pressure/io; grep -E 'Dirty|Writeback' /proc/meminfo
# Cloud side: Azure disk metric "Data Disk IOPS Consumed Percentage" / AWS EBS VolumeQueueLength, BurstBalance
Device  r/s   w/s  rkB/s  wkB/s  r_await w_await aqu-sz %util
sda     2.0 498.0   16.0 63744.0   12.30 1840.55  916.2 100.0
D   245 jbd2/sda1-8   jbd2_journal_commit_transaction
D  2210 gunicorn      folio_wait_bit_common
Fix
  • Storage at its limit: upgrade the disk tier or IOPS (Azure Premium SSD v2; AWS gp3, where IOPS and throughput can be set separately), move high-I/O workloads to a dedicated disk, and reduce write amplification.
  • Dirty page storm: lower vm.dirty_background_ratio/vm.dirty_ratio (or use the *_bytes variants) to smooth out writeback.
  • NFS: use suitable mount options (hard + timeo, with monitoring), and fix the server side.
Prevention
  • Do not “fix” this by setting hung_task_timeout_secs to 0. Alert on IO PSI and disk latency.
  • Benchmark the cloud disk with fio to confirm its actual IOPS and latency, and make sure you are not relying on burst credits.

See Hour 7, Module 4: disk I/O.

#45 watchdog: BUG: soft lockup - CPU#1 stuck for 23s! [kworker/1:2:1874]
kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 23s! [kworker/1:2:1874]
kernel: Modules linked in: …
kernel: CPU: 1 UID: 0 PID: 1874 Comm: kworker/1:2 Not tainted 7.0.0-15-generic #15-Ubuntu

Symptom: a VM prints soft lockup when the host is busy, with clock jumps and application timeouts. On bare metal, this usually points to a driver bug.

Root cause: a soft lockup means a CPU has stayed in kernel mode beyond the threshold (about 2×watchdog_thresh, default 20 seconds) without yielding to the scheduler. In a VM, the most common cause is a vCPU not being scheduled by the host (high steal time: overcommitted host, exhausted burst credits, live migration). The guest kernel wakes up and finds that much time has passed. Other causes: long loops in a driver or kernel bug, and a flood of interrupts.

Diagnostic commands
mpstat -P ALL 1 3 | tail -6  # %steal
vmstat 1 5  # st column
sudo journalctl -k -b | grep -E 'soft lockup|clocksource|hrtimer' | tail -5
# Cloud side: AWS T-series CPUCreditBalance; Azure B-series CPU Credits Remaining
CPU    %usr  %sys  %iowait  %steal  %idle
all    21.0   9.5      0.2    38.7   30.6
Fix
  • High steal: switch to a non-burstable or larger size, or move to a different host (Azure “redeploy”, or AWS stop then start).
  • If it points to a specific driver or module: upgrade the kernel and drivers (the cloud platform ENA and Hyper-V drivers are updated along with the kernel).
Prevention
  • In production, avoid burstable sizes that can run out of credits, or monitor the credit balance. Include steal in the CPU saturation check of the USE method.

See Hour 7, Module 2: CPU and load.

#46 load average: 38.12, 35.80, 22.41 —— but CPU is 80% idle (nfs: server … not responding)
$ uptime
 11:42:10 up 12 days,  3:01,  2 users,  load average: 38.12, 35.80, 22.41
$ vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st gu
 1 36      0 812344  9120 1904112    0    0     0     2  310  402  3  2 80 15  0  0
kernel: nfs: server 10.0.0.10 not responding, still trying

Symptom: the monitoring alert says “load 38 on a 2-core machine.” On-call assumes the CPU is saturated, and adding capacity does not help.

Root cause: the Linux load average is an exponential moving average of the number of R (runnable) and D (uninterruptible sleep) tasks. Other Unix systems count only CPU. When many processes are stuck in D state (waiting for NFS, a slow disk (#44), or kernel locks), the load is high while the CPU is idle. See the b column and wa in vmstat.

Diagnostic commands
ps -eo state,pid,comm,wchan:30 | awk '$1 ~ /D/' | head
cat /proc/pressure/cpu /proc/pressure/io
findmnt -t nfs,nfs4 -o TARGET,SOURCE,OPTIONS; nfsstat -m 2>/dev/null | head
Fix
  • Once the storage or NFS server or the network is restored, D-state tasks return on their own. Do not keep sending kill -9 to them, because they cannot receive signals.
  • Do not make a critical path depend on a single NFS server. Consider a managed file service (Azure Files / Amazon EFS) and set its mount options as documented.
Prevention
  • Alert on saturation: for CPU, use the run queue and PSI cpu; for I/O, use PSI io and await. Do not rely on load average alone.

See Hour 7, Module 1: USE method and 60-second analysis, Hour 7, Module 2.

#47 rhellab: nginx 502. error.log shows connect() to 127.0.0.1:5000 failed (13: Permission denied) —— avc: denied { name_connect }
2026/11/17 11:50:02 [crit] 3301#3301: *1 connect() to 127.0.0.1:5000 failed (13: Permission denied) while connecting to upstream, client: 10.0.0.9, …
$ sudo ausearch -m AVC -ts recent | tail -2
type=AVC msg=audit(1763380202.311:812): avc:  denied  { name_connect } for  pid=3301 comm="nginx" dest=5000 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:commplex_main_port_t:s0 tclass=tcp_socket permissive=0

Symptom: on Rocky/Alma 10, after adding an nginx reverse proxy in front of myapp, requests return 502. curl 127.0.0.1:5000 works, and the permission bits and the firewall are fine.

Root cause: with SELinux enforcing, nginx runs in the httpd_t domain. The default policy forbids it from actively connecting to arbitrary ports (name_connect). The errno is still 13 (EACCES), but DAC has already passed, so this is an LSM denial. Similar cases: listening on a non-standard port (name_bind, needs semanage port), or files in a non-standard directory with the wrong label (needs semanage fcontext + restorecon).

Diagnostic commands
getenforce; sudo ausearch -m AVC,USER_AVC -ts recent | audit2why | head -15
getsebool httpd_can_network_connect
sudo semanage port -l | grep -w 5000
ls -Zd /opt/myapp/app /opt/myapp/venv/bin/gunicorn
Enforcing
	Was caused by:
	One of the following booleans was set incorrectly.
	Description:
	Allow httpd to can network connect
	Allow access by executing:
	# setsebool -P httpd_can_network_connect 1
httpd_can_network_connect --> off
Fix
sudo setsebool -P httpd_can_network_connect 1  # allow httpd_t to make network connections (as audit2why suggests)
# More restrictive: allow connections only to HTTP-type ports. Add 5000 to http_port_t (use -m if it is in use), and enable httpd_can_network_relay
curl -sI http://127.0.0.1/ | head -1
Prevention
  • Run audit2why first. Prefer booleans, then port and file labels, and only then a custom policy module (audit2allow -M, which needs manual review). Do not run setenforce 0. At most, set a single domain to permissive while you investigate.
  • Keep SELinux booleans and labels under configuration management (Ansible ansible.posix.seboolean, community.general.sefcontext).

See Hour 6, Module 2: SELinux and AppArmor.

#48 apparmor="DENIED" operation="open" profile="myapp" name="/etc/myapp/tls.key" … (Ubuntu)
kernel: audit: type=1400 audit(1763381000.120:301): apparmor="DENIED" operation="open" class="file" profile="myapp" name="/etc/myapp/tls.key" pid=2210 comm="gunicorn" requested_mask="r" denied_mask="r" fsuid=998 ouid=0
myapp[2210]: PermissionError: [Errno 13] Permission denied: '/etc/myapp/tls.key'

Symptom: in hour 6 you enabled an AppArmor profile for myapp. Today TLS went live, and the new key file cannot be read, even though the myapp user owns it.

Root cause: AppArmor enforces access control by path. A process under the myapp profile can only access the paths and permissions listed in its rules, and new paths are denied by default. Also: distribution-provided profiles (such as mysqld and tcpdump) do not allow non-default data directories. Since Ubuntu 24.04, unprivileged user namespaces are restricted by default, so sandboxed programs such as browsers and some container tools need dedicated profiles.

Diagnostic commands
sudo aa-status | grep -A3 -E 'profiles are in enforce mode' | head; sudo aa-status | grep myapp
sudo journalctl -k --since -1h | grep 'apparmor="DENIED"' | tail -5
cat /proc/$(systemctl show -p MainPID --value myapp)/attr/current
   myapp
myapp (enforce)
Fix
sudo aa-complain myapp  # during investigation: log only, do not block
# Add minimal rules to /etc/apparmor.d/myapp:  /etc/myapp/tls.key r,
sudo apparmor_parser -r /etc/apparmor.d/myapp && sudo aa-enforce myapp
sudo systemctl restart myapp
Prevention
  • Keep profiles versioned with the application code and tested. Changes follow this path: run in complain mode for a while → aa-logprof suggests rules → manual review → enforce.

See Hour 6, Module 2.

#49 Release file for … is not valid yet (invalid for another 3h 12min 5s). / certificate is not yet valid (clock skew)
$ sudo apt update
E: Release file for http://archive.ubuntu.com/ubuntu/dists/resolute-updates/InRelease is not valid yet (invalid for another 3h 12min 5s). Updates for this repository will not be applied.
$ curl https://pypi.org
curl: (60) SSL certificate problem: certificate is not yet valid

Symptom: VMs restored from snapshots, laptop VMs resumed after a long suspend, and isolated machines without NTP access all have apt and TLS failures. Kerberos and Entra tokens and TOTP also fail because of the clock. Logs have wrong timestamps, which makes post-incident analysis hard.

Root cause: the clock is behind or ahead. On 26.04, new installs default to chrony (replacing systemd-timesyncd, and using NTS by default for Ubuntu time servers). Upgraded systems need a manual migration. Loss of sync happens when NTP is blocked (UDP 123, or the TCP 4460 used by NTS), or when a VM snapshot restore causes a jump larger than chrony's makestep threshold. In the cloud, Azure can use the host PTP clock source (/dev/ptp_hyperv), and AWS provides the Amazon Time Sync Service (169.254.169.123).

Diagnostic commands
timedatectl
chronyc tracking | grep -E 'Reference|System time|Leap'
chronyc sources -v | tail -5
systemctl is-active chrony systemd-timesyncd 2>/dev/null
               Local time: Mon 2026-11-17 08:30:10 UTC
System clock synchronized: no
              NTP service: active
Reference ID    : 00000000 ()
System time     : 11525.120334 seconds slow of NTP time
Leap status     : Not synchronised
Fix
sudo chronyc makestep  # step the clock immediately (needs a reachable time source)
# Allow outbound NTP/NTS, or use a time source inside the cloud (see the platform docs):
#   AWS: server 169.254.169.123 prefer iburst      Azure: refclock PHC /dev/ptp_hyperv poll 3 dpoll -2 offset 0
sudo systemctl restart chrony && chronyc tracking | grep 'Leap'
Prevention
  • Monitor clock offset (the timex metrics from node_exporter, chronyc tracking) and alert above 100 ms. Use UTC on all servers.
  • After a snapshot restore, sync the clock first, then start time-sensitive services (database replication, certificate rotation, token validation).

See Hour 2, Module 7: time synchronization.

#50 EXT4-fs (sda1): Remounting filesystem read-only — after this, every write fails with Read-only file system
kernel: EXT4-fs error (device sda1): ext4_lookup:1859: inode #131074: comm gunicorn: deleted inode referenced: 131080
kernel: EXT4-fs (sda1): Remounting filesystem read-only
myapp[2210]: OSError: [Errno 30] Read-only file system: '/var/lib/myapp/state.json'

Symptom: a service suddenly cannot write. touch reports Read-only file system, and mount shows the root partition as ro.

Root cause: when ext4 finds inconsistent metadata, it acts according to errors=. The Ubuntu root partition defaults to errors=remount-ro, which switches to read-only to prevent further damage. Triggers: underlying I/O errors (disk or storage backend failure, a cloud disk detached unexpectedly), unclean power loss, kernel or driver bugs, memory errors. Read-only is a protective measure, not the fault itself. XFS can shut down a filesystem after serious errors, with similar symptoms.

Diagnostic commands
findmnt -no OPTIONS /
sudo journalctl -k -b | grep -E 'EXT4-fs|I/O error|blk_update_request|nvme|sd[a-z]' | tail -10
sudo dumpe2fs -h /dev/sda1 2>/dev/null | grep -iE 'state|errors|error count|last error'
sudo smartctl -H /dev/sda 2>/dev/null | tail -2  # physical disk; for cloud disks, check the platform health events
ro,relatime,errors=remount-ro
Filesystem state:         clean with errors
Errors behavior:          Remount read-only
FS Error count:           3
Fix
  • Preserve the data first: take a snapshot of the cloud disk, and copy out the important data that is still readable.
  • The repair requires unmounting. The root partition must be checked from rescue mode or a rescue VM (the offline method in #28 and #38) with e2fsck -f /dev/sda1 (for XFS, use xfs_repair). Then boot normally.
  • If the kernel log keeps reporting I/O errors, fix the storage first (replace the disk, or rebuild the volume from a snapshot). Otherwise the damage will continue.
Prevention
  • Alert on EXT4-fs error / I/O error. Take snapshots regularly and practice restores. Keep data on replaceable data disks so the root disk can be rebuilt at any time (immutable infrastructure).

See Hour 7, Module 4, Hour 7, Module 6: rescue mode.

Resource limit layers: who enforces them, what happens when they are exceeded, and where the evidence isProcess rlimitLimitNOFILE= · ulimitEMFILE #41 · NPROC #40Evidence: /proc/PID/limitscgroup v2 (systemd unit)MemoryMax · TasksMax · CPUQuotaoom-kill #39 · EAGAIN #40Evidence: memory.events · pids.eventsWhole machine / kernel tablesMemory · pid_max · conntrackOOM #39 · packet drops #42 · #43Evidence: dmesg / journalctl -kCloud platformDisk IOPS · CPU creditshung task #44 · steal #45Evidence: platform metricsAccess control: DAC → ACL → capabilities → LSMPermission bits all correct but still EACCES → check the audit logSELinux avc: denied #47 · AppArmor DENIED #48Fix with booleans, labels or rules, not by disablingKernel “warning” messages = symptomsblocked for more than … → storage / lockssoft lockup → steal / driverRemounting read-only → I/O error #50
Figure 4-1: first ask “which layer's limit was triggered.” The location of the evidence follows from that.

A simulator of the resource gates a request passes through

Choose a scenario and click “Run” to see which gate the myapp request fails at, and what the kernel or systemd records (the order is illustrative).

$ Waiting to run…
Environment linuxlab (2 vCPU / 4 GB). All limits are added with l8_inject to myapp.service or to a one-off systemd-run transient unit, so the whole machine is not affected. Run l8_heal when you finish.

Lab 4-A: cgroup OOM (#39)

Allocate 300 MB of memory in a transient unit limited to 100 MB:
sudo systemd-run --unit=lab8-oom -p MemoryMax=100M -p MemorySwapMax=0 --wait \
  python3 -c 'b=bytearray(300*1024*1024); print("allocated")'; echo "exit=$?"
journalctl -u lab8-oom -n 3 --no-pager -o cat; sudo journalctl -k -n 2 --no-pager -o cat | grep -i killed
Running as unit: lab8-oom.service; invocation ID: …
Finished with result: oom-kill
Main processes terminated with: code=killed/status=KILL
exit=137
lab8-oom.service: The kernel OOM killer killed some processes in this unit.
lab8-oom.service: Failed with result 'oom-kill'.
Memory cgroup out of memory: Killed process 5521 (python3) total-vm:…kB, anon-rss:…kB, …

137 = 128 + 9 (SIGKILL). Other processes on the machine are unaffected. That is the value of setting MemoryMax on each service.

Lab 4-B: TasksMax and fork failure (#40)

sudo systemd-run --unit=lab8-pids -p TasksMax=20 --wait --pipe \
  python3 -c '
import threading,time
n=0
try:
    while True:
        threading.Thread(target=time.sleep,args=(5,),daemon=True).start(); n+=1
except RuntimeError as e: print("threads:",n,"error:",e)'
threads: 19 error: can't start new thread

Lab 4-C: LimitNOFILE is unrelated to limits.conf (#41)

Check the service's actual limits, then open 1100 files with a soft limit of 1024:
grep 'open files' /proc/$(systemctl show -p MainPID --value myapp)/limits
sudo systemd-run --unit=lab8-fd -p LimitNOFILE=1024 --wait --pipe \
  python3 -c 'fs=[open("/dev/null") for _ in range(1100)]' 2>&1 | tail -1
Max open files            1024                 524288               files
OSError: [Errno 24] Too many open files: '/dev/null'
Raise the limits for myapp through a drop-in, then verify:
printf '[Service]\nLimitNOFILE=65536\n' | l8_inject && sudo systemctl restart myapp
grep 'open files' /proc/$(systemctl show -p MainPID --value myapp)/limits
l8_heal
Max open files            65536                65536                files
active

Lab 4-D: high load ≠ busy CPU (#46)

Use dm-delay to create an extremely slow loopback block device, which produces D-state tasks (needs dmsetup, installed by default on Ubuntu):
DEV=$(l8_loop slow 64M) && S=$(sudo blockdev --getsz $DEV)
echo "0 $S delay $DEV 0 2000" | sudo dmsetup create lab8slow  # each I/O is delayed by 2 seconds
for i in 1 2 3 4 5 6; do sudo dd if=/dev/mapper/lab8slow of=/dev/null bs=4k count=50 iflag=direct status=none & done
sleep 8; ps -eo state,comm | awk '$1=="D"' | sort | uniq -c; uptime; vmstat 1 2 | tail -1
      6 D dd
 12:10:31 up 3:02,  1 user,  load average: 5.12, 1.40, 0.52
 0  6      0 2810232 …    0    0     4     0  210  302  0  1 99  0  0  0
Cleanup (after the dd processes finish, remove the device):
wait; sudo dmsetup remove lab8slow; l8_clean

Teaching videos (titles and channels verified with YouTube oEmbed)

▶
Linux Performance Analysis in 60 seconds — Brendan Gregg
English · 60-second analysis checklist (#44–#46)
▶
Linux Performance Tools, Brendan Gregg, part 1 of 2 — Brendan Gregg
English · overview of performance tools
▶
What Happens When Linux Runs Out of Memory? — Nir Lichtman
English · OOM mechanics (#39)
▶
Solve SELinux errors: Troubleshooting basics — Red Hat
English · SELinux troubleshooting basics (#47)
▶
Linux Load Average: Simple Explanation for Beginners — Learn Linux TV
English · load average (#46). Note that Linux load includes D state.

No verified video covers conntrack table full, SYN/accept queue overflow, or ext4 read-only. Storyboard:

Shot 1 (0:00) A load tool opens short connections, and nf_conntrack_count approaches the limit. The kernel starts printing table full, and clients time out instead of being refused.
Shot 2 (1:00) Reduce gunicorn to 1 worker to create slow requests. Recv-Q in ss -ltn climbs to Send-Q, and ListenOverflows grows in nstat.
Shot 3 (2:00) Inject errors into a loopback ext4 with dmsetup, showing Remounting filesystem read-only and the repair with e2fsck.

Official docs

or score ≥ 70% on the quiz

Module 5 · Part B: Foundations and architecture (interview questions 1–13)

30:00 – 37:00 · command execution, boot process, kernel and system calls, processes and signals, filesystems and permissions, capabilities, virtual memory, load, differences between distributions, namespaces and cgroups, packages
7 minmechanism → command → production experience13 questions
Learning objectives
  • Be able to draw on a whiteboard the chains for “after you press Enter” and “after power-on,” and give a real failure for each step (refer to the Part A numbers).
  • Answer “why”: rm does not free space, root is denied, load is high while the CPU is idle, and a container is not a virtual machine.
  • Every answer should lead to a command you can type on the spot.

Skim the questions and what they test first, and mark the ones you are unsure of. Click a row to jump to the detailed answer.

Q1. What happens after you type ./deploy.sh > out.log in bash and press Enter, until the command finishes? Intermediate
30-second answer

bash reads the line → splits words and expands them (variables, globs, command substitution), handles redirection → looks up the command (alias, function, builtin, PATH; a name containing / is treated as a path) → fork() (in practice clone()) → the child runs open("out.log") and dup2 onto fd 1 → execve(): the kernel checks path permissions and loads the interpreter named in #! → the program runs, calling into the kernel through system calls → exit() → the parent shell wait()s, and the exit code goes into $?.

In-depth answer
  • Redirection happens before exec. The shell creates out.log as the current user, so sudo cmd > /root/x fails.
  • Exit codes: 0 success; 1–125 custom; 126 not executable (#1); 127 not found; 128+N killed by signal N (137 = SIGKILL, OOM #39).
  • fork uses copy-on-write. exec replaces the address space but keeps the fds (unless O_CLOEXEC is set).
strace -f -e trace=clone,clone3,execve,openat,dup2,wait4 bash -c './deploy.sh > out.log'
Common follow-up questions
  • Why don't builtins fork? cd has to change the shell's own directory, so builtins still work when fork fails (#40).
  • Is PATH lookup cached? bash has a hash table (cleared with hash -r).
Bonus points

Match errno values to Part A: EACCES (#1, #4), ENOENT (#2, bad interpreter), E2BIG (#19), EAGAIN (#40).

Wrong answers

“The shell runs the program directly.” This misses the separation of fork and exec, and the timing of redirection.

See Hour 1, Module 1, Hour 1, Module 2.

Q2. Describe how a Linux server (or cloud VM) boots, from power-on until you can log in over SSH. Intermediate
30-second answer

Firmware (UEFI, virtual in the cloud) → GRUB (Secure Boot via shim) loads the kernel and initramfs → the kernel initializes hardware and runs the initramfs init (loads storage drivers, unlocks LUKS, finds the real root) → switches to the real root and runs /sbin/init (systemd, PID 1) → starts units in parallel according to their dependencies, up to default.target (multi-user.target on servers) → sshd. In the cloud, cloud-init fetches configuration from the metadata service in stages during this time (hostname, users, keys, growing the root partition), and then the cloud agent registers.

In-depth answer
  • On 26.04, Dracut generates the initramfs by default (it replaces initramfs-tools). A missing driver causes VFS: Unable to mount root fs (#38).
  • The generator converts fstab entries into .mount units. A failed data disk drags down local-fs.target by default, which leads to emergency mode (#21, #28).
  • Analyze the boot with systemd-analyze, systemd-analyze critical-chain, and cloud-init analyze show.
Common follow-up questions
  • rescue.target vs emergency.target? rescue mounts the local filesystems and starts basic services. emergency starts almost nothing, and root is read-only.
  • What if you can't see the screen in the cloud? Use boot diagnostics, console output, or the serial console.
Bonus points

Map each stage to an out-of-band tool (Figure 3-1), and mention how Secure Boot / trusted boot affects self-compiled kernel modules.

Wrong answers

Describing SysV /etc/inittab and runlevels 0–6 with serial startup, and not mentioning systemd's parallel, dependency-based startup.

See Hour 7, Module 6, Hour 3, Module 2.

Q3. What are user mode and kernel mode? How does a system call happen? How can you see which system calls a process makes? Intermediate
30-second answer

The CPU has privilege levels. The kernel runs in privileged mode, with direct access to hardware and all memory. Applications run in user mode. To use files, networking, processes or memory services, they trap into the kernel through a system call (the x86-64 syscall instruction). The kernel dispatches on the call number and returns a result or -errno. glibc stores errno in a thread-local variable. To observe calls: strace (ptrace, high overhead), perf trace, eBPF (bpftrace, syscount).

In-depth answer
  • vDSO: high-frequency calls such as clock_gettime complete in user space without trapping into the kernel, so strace does not see them.
  • The cost of context switches and system calls shows up in the sy (vmstat) and cs columns.
strace -c -f -p $(systemctl show -p MainPID --value myapp)  # after Ctrl-C, shows statistics per system call
sudo bpftrace -e 'tracepoint:raw_syscalls:sys_enter /comm == "gunicorn"/ { @[args.id] = count(); }'  # count by call number; use ausyscall <number> to convert it to a name
# Older bpftrace versions use args->id. You can also use bcc's syscount (Ubuntu package bpfcc-tools, command syscount-bpfcc)
Common follow-up questions
  • Why be careful with strace in production? It stops the process at every system call, which can slow latency down by tens of times. Prefer eBPF.
Bonus points

Discuss seccomp (restricting system calls), how it relates to the default seccomp profile in containers, and SystemCallFilter=.

Wrong answers

“System calls are just calling library functions.” This confuses the libc wrapper functions with the actual kernel entry point.

See Hour 1, Module 1, Hour 7, Module 7.

Q4. What is the difference between a process and a thread? What are zombie and orphan processes? How do you deal with many zombies? Beginner
30-second answer

On Linux, processes and threads are both tasks (task_struct). The difference is how much they share: threads share the address space, fds and more (clone flags). A zombie (Z) has exited, but its parent has not called wait(), so it only occupies a process table entry. An orphan has a parent that exited first, so it is adopted and reaped by init (or a subreaper). Many zombies mean the parent process is faulty. Fix or restart the parent. Killing the zombies does not help.

In-depth answer
ps -eo pid,ppid,stat,comm | awk '$3 ~ /Z/'  # find zombies and their parents
ps -o pid,nlwp,cmd -p $(pgrep -f gunicorn | head -1)  # thread count (NLWP)
  • In a container, if PID 1 does not reap its child processes, zombies pile up → use tini or --init.
  • Threads also count toward pids.max/TasksMax (#40).
Common follow-up questions
  • What do zombies exhaust? PID numbers and process table entries. Eventually fork fails.
Bonus points

Mention that systemd is a subreaper, and that KillMode=control-group cleans up the whole group when a service stops (#23).

Wrong answers

“kill -9 the zombie process.”

See Hour 1, Module 5: processes, signals and job control.

Q5. What is the difference between SIGTERM, SIGKILL and SIGHUP? How does systemd stop a service? Intermediate
30-second answer

SIGTERM (15) requests termination. It can be caught for a graceful exit (finish requests, close connections). SIGKILL (9) is enforced by the kernel directly; it cannot be caught and gets no cleanup. SIGHUP originally meant terminal hangup, and daemons often use it to reload configuration. systemctl stop: ExecStop= (if set) → send KillSignal= (default SIGTERM) to the cgroup → wait for TimeoutStopSec (default 90 seconds) → if the process is still running, SIGKILL (FinalKillSignal=).

In-depth answer
  • gunicorn: TERM for a graceful shutdown, HUP to reload workers, USR2 for a graceful binary upgrade.
  • A container's PID 1 ignores SIGTERM by default if it has no handler, so docker stop often waits 10 seconds before sending SIGKILL.
  • A D-state process has to wait for I/O to return, even for SIGKILL (#46).
systemctl show myapp -p KillMode -p KillSignal -p TimeoutStopUSec
sudo systemctl kill -s HUP myapp
Common follow-up questions
  • Why shouldn't deployments always use kill -9? It interrupts requests, does not clean up temporary files and locks, and the data may be left inconsistent.
Bonus points

Zero-downtime release: the load balancer removes the instance (draining connections) → SIGTERM → wait → add the new version back once its health check passes.

Wrong answers

“SIGHUP just kills the process.”

See Hour 1, Module 5, Hour 2, Module 1.

Q6. What is an inode? What is the difference between hard links and symbolic links? Why isn't disk space freed after you delete a large file? Beginner
30-second answer

An inode stores metadata (owner, permissions, times, size, block locations) and the link count, but not the file name. A directory maps “name → inode number.” A hard link is another name for the same inode; it cannot cross filesystems or link directories. A symbolic link is a separate file that stores the target path, and it can dangle. unlink only removes a name. Blocks are freed only when the link count reaches 0 and no process has the file open. This is #18.

In-depth answer
stat -c '%i %h %n' file hardlink  # same inode, link count 2
sudo lsof +L1  # files with link count 0 that are still open
df -i  # inode usage (#19)
  • Within the same filesystem, mv only changes the directory entry, so it is atomic. Across filesystems it is a copy plus a delete. An “atomic replace” therefore has to use rename within the same filesystem.
Common follow-up questions
  • How do you recover a deleted file that is still open? cp /proc/<PID>/fd/<N> /tmp/recovered.
Bonus points

Tie together three production scenarios: inode exhaustion, deleted files that are still open, and atomic rename.

Wrong answers

“Symbolic and hard links are both shortcuts.”

See Hour 1, Module 2, Hour 2, Module 3.

Q7. Explain the Linux permission model. What do r, w and x mean on a directory? How are SUID, SGID, sticky bit, umask and ACLs used? Beginner
30-second answer

On a directory, r lists the names, w creates, deletes or renames entries (it requires x), and x enters the directory and accesses its entries (required for path resolution). SUID runs the program as the file owner (passwd). SGID on a directory makes new files inherit the directory's group (for team sharing). The sticky bit (the t in /tmp) lets only the owner delete their own files. umask removes bits from the default permissions (022 → files 644, directories 755). ACLs grant extra permissions to additional users and groups, limited by the mask.

In-depth answer
install -d -m 2770 -g devs /srv/shared  # SGID shared directory
setfacl -m u:myapp:rx /srv/shared; setfacl -d -m g:devs:rwX /srv/shared  # default ACL so new files inherit it
namei -l /srv/shared/report.txt
  • The permission check matches only the first applicable category: owner → named user → group → other (#4).
Common follow-up questions
  • Does deleting a file require w on the file? No. It requires w and x on the directory (the sticky bit adds another constraint).
Bonus points

SUID programs are a high-risk point for privilege escalation (audit with find / -perm -4000). They can be blocked with the nosuid mount option.

Wrong answers

“If a directory has r, you can read the files inside it.”

See Hour 1, Module 3.

Q8. What are Linux capabilities? How do you let a non-root service listen on port 80? Advanced
30-second answer

Capabilities split root's privileges into dozens of items: CAP_NET_BIND_SERVICE binds ports below 1024, CAP_NET_ADMIN configures networking, CAP_SYS_ADMIN is nearly root, CAP_LINUX_IMMUTABLE changes the i attribute (#3), and so on. Give a service only what it needs: systemd User=myapp + AmbientCapabilities=CAP_NET_BIND_SERVICE + CapabilityBoundingSet=CAP_NET_BIND_SERVICE. Or use file capabilities with setcap, or let a reverse proxy or load balancer listen on port 80.

In-depth answer
[Service]
User=myapp
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
grep Cap /proc/$(systemctl show -p MainPID --value myapp)/status | xargs -L1 echo; capsh --decode=0000000000000400
  • Capability sets: permitted, effective, inheritable, bounding and ambient. They are transformed on exec according to the rules. File capabilities only apply to ELF binaries, not to scripts.
  • net.ipv4.ip_unprivileged_port_start can lower the privileged-port threshold globally (use with care).
Common follow-up questions
  • Is root in a container real root? By default most capabilities are dropped, and seccomp and user namespaces apply (if enabled). --privileged gives back nearly all of them.
Bonus points

Mention systemd-analyze security myapp, which gives an exposure score, and tighten the settings one by one.

Wrong answers

“Run it as root and chmod 777, and it's fine.”

See Hour 6, Module 1 and Hour 6, Module 7.

Q9. Explain the output of free -m: what is buff/cache? How should you read available? Should you enable swap? Intermediate
30-second answer

Free memory is used as page cache (file data) and buffers, and it can be reclaimed. A low free value therefore does not mean you are short of memory. available is the kernel's estimate of how much memory can be allocated without swapping. When memory is tight, check it together with PSI. Swap gives anonymous pages somewhere to go. A moderate amount of swap (with vm.swappiness) lets the kernel move cold pages out and avoids premature OOM kills. But latency-sensitive services that swap heavily will thrash.

Deeper answer
  • Virtual memory and overcommit: malloc only reserves address space. A physical page is allocated on the first write that causes a page fault. vm.overcommit_memory takes the values 0, 1, or 2.
  • Anonymous pages vs. file pages; dirty page writeback (#44); cgroup v2 memory.high throttles and reclaims first, while memory.max triggers OOM (#39).
free -m; cat /proc/pressure/memory; vmstat 1 5  # check the si/so columns for swap-in and swap-out
grep -E 'MemAvailable|Dirty|AnonPages|Shmem' /proc/meminfo
Common follow-ups
  • Why did Kubernetes nodes once require swap to be turned off? kubelet's memory accounting and eviction logic assumed there was no swap. Newer versions are gradually adding support, so check the Kubernetes documentation for the current status.
Bonus points

Alert on memory using PSI (some/full) rather than a "free percentage." systemd-oomd is built on PSI.

Wrong answer

"Free shows only 200 MB left, so we need more RAM." This ignores reclaimable cache.

See Hour 7, Module 3.

Q10. What is load average? Does a load of 8 on a 2-core machine always mean a problem? Intermediate
30-second answer

Load average is the exponentially weighted moving average, over 1, 5, and 15 minutes, of the number of runnable (R) plus uninterruptible sleep (D) tasks. Compare it with the CPU count and look at what makes it up. A high R count means the CPU is saturated (see the vmstat r column and PSI cpu). A high D count means tasks are waiting on I/O or locks (#46), and adding CPUs will not help. Whether a load of 8 is a problem depends on your latency targets, saturation, and errors.

Deeper answer
uptime; nproc
vmstat 1 5  # r = run queue, b = D state, wa = I/O wait, st = steal
cat /proc/pressure/cpu /proc/pressure/io
ps -eo state | sort | uniq -c
Common follow-ups
  • Whose load does a container see? The whole host's. /proc/loadavg is not isolated per namespace, although tools such as LXCFS can change that.
Bonus points

Mention Brendan Gregg's historical explanation of why Linux counts D-state tasks in the load average, and the USE method.

Wrong answer

"Load is just CPU utilization."

See Hour 7, Module 1 and Hour 7, Module 2.

Q11. What are the main differences between Ubuntu and the RHEL family? Which default changes in Ubuntu 26.04 LTS affect operations? Beginner
30-second answer

Package management: apt/dpkg vs. dnf/rpm. Default firewall front ends: ufw vs. firewalld (both built on nftables). Mandatory access control: AppArmor vs. SELinux. Networking: netplan (+ systemd-networkd) vs. NetworkManager. Lifecycle: Ubuntu LTS standard support for 5 years (10 years total with Pro) vs. 10 years for RHEL. 26.04 changes: sudo-rs by default; rust-coreutils (cp, mv, and rm are still GNU); chrony instead of timesyncd on new installs; Dracut instead of initramfs-tools; APT 3.1 removes apt-key; systemd 259 removes cgroup v1; kernel 7.0; and OpenSSH 10.2 no longer generates DSA host keys.

Deeper answer
  • Impact: test anything that relies on advanced sudoers features or sudo-ldap. Scripts that parse coreutils error text may be affected. Time sync and custom initramfs configuration need to be migrated.
  • For comparison: Rocky/Alma 10.2 (RHEL 10.2 compatible, kernel 6.12 series).
Common follow-ups
  • How do you assess a major distribution upgrade? Read the release notes → build images in the pipeline → run automated tests (services, hardening baseline, monitoring agents) → canary → replace in batches (rebuilding is preferred over in-place upgrades).
Bonus points

Identify migration risks such as "26.04 is the last version to support SysV service scripts," and come up with a plan for them.

Wrong answer

"Distributions only differ in their package managers."

See Hour 1, Module 1 and Sources and versions.

Q12. How are containers implemented on Linux? What is the fundamental difference from virtual machines? Advanced
30-second answer

A container is a normal process plus namespaces (isolated views: pid, mnt, net, uts, ipc, user, cgroup, time), cgroups v2 (limits and accounting for CPU, memory, I/O, and pids), capability dropping, seccomp, and an LSM (to reduce the attack surface), and a union filesystem such as overlayfs as its root. Containers share the host kernel. A VM runs on virtual hardware provided by a hypervisor and has its own kernel. Containers are therefore fast and dense, but the isolation boundary is the kernel. A kernel vulnerability or excessive privileges (--privileged, mounting docker.sock) can lead to a container escape.

Deeper answer
sudo unshare --pid --fork --mount-proc --uts --net bash -c 'hostname lab8; ps -ef; ip link'
lsns | head; systemd-cgls --no-pager | head -20
  • systemd services are cgroups too. MemoryMax/TasksMax use the same mechanism as the container flags --memory/--pids-limit (#39, #40).
  • Stronger isolation: gVisor, Kata Containers, Firecracker microVMs.
Common follow-ups
  • Why can the host's dmesg show a container OOM? The same kernel performs the OOM kill.
Bonus points

Be ready to demonstrate with unshare live, or explain that rootless containers depend on user namespaces, and that Ubuntu uses AppArmor to restrict unprivileged user namespaces.

Wrong answer

"A container is a lightweight VM."

See Hour 6, Module 7 and Docker in 8 Hours.

Q13. How do you keep server packages reproducible and auditable? How do you pin versions and handle offline environments? Intermediate
30-second answer

Trusted sources: signed repositories bound with Signed-By (#11). Controlled versions: an internal mirror or snapshot repository, and when needed apt-mark hold, APT pinning, or dnf versionlock. Reproducible builds: Packer golden images that record the package manifest and SBOM. Auditable changes: patch platform compliance reports, /var/log/apt/history.log, and dnf history. For offline environments, build a local mirror with Pulp, Satellite, Landscape, or aptly/reposync.

Deeper answer
apt-cache policy redis-server; sudo apt-mark hold redis-server
dpkg-query -W -f='${Package} ${Version}\n' > packages-$(date +%F).txt
# RHEL family: sudo dnf install python3-dnf-plugin-versionlock && sudo dnf versionlock add redis
  • A hold only pauses upgrades. You need a process to release holds and follow up on security updates, or vulnerabilities will pile up.
Common follow-ups
  • How do you keep the same packages in dev and prod? Freeze repository snapshots by date, and promote environments from one snapshot to the next.
Bonus points

Mention Ubuntu Pro's ESM and Livepatch, RHEL's EUS, and CVE scanning (pro fix, OVAL).

Wrong answer

"Run apt upgrade -y to the latest version every time."

See Hour 1, Module 6 and Hour 5, Module 3.

Interview whiteboard diagram: user space, kernel, and hardware (Q1, Q3, Q12)User spacebash → fork/execgunicorn (myapp)systemd (PID 1)Container = process + nsglibc · vDSOsyscall (openat · execve · clone · socket · mmap) → return value or -errnoKernelScheduler · cgroupsMemory · OOMVFS · filesystemsNetwork stack · netfilterLSMnamespacesHardware / virtual hardware (cloud: hypervisor — steal #45, disk quota #44)
Figure 5-1, explained as you draw it: which faults are in user space (#1, #2, #16), which are executed by the kernel (#39–#46), and which come from the host (#44, #45)

Scenario question 5-1: same binary, works on the dev machine, "Permission denied" on the server

A developer runs the Go-compiled myapp-worker from /tmp and it fails. Copied to /opt, it runs, but as a systemd service it cannot read /home/dev/config.yaml. Describe your troubleshooting approach and a deployment standard.

Key points of the reference answer
  • Step 1: /tmp is mounted noexec (#1), and strace -e execve shows EACCES. Don't relax noexec. Instead, standardize the install path (/opt/<app> or /usr/local/bin, owned by root, mode 0755).
  • Step 2: the service user cannot traverse /home/dev (0750, #4), or ProtectHome= makes /home invisible.
  • Standard: put configuration in /etc/<app>/ (root:app 0640), store data with StateDirectory=, send logs to journald, and run as a system user inside a sandbox. Deploy through configuration management or the image pipeline, not by hand-copying files.

Scenario question 5-2: explain the isolation differences between containers, VMs, and systemd services to the team

The security team requires that "all services run isolated." The current setup includes systemd services on VMs, Docker containers, and execution environments for multi-tenant SaaS plugins. Give tiered recommendations.

Key points of the reference answer
  • Services in the same trust domain: a systemd sandbox is enough (DynamicUser, ProtectSystem=strict, PrivateTmp, NoNewPrivileges, CapabilityBoundingSet, SystemCallFilter, resource limits), and it has the lowest cost.
  • Containers: they also share the kernel. Run them as non-root, drop capabilities, use the default seccomp profile, mount the root filesystem read-only, and do not mount docker.sock.
  • Untrusted code (multi-tenant plugins): VMs or microVMs (Firecracker/Kata), or gVisor. Use separate node pools and network isolation.
  • Measure with systemd-analyze security, container baseline scans, and penetration testing.
Or score ≥ 70% on the quiz

Module 6 · Part B: Systems Administration and Networking (Interview 14–25)

37:00 – 44:00 · systemd unit design, logging, storage and filesystems, fstab, network stack, TCP states, DNS, firewalls, SSH, scheduled tasks, troubleshooting a "slow website," time sync
7 minConfigure → observe → trade-offs12 questions
Learning goals
  • Write a production-grade systemd unit and explain it line by line. Explain the trade-offs between ext4 and XFS, cron and timers, and ufw and firewalld.
  • Follow one packet through the network: socket → route → neighbor → netfilter → NIC. Explain what TIME_WAIT and CLOSE_WAIT mean.
  • For open-ended questions such as "the website is slow," lay out a layered, measurable troubleshooting approach.

Skim the questions and focus areas first, and mark the ones you are unsure about. Click a row to jump to the full answer.

Q14. Write a production-grade systemd service unit and explain the key options. Intermediate
30-second answer

Key points: type and dependencies (Type=, After=/Wants=), least privilege (dedicated user, sandbox, capabilities), resource limits (memory, task count, file handles), restart policy (Restart=on-failure with a sensible RestartSec and start rate limiting), and writable directories managed by systemd.

Deeper answer
[Unit]
Description=myapp (Flask + gunicorn)
Wants=network-online.target redis-server.service
After=network-online.target redis-server.service
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Type=exec                        # Counts as started only after execve succeeds (same as in hour 2)
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp/app
SyslogIdentifier=myapp
EnvironmentFile=/etc/myapp/myapp.env
ExecStart=/opt/myapp/venv/bin/gunicorn -w 2 -b 0.0.0.0:5000 app:app
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=3
StateDirectory=myapp
MemoryHigh=800M
MemoryMax=1G
TasksMax=512
LimitNOFILE=65536
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
  • Requires= is a hard dependency: if the other unit fails or stops, this unit goes down with it. Wants= is a soft dependency. Ordering is set only by After=/Before=, and it is independent of the dependency type.
  • Use network-online.target only when you really need the network to be configured.
Common follow-ups
  • Type=simple or exec? simple counts as started right after fork. exec counts as started only after execve succeeds, so errors like those in #13 get reported to systemctl start.
Bonus points

Use systemd-analyze verify and systemd-analyze security myapp as checks in CI.

Wrong answer

Running as root, using Restart=always with RestartSec=0, and using nohup.

See Hour 2, Module 1.

Q15. How do journald and rsyslog relate? How are logs rotated, retained, and centralized? Beginner
30-second answer

journald collects kernel messages, service stdout/stderr, syslog, and more, and stores them as structured binary logs with fields such as _SYSTEMD_UNIT and _PID. It rotates them automatically by size and time (SystemMaxUse, MaxRetentionSec). rsyslog can read from journald and write text files or forward logs remotely, and logrotate rotates those text files. In production, the local host only buffers logs, and everything is forwarded to a central platform (Azure Monitor Agent + DCR, CloudWatch Agent, Loki/Elastic).

Deeper answer
journalctl -u myapp -p warning --since "1 hour ago" -o json-pretty | head -30
journalctl --disk-usage; journalctl --verify | tail -2
  • Persistent storage requires /var/log/journal or Storage=persistent (#17). Applications that write their own log files must handle reopening, or use copytruncate (#18).
Common follow-ups
  • How do you protect logs from tampering? Forward them in real time to central WORM or immutable storage. journald FSS (Forward Secure Sealing) can detect local tampering.
Bonus points

Mention structured logs (JSON) with correlation IDs, and log volume and cost control (sampling, log levels, DCR transformations).

Wrong answer

"SSH into each machine and grep the logs."

See Hour 2, Module 2 and Hour 5, Module 7.

Q16. How do you grow a data disk online? How do you choose between ext4 and XFS? What does LVM add? Intermediate
30-second answer

Grow each layer in turn: cloud disk → growpart to grow the partition → pvresize → lvextend -r (which also grows the filesystem). Without LVM, use resize2fs or xfs_growfs directly. ext4 can grow and shrink (shrinking requires unmounting), has mature tooling, and has a fixed inode count. XFS handles large files and parallel I/O well, has dynamic inodes, and can only grow. It is the default on the RHEL family and on AL2023. LVM provides online growth, pooling of multiple disks, snapshots, and migration (pvmove).

Deeper answer
sudo growpart /dev/sdc 1 && sudo pvresize /dev/sdc1 && sudo lvextend -r -l +100%FREE /dev/vgdata/lvdata
lsblk -f; sudo vgs; df -hT /data
  • In most cloud setups you can skip partitioning and create the PV or filesystem on the whole disk, which avoids growpart.
  • LVM snapshots reduce write performance, so cloud setups usually use platform disk snapshots instead (watch for multi-disk consistency, Q38).
Common follow-ups
  • How do you shrink XFS? You can't. You have to create a smaller filesystem and migrate the data.
Bonus points

Work #19 (inodes), #20 (duplicate XFS UUID), and #22 (forgetting to grow the filesystem) into your answer.

Wrong answer

"Just reboot after growing the cloud disk." The root partition is grown automatically by cloud-init, but data disks are not.

See Hour 2, Module 3.

Q17. What do the fstab fields mean? How do you write entries so the server still boots? Beginner
30-second answer

Six fields: device (UUID= recommended), mount point, type, options, dump (almost always 0), and fsck order (root 1, others 2, skip 0). To avoid boot failures, add nofail to data disks (you can also set x-systemd.device-timeout=), add _netdev to network filesystems, and pre-check changes with findmnt --verify and mount -a. If you're not sure about an entry, use noauto or automount (x-systemd.automount).

Deeper answer
UUID=5c0e…  /data   xfs   defaults,nofail,x-systemd.device-timeout=10s  0 2
//files/share /mnt/share cifs credentials=/etc/cifs.cred,_netdev,nofail,x-systemd.automount 0 0
  • How it works: systemd-fstab-generator creates a .mount unit for each line. Without nofail, the mount becomes a Requires of local-fs.target (#21, lab 3-B).
Common follow-ups
  • Why not use /dev/sdb? Device names are assigned in discovery order, which is especially unreliable in the cloud (#28, #36).
Bonus points

Describe an out-of-band recovery plan: serial console, ALAR, and rescue instances.

Wrong answer

"If you get it wrong, just reboot and see."

See Hour 2, Module 4.

Q18. Describe the parts of the Linux network stack that an outbound HTTP request passes through, from the application to the NIC. Advanced
30-second answer

The application resolves the name with getaddrinfo() (nsswitch → systemd-resolved → upstream DNS). Then socket() and connect() run. The kernel looks up the route (ip rule policy → routing table) to choose the interface, next hop, source address, and ephemeral port. The SYN passes through netfilter (OUTPUT → POSTROUTING), where conntrack creates an entry and SNAT may apply. The neighbor subsystem (ARP/ND) resolves the next hop's MAC. Then comes the qdisc, the NIC driver (virtio, ENA, or MANA in the cloud, or accelerated networking), and the wire. Replies travel through PREROUTING → INPUT → the socket.

Deeper answer
ip route get 151.101.0.223; ip rule; ip neigh
ss -tni dst 151.101.0.223  # congestion window, RTT, retransmissions
sudo conntrack -L -d 151.101.0.223 2>/dev/null | head -2
sudo tcpdump -ni eth0 host 151.101.0.223 -c 10
  • Common faults: DNS (#25), asymmetric routing, a full conntrack table (#42), MTU problems (large packets fail while small ones get through, because ICMP is filtered and breaks PMTUD), and security groups or firewalls (#24).
Common follow-ups
  • Where do inbound requests queue before the application calls accept? In the SYN queue and the accept queue (#43).
Bonus points

Mention eBPF/XDP processing packets at the driver layer, and cloud accelerated networking (SR-IOV) bypassing the host's virtual switch.

Wrong answer

Only talks about the seven OSI layers without mapping them to Linux commands and components.

See Hour 2, Module 5 and Hour 7, Module 5.

Q19. What does a large number of TIME_WAIT or CLOSE_WAIT connections on a server mean? How do you handle it? Intermediate
30-second answer

TIME_WAIT appears on the side that closes actively. It lasts 2×MSL (fixed at about 60 seconds on Linux), so the final ACK and old packets can drain. This is normal. A large number means many short-lived connections, and clients may run out of ephemeral ports. CLOSE_WAIT appears on the side that closes passively. The peer has closed, but the local side has not called close(). This is almost always an application bug (a connection leak), and it eventually exhausts file descriptors (#41).

Deeper answer
ss -s; ss -tan state time-wait | wc -l; ss -tanp state close-wait | head
sysctl net.ipv4.ip_local_port_range net.ipv4.tcp_tw_reuse
  • Many TIME_WAIT connections: reuse connections with pooling or keep-alive, widen ip_local_port_range, and enable tcp_tw_reuse on clients. Do not use tcp_tw_recycle, which has been removed.
  • Many CLOSE_WAIT connections: fix the code (close in finally blocks, set timeouts). A restart is only a temporary fix.
Common follow-ups
  • Does TIME_WAIT take up conntrack entries? Yes (#42).
Bonus points

Be able to draw the four-way close and mark where each of the two states appears.

Wrong answer

"Set the TIME_WAIT timeout to 1 second."

See Hour 7, Module 5.

Q20. Which components are involved in name resolution on Linux? How do you troubleshoot intermittent resolution failures? Intermediate
30-second answer

glibc looks up names in the order given by hosts: in /etc/nsswitch.conf: files → /etc/hosts, resolve → systemd-resolved, and dns → the servers in resolv.conf. On Ubuntu, resolv.conf points to the 127.0.0.53 stub. resolved handles caching, per-domain routing (per-link DNS, ~corp.example), and DNSSEC/DoT, then forwards to the upstream servers. Intermittent failures come from upstream timeouts or rate limiting (cloud DNS enforces a query rate limit per interface), UDP drops caused by conntrack (#42), multiple lookups caused by search domains, and IPv6 AAAA timeouts.

Deeper answer
getent ahosts pypi.org; resolvectl query pypi.org; resolvectl statistics
sudo tcpdump -ni any port 53 -c 20
cat /etc/nsswitch.conf | grep hosts
  • Applications with their own resolvers (Go, Java) may bypass nsswitch and resolved. Check them separately.
Common follow-ups
  • Why does ndots:5 make lookups slow in Kubernetes? Short names try each entry in the search list first.
Bonus points

Mention local caching (resolved or a node-local DNS cache) and cloud DNS quotas (the AWS Route 53 Resolver per-ENI queries-per-second limit; check the documentation for current values).

Wrong answer

"Just add 8.8.8.8 to /etc/resolv.conf." (An anti-pattern, see #25.)

See Hour 2, Module 5.

Q21. How are iptables, nftables, ufw, and firewalld related? Do cloud security groups still need a host firewall? Intermediate
30-second answer

The kernel packet filtering framework is netfilter. nftables is the current engine and tool (nft), and on modern distributions iptables is mostly the iptables-nft compatibility layer. ufw (Ubuntu) and firewalld (RHEL family, zone-based) are rule front ends. Cloud security groups and NSGs filter at the virtual network layer. A host firewall adds defense in depth (against lateral movement within a subnet and accidentally opened security groups). Manage both with IaC so they stay consistent.

Deeper answer
sudo nft list ruleset | head -40
sudo ufw status numbered; sudo firewall-cmd --list-all  # on Ubuntu / RHEL family respectively
update-alternatives --display iptables 2>/dev/null | head -3
  • Docker writes its own nat/filter rules, which can bypass ufw and expose published ports. Control this with the DOCKER-USER chain.
  • The host firewall must allow exceptions for cloud platform addresses (Azure 168.63.129.16 and the metadata address 169.254.169.254, #31).
Common follow-ups
  • DROP or REJECT? For external traffic, DROP leaks less information. For internal traffic, REJECT fails fast and makes troubleshooting easier (#24).
Bonus points

Explain the conflict risk when two front ends manage rules at the same time, and standardize on a single entry point.

Wrong answer

"With security groups in place, you can turn off the host firewall."

See Hour 6, Module 3 (firewalls).

Q22. How do you harden SSH? How do you manage SSH access when you have thousands of servers? Intermediate
30-second answer

The basics: disable password and root logins (PasswordAuthentication no, PermitRootLogin no), use only modern keys such as Ed25519, restrict access with AllowGroups, set MaxAuthTries, and keep SSH off the public internet (go through a bastion, VPN, or zero trust). At scale: use SSH certificates (a CA signs short-lived user certificates, with TrustedUserCAKeys; host certificates solve #8), or use cloud identity (Entra sign-in + RBAC #26, SSM Session Manager #35, EC2 Instance Connect), and audit sessions centrally.

Deeper answer
sudo sshd -T | grep -E 'passwordauthentication|permitrootlogin|pubkeyauthentication|allowgroups|kexalgorithms'
ssh-keygen -s ca_key -I alice@corp -n labadmin -V +8h ~/.ssh/id_ed25519.pub  # user certificate valid for 8 hours
  • Validate sshd configuration changes with sshd -t before applying them, and keep one logged-in session open (the same principle as #6).
Common follow-ups
  • How do you revoke keys for departing employees? Certificates expire automatically. With public key mode, configuration management pushes the full authorized_keys set.
Bonus points

Mention the OpenSSH 10 changes (DSA removed, post-quantum hybrid key exchange on by default) and compliance requirements for session recording.

Wrong answer

"Changing to a non-22 port makes it secure."

See Hour 2, Module 6 and Hour 6, Module 4.

Q23. How do you choose between cron and systemd timers? Beginner
30-second answer

cron is simple and universal. systemd timers send logs to journald, run in the same environment as services (user, sandbox, resource limits), use Persistent=true to run missed jobs, use RandomizedDelaySec to spread out load spikes at the top of the hour, support dependencies and locking (the same service never runs twice at once), and can all be listed with systemctl list-timers. Use a timer for new jobs.

Deeper answer
# /etc/systemd/system/myapp-backup.timer
[Timer]
OnCalendar=*-*-* 02:30:00
RandomizedDelaySec=15m
Persistent=true
[Install]
WantedBy=timers.target
systemd-analyze calendar '*-*-* 02:30:00'; systemctl list-timers --all | head
  • cron pitfalls: very few environment variables (just PATH), % must be escaped, output gets swallowed by email, and overlapping runs are not prevented (you need flock).
Common follow-ups
  • Distributed scheduled jobs? Don't run them on every machine. Use a scheduling platform (Kubernetes CronJob, cloud schedulers) or a distributed lock.
Bonus points

Alert when a scheduled job does not succeed on time (dead man's switch or heartbeat monitoring).

Wrong answer

"cron is enough, timers are too complicated." This ignores observability and catch-up runs.

See Hour 2, Module 7.

Q24. Users report that "the website is slow." How do you troubleshoot it on the Linux backend? Advanced
30-second answer

First, quantify and scope the problem: which endpoint, how slow (p50/p99), since when, whether all instances are affected, and any recent changes. Then work through the layers: client/CDN/LB → network (RTT, retransmissions, DNS) → host (USE: utilization, saturation, and errors for CPU, memory, disk, and network) → application (worker saturation, slow queries, locks, GC) → dependencies (Redis, databases, external APIs). Use data to narrow the scope.

Deeper answer
curl -o /dev/null -s -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://myapp.example.com/healthz
uptime; dmesg -T | tail; vmstat 1 5; mpstat -P ALL 1 3; pidstat 1 3; iostat -xz 1 3; free -m; sar -n DEV,TCP,ETCP 1 3
ss -ltn 'sport = :5000'; nstat -az | grep -E 'ListenOverflows|Retrans'
sudo py-spy dump --pid $(systemctl show -p MainPID --value myapp) | head -30
redis-cli --latency -i 1 | head -3
  • Common findings: accept queue overflow (#43), steal (#45), disk quota (#44), slow DNS (Q20), slow dependencies, and GC or memory pressure (#39).
  • After a fix, verify the same metric, and write a postmortem covering the root cause, time to detection, and follow-up actions.
Common follow-ups
  • Only p99 is slow while the average looks normal? That points to queuing and tail latency: lock contention, GC, a single slow dependency, or one bad node. Break the metrics down by instance.
Bonus points

Be able to explain RED (Rate, Errors, Duration) for services and USE for resources, and share a real incident story.

Wrong answer

Jumping straight to "restart the service / add machines."

See Hour 7, Module 1.

Q25. Why does time synchronization matter for production systems? How do chrony and systemd-timesyncd differ? Beginner
30-second answer

TLS certificate validity, Kerberos and OAuth tokens, TOTP, distributed databases and consensus protocols, and log correlation and auditing all depend on accurate time (#49). timesyncd is only an SNTP client. chrony is a full NTP implementation: it converges quickly, adapts to intermittent networks and VMs, can act as a server, and supports PHC hardware clocks and NTS (authenticated NTP). On new Ubuntu 26.04 installs, chrony is the default, and NTS is enabled for Ubuntu time servers. The RHEL family has always used chrony.

Deeper answer
chronyc tracking; chronyc sources -v; timedatectl show-timesync 2>/dev/null | head -3
  • Step vs. slew: for large offsets, use makestep to step the clock. Otherwise slew, which prevents time from going backward. Leap-second smearing must be consistent across the whole cluster.
  • Use a nearby time source in the cloud: AWS 169.254.169.123, and the Azure host PTP device (/dev/ptp_hyperv).
Common follow-ups
  • Can a container have its own clock? No. The clock is global to the kernel. A time namespace only offsets monotonic and boottime.
Bonus points

Set alerts for clock offset and include it in startup health checks.

Wrong answer

"Just change it manually with date -s."

See Hour 2, Module 7.

Interview whiteboard diagram: the Linux network stack an outbound request passes through (Q18, Q20, Q21)Applicationgetaddrinforesolved127.0.0.53socketconnect()Routeip rule · routenetfilterconntrack · NATNeighborARPNICqdisc · driver#25 EAI_AGAIN#41 EMFILE · port exhaustionAsymmetric routing#42 table full · #24 DROPMTU · packet lossTCP close: whichever side calls close first enters TIME_WAIT (about 60 seconds). If the peer closes and the local side does not call close → CLOSE_WAIT (application bug)Inbound: SYN → SYN queue → handshake completes → accept queue → application calls accept() (queue full → #43 ListenOverflows)Troubleshooting commands: ip route get · ss -tni · conntrack -S · nstat -az · tcpdump -ni any
Figure 6-1: map incident numbers to the diagram as you draw it in an interview

Scenario question 6-1: CLOSE_WAIT keeps climbing after a release

Six hours after the new myapp version went live, it reports Too many open files, and ss shows more than 900 CLOSE_WAIT connections to Redis. Identify the root cause, stop the bleeding, and propose a long-term fix.

Key points of the reference answer
  • Diagnosis: CLOSE_WAIT is on the local side. Redis (or a proxy) closed idle connections, but the application never called close. The new version may be creating a new client for every request without reusing or closing it (a leak), which eventually hits LimitNOFILE (#41).
  • Stop the bleeding: roll back, or do a rolling restart (one host at a time, to keep capacity). Raising LimitNOFILE temporarily only buys time.
  • Fix: use a global connection pool, set timeouts and keepalive, check in code review and testing that the number of long-lived fds does not grow, and monitor process_open_fds and the CLOSE_WAIT count.

Scenario question 6-2: one machine has intermittent DNS failures, while the others are fine

The nightly batch job on batch-03 intermittently fails with Temporary failure in name resolution, and the problem cannot be reproduced during the day. How do you investigate?

Key points of the reference answer
  • Collect: failure times, failing domain names, resolvectl statistics, and the nightly job (how many concurrent queries the batch run generates).
  • Hypotheses and checks: ① the query rate exceeds the cloud DNS quota → capture packets to look for repeated queries or unanswered requests, and add local caching; ② the conntrack table is full and drops UDP (#42) → check kernel logs; ③ resolved upstream switching or timeouts → configure multiple upstreams; ④ the application has its own resolver with no caching.
  • Prevention: local caching plus retries with backoff, and a metric for the resolution failure rate.
Or score ≥ 70% on the quiz

Module 7 · Part B: Cloud and Automation (Interview 26–38)

44:00 – 52:00 · cloud-init, metadata service and IMDSv2, instance identity, SSH-free operations, patching, golden images, immutable infrastructure, Bash, tool selection, configuration drift, monitoring agents, disk performance, backup consistency
8 minPlatform mechanisms → automation → trade-offs13 questions
Learning goals
  • Compare Azure and AWS capabilities (managed identity ↔ instance profile, run-command ↔ SSM Run Command, Update Manager ↔ Patch Manager, AMA + DCR ↔ CloudWatch Agent). Don't memorize just one cloud.
  • Be able to argue what goes into the image, what happens at boot, and who makes changes at runtime. Explain the benefits and costs of immutable infrastructure.
  • Write Bash that can run in CI: strict mode, quoting, trap, ShellCheck, and idempotence.

Skim the questions and focus areas first, and mark the ones you are unsure about. Click a row to jump to the full answer.

Q26. What is cloud-init? What stages does first boot go through, and what does each one do? Intermediate
30-second answer

cloud-init is the cloud image initialization framework. It detects the data source (Azure, EC2, NoCloud, and so on), gets metadata and user data from the metadata service or an attached medium, and applies first-boot configuration module by module. Stages: generator (whether it is enabled) → local (no network yet: find the data source and write network configuration) → network (fetch metadata and user data, bootcmd, disk mounts, grow the root partition) → config (users, package sources, and so on) → final (install packages, runcmd, user scripts, final message).

Deeper answer
cloud-init status --long; cloud-init analyze show | head -20
cloud-init query -a | jq '.v1 | {cloud_name, region, instance_id}'
sudo cloud-init schema --system --annotate
  • Module frequency: per-instance (most modules), per-boot, or per-once. It is determined by the instance ID (#37).
  • Multipass uses the NoCloud data source, which makes it easy to reproduce cloud-config locally (lab 3-A).
Common follow-ups
  • How do cloud-init and the Linux agent divide the work on Azure? On modern images, cloud-init handles first-time configuration (users, keys, disks), and walinuxagent manages extensions and health reporting (check the documentation for details).
Bonus points

Stress that cloud-init should be thin: it only bootstraps, and complex logic belongs in the image or in configuration management. Validate the schema in CI.

Wrong answer

"cloud-init runs the user data on every boot."

See Hour 3, Module 2 and Hour 4, Module 2.

Q27. What security risks does the instance metadata service carry? How does IMDSv2 mitigate SSRF? Advanced
30-second answer

The metadata service (169.254.169.254) gives any process on the instance its instance information and temporary cloud identity credentials. If an application has an SSRF (server-side request forgery) bug, an attacker can use it to request the credentials URL and steal the instance role. IMDSv2 requires you to first PUT to get a session token, and then include it in a header. Most SSRF bugs can only send GET requests and cannot add headers. The PUT response's IP TTL is limited by a hop limit, so the token cannot leave the host. Requests that carry X-Forwarded-For are rejected. AL2023 enforces IMDSv2 by default with a hop limit of 2 (#34).

Deeper answer
  • Azure IMDS requires the header Metadata: true and rejects requests that carry X-Forwarded-For, which serves a similar purpose.
  • Defense in depth: least privilege for instance roles, outbound filtering from applications, blocking the metadata address inside containers, or using workload identity.
aws ec2 modify-instance-metadata-defaults --region ca-central-1 --http-tokens required --http-put-response-hop-limit 2
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name MetadataNoToken --dimensions Name=InstanceId,Value=i-0abc… --statistics Sum --period 3600 --start-time $(date -u -d '-1 day' +%FT%TZ) --end-time $(date -u +%FT%TZ)
Common follow-ups
  • How do you find programs still using IMDSv1? Use the MetadataNoToken metric, and enforce v2 in a test environment to surface failures.
Bonus points

Cite a real event where an SSRF was used to steal instance credentials (you don't need to name it), and explain organization-wide defaults and enforcement with SCPs.

Wrong answer

"The metadata service is only reachable locally, so it is safe."

See Hour 4, Module 2.

Q28. Compare Azure managed identity with AWS instance profiles (IAM roles). How do programs on an instance get cloud credentials? Intermediate
30-second answer

Both let programs on an instance work without long-term keys. They request credentials from a local metadata endpoint and get short-lived tokens or credentials that rotate automatically. Azure: system-assigned (tied to the VM's lifecycle) or user-assigned (a standalone resource that multiple VMs can share) managed identities. They obtain Entra tokens from IMDS and are authorized through RBAC. AWS: an instance profile wraps an IAM role. IMDS returns temporary STS credentials, which are authorized by IAM policies. The SDK default credential chain uses these automatically.

Deeper answer
# Azure (inside the VM)
curl -s -H Metadata:true "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/" | jq -r '.expires_on'
# AWS (inside the VM)
aws sts get-caller-identity
  • Authorization boundaries: Azure role assignment scope (resource, resource group, or subscription), and AWS policy resource ARNs and conditions. Both should follow least privilege.
  • Every process on the same instance shares this identity. For finer-grained control, split workloads across instances or use container-level workload identity.
Common follow-ups
  • What about outside an instance (CI)? Use OIDC federation (GitHub/GitLab → Entra federated credentials, or AWS IAM OIDC identity providers). It also avoids long-term keys.
Bonus points

Mention that Entra sign-in (#26, #27) and SSM (#35) both depend on this mechanism.

Wrong answer

"Put access keys in /etc/environment."

See Hour 3, Module 4 and Hour 4, Module 2.

Q29. How do you manage cloud Linux without opening an SSH port? Intermediate
30-second answer

AWS: SSM Session Manager (the agent makes outbound connections, access is authorized through IAM, sessions can be recorded to S3/CloudWatch, and port forwarding is supported), Run Command, and EC2 Instance Connect Endpoint. Azure: Azure Bastion (connect to private IPs through it from a browser or native client), az ssh vm with Entra sign-in, and az vm run-command. Common principles: centralized identity, no public IPs, and complete auditing. Prerequisites: a healthy agent and outbound reachability (#31, #35).

Deeper answer
aws ssm start-session --target i-0abc… --document-name AWS-StartPortForwardingSession --parameters portNumber=5000,localPortNumber=15000
az network bastion ssh -n bas-linux-lab -g rg-linux-lab --target-resource-id "$VMID" --auth-type AAD
az vm run-command invoke -g rg-linux-lab -n vm-linux-lab --command-id RunShellScript --scripts "systemctl is-active myapp"
Common follow-ups
  • What if the agent breaks? Use an out-of-band channel: the serial console or rescue instances (Q48).
Bonus points

Cover the break-glass process: who can use it, how it is approved, and how it is audited afterward.

Wrong answer

"Opening port 22 and restricting the source IP is enough." This lacks identity and auditing.

See Hour 4, Module 4 and Hour 3, Module 4.

Q30. How do you design Linux patch management, including kernel updates and reboots? Intermediate
30-second answer

Tiers and cadence: set SLAs by severity (for example, critical vulnerabilities within 7 days). Roll out in batches (dev → staging → canary → production in waves), and check health after each batch. Use platform tooling: Azure Update Manager for periodic assessment and maintenance configurations; AWS SSM Patch Manager for patch baselines and maintenance windows; locally, unattended-upgrades, which installs only security updates. Kernel updates require a reboot, so use maintenance windows, rolling restarts, or Livepatch (Ubuntu Pro) / kpatch (RHEL) to reduce reboots. Rebuilding the image and replacing instances is the preferred approach.

Deeper answer
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required.pkgs  # Ubuntu
needs-restarting -r 2>/dev/null  # RHEL family
aws ssm describe-instance-patch-states --instance-ids i-0abc… --query 'InstancePatchStates[0].{missing:MissingCount,failed:FailedCount}'
  • Risk controls: snapshots, rollback plans, and automated smoke tests after patching. Watch #9 (locks), #10 (interruptions), and #38 (initramfs).
Common follow-ups
  • How do you prove compliance? Platform compliance reports plus CVE scanning (pro fix, Inspector, Defender for Cloud).
Bonus points

Distinguish between a patch being "available," "installed," and "in effect" (processes that need a restart have been restarted). Check with needrestart.

Wrong answer

"Every machine automatically runs full-upgrade every night and reboots."

See Hour 3, Module 6, Hour 4, Module 6, and Hour 5, Module 5.

Q31. How do you choose between golden images (Packer) and boot-time configuration (cloud-init / Ansible)? Advanced
30-second answer

Layer by how often things change and how fast boot needs to be. Things that change slowly and are identical across instances (OS patches, hardening baselines, monitoring and security agents, runtimes) go into the image. Images boot fast, are repeatable, and are testable. A few environment-specific parameters (hostname, environment identifier, secret references) are injected at boot by cloud-init. The application version either comes with the image (fully immutable) or is pulled at boot. Changes at runtime go through configuration management or a rebuild.

Deeper answer
  • Image pipeline: build with Packer → automated tests (Goss/Testinfra/InSpec, CIS scans) → publish to Azure Compute Gallery / AMI (with version and SBOM) → promote through environments → rebuild on a regular schedule (for example, weekly) to pick up patches.
  • Costs: image management, storage, and build time. Benefits: fast boot, reliable scaling, and fewer external dependencies at boot (#9, #30).
build {
  sources = ["source.azure-arm.ubuntu2604", "source.amazon-ebs.al2023"]
  provisioner "shell"   { script = "scripts/harden.sh" }
  provisioner "ansible" { playbook_file = "playbooks/base.yml" }
  post-processor "manifest" {}
}
Common follow-ups
  • Can secrets go into the image? No. At boot, use the instance identity to fetch them from Key Vault or Secrets Manager.
Bonus points

Mention what to clean up from the image: SSH host keys, machine-id, and cloud-init state (cloud-init clean).

Wrong answer

"Install everything with apt install at boot, and keep the image as bare as possible." This is slow to boot and depends on the availability of external repositories.

See Hour 5, Module 3: Building Azure and AWS golden images with Packer.

Q32. What is immutable infrastructure? How does it change the way you operate Linux? Intermediate
30-second answer

Nothing is changed in place after deployment. Patches, configuration changes, and application version changes all happen by replacing the image or instance with a new one. Benefits: no drift, repeatability, rollback by switching back to the old version, and bad machines are simply replaced. Operational changes: you fix the pipeline instead of SSHing into machines. State is kept outside the instance (in databases, object storage, or separate data disks). Logs and monitoring are centralized. Health checks and automatic replacement are required (VMSS / Auto Scaling).

Deeper answer
  • It is not absolute: databases and stateful monoliths often stay mutable, and configuration management controls their drift (Q35).
  • For incident handling: problems like #3, #18, and #50 are best handled in an immutable environment by isolating and replacing the instance, then doing forensics offline.
Common follow-ups
  • Do urgent security patches also go through the image pipeline? The pipeline has to be fast (hours). In extreme cases, use SSM or Run Command for a temporary patch, then bake it into the next image.
Bonus points

Describe the "pets vs. cattle" trade-off and the migration steps you actually drove.

Wrong answer

"Immutable means no SSH access."

See Hour 5, Module 4 (image generalization, hardening, and versioning).

Q33. How do you write robust production Bash scripts? Beginner
30-second answer

Start with #!/usr/bin/env bash and set -Eeuo pipefail. Quote variable expansions. Use trap to clean up temporary files and report the failing line. Use mktemp. Split code into functions with a single responsibility. Check dependencies and arguments. Make scripts idempotent. Write timestamped logs to stderr. Use flock to prevent concurrent runs. Run ShellCheck and bats in CI.

Deeper answer
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'
log() { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*" >&2; }
tmp=$(mktemp -d); trap 'rc=$?; rm -rf "$tmp"; [ $rc -ne 0 ] && log "failed at line $LINENO (rc=$rc)"; exit $rc' EXIT
exec 9>/run/lock/deploy.lock; flock -n 9 || { log "another deploy running"; exit 1; }
command -v jq >/dev/null || { log "jq required"; exit 1; }
: "${APP_VERSION:?APP_VERSION is required}"
log "deploying $APP_VERSION"
  • Blind spots of set -e: commands inside if, &&, and ||, and failures inside command substitutions. It does not replace explicit error handling.
  • CRLF line endings (#2) and noexec (#1) are common causes of script failures.
Common follow-ups
  • When shouldn't you use Bash? For complex data structures, heavy JSON, or logic that needs unit tests and error handling, use Python or Go (Q34).
Bonus points

Be able to name a few ShellCheck codes (SC2086 unquoted variable, SC2155 declaring and assigning in one line, SC1017 carriage return).

Wrong answer

"Adding set -e makes it robust."

See Hour 5, Module 1 and Bash in 8 Hours.

Q34. For operations automation, what are Bash, Python, Ansible, and Terraform each suited for? Intermediate
30-second answer

Terraform (or Bicep/CloudFormation) declares cloud resources. Packer builds images. Ansible configures systems and applications idempotently (across many hosts, with state checks and dry-run support). Bash handles glue and small local tasks (a few dozen lines, calling CLIs). Python/Go handles tools with complex logic, API calls, error handling, and tests. Decision criteria: declarative vs. procedural, idempotence, team skills, and testability.

Deeper answer
  • Boundary examples: Terraform creates the VM and the DCR. cloud-init only injects a role tag. Ansible configures myapp by role. Bash runs as a health pre-check in systemd ExecStartPre.
  • Don't use Terraform's remote-exec for configuration management, and don't let Ansible's shell module do everything (you lose idempotence).
Common follow-ups
  • How does Ansible stay idempotent? Modules describe the desired state and check it before acting. Preview changes with --check --diff.
Bonus points

Describe how you would migrate a 300-line Bash script into an Ansible role plus a small amount of Python.

Wrong answer

"One tool solves every problem."

See Hour 5, Module 6, Ansible in 8 Hours, and Terraform in 8 Hours.

Q35. What is configuration drift? How do you detect and correct it? Intermediate
30-second answer

Drift: the actual state diverges from the desired state defined in code, caused by manual changes, emergency fixes, and automatic software updates. Detection: run check mode regularly (ansible-playbook --check --diff), use file integrity monitoring (AIDE, auditd rules), and use cloud compliance and policy scanning (Azure Policy Guest Configuration / Machine Configuration, AWS Config + SSM State Manager). Correction: automatically reapply the desired state, or replace instances in an immutable environment. Also trace where the drift came from and fix the process.

Deeper answer
ansible-playbook -i inventory site.yml --check --diff --limit linuxlab | grep -E 'changed=|^---|^\+\+\+'
sudo aide --check 2>/dev/null | head; sudo ausearch -k etc-changes -ts today | tail -3
Common follow-ups
  • What if you must make a manual change in an emergency? Make the change → file a ticket → write it back to the codebase within 24 hours → confirm there is no drift on the next run.
Bonus points

Publish drift as a platform metric (for example, the share of hosts reporting changed in the weekly check-mode run).

Wrong answer

"Blocking everyone from logging in prevents drift." Automatic software updates and platform agents also change state.

See Hour 5, Module 6 and Hour 6, Module 5.

Q36. How are logs and metrics collected from Linux in the cloud? How do the Azure and AWS approaches compare? Beginner
30-second answer

Azure: Azure Monitor Agent with data collection rules (DCR) defines what is collected (Syslog facility/level, performance counters, text logs) and the target Log Analytics workspace. VMs must be associated with a DCR (#32), and AMA authenticates with a managed identity. AWS: the CloudWatch Agent (its configuration can be stored in SSM Parameter Store) collects metrics and logs into CloudWatch and authenticates with the instance role. Platform metrics (CPU, network, EBS) need no agent. Open-source alternatives: node_exporter + Prometheus, and Fluent Bit/Vector + Loki.

Deeper answer
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status
az monitor data-collection rule association list --resource "$VMID" -o table
  • Note: platform metrics usually don't include memory or disk usage, so you need an agent. Monitor the agent too (with heartbeat alerts).
Common follow-ups
  • How do you control logging costs? Collect only the levels you need, filter and transform in the DCR, use tiered retention, and sample high-volume logs.
Bonus points

Use Policy or State Manager to automatically ensure every instance has the agent installed and the rules associated.

Wrong answer

"Installing the agent automatically collects every log."

See Hour 3, Module 5, Hour 4, Module 5, and Prometheus & Grafana: 8 + 1 Hours.

Q37. How do you choose disks for Linux in the cloud? How do you understand IOPS, throughput, and bursting? Intermediate
30-second answer

Start by measuring the workload: small random I/O for IOPS and latency, and large sequential I/O for throughput. A cloud disk's limits are set by both the disk itself (type and size, or provisioned values) and the VM size (per-VM disk IOPS and throughput caps). The lower of the two applies. Burstable disks and instances use credits to deliver short-term high performance. When the credits run out, performance drops back to baseline. This is often the root cause of periodic slowdowns and is related to #44. For selection: for general use, choose Azure Premium SSD v2 or AWS gp3 (IOPS and throughput can be configured independently). For the lowest latency, choose Ultra Disk or io2. For temporary high-speed cache, use local temporary disks or instance store (volatile, #29).

Deeper answer
sudo fio --name=randrw --filename=/data/fio.test --size=2G --rw=randrw --bs=4k --iodepth=32 --direct=1 --runtime=60 --time_based --group_reporting
iostat -xz 1  # r_await / w_await / aqu-sz
Common follow-ups
  • Why is fio below the advertised numbers? Queue depth is too low, VM size limits apply, filesystem and cache effects, or the test file is too small.
Bonus points

Mention the "consumed IOPS percentage" on Azure, and VolumeQueueLength / BurstBalance on AWS.

Wrong answer

"Bigger disks are faster." This holds for some disk types (performance scales linearly with capacity), but it is capped by VM limits.

See Hour 3, Module 3 and Hour 4, Module 3.

Q38. How do you keep a snapshot backup of a Linux VM running a database consistent? Advanced
30-second answer

Cloud disk snapshots are crash-consistent by default (like a sudden power loss). For application consistency: ① the application makes a consistent backup itself (a native database backup or export, or Redis BGSAVE); ② or freeze before the snapshot: flush the database and stop writes (for example, FLUSH TABLES WITH READ LOCK) → fsfreeze -f → snapshot → fsfreeze -u; ③ multi-disk setups (LVM striping, data and logs on separate disks) need a consistent multi-disk snapshot (Azure restore points, AWS multi-volume snapshots). A backup only proves itself through restore drills.

Deeper answer
redis-cli BGSAVE && redis-cli LASTSAVE
sudo fsfreeze -f /data && aws ec2 create-snapshots --instance-specification InstanceId=i-0abc…,ExcludeBootVolume=true --description lab8; sudo fsfreeze -u /data
  • Azure Backup and AWS Backup provide pre- and post-script hooks for Linux to achieve application consistency. Keep the freeze short to avoid triggering hung tasks (#44).
  • The 3-2-1 rule, cross-region or cross-account copies, and immutable backups (to protect against ransomware).
Common follow-ups
  • How do RPO and RTO shape the design? RPO determines backup frequency and replication method. RTO determines the recovery approach (snapshot restore, hot standby, or cross-region failover).
Bonus points

Describe automated recovery tests on a regular schedule (restore into an isolated environment and verify the data).

Wrong answer

"Cloud disks have three replicas, so backups aren't needed." Replicas protect against hardware failure, not against accidental deletion or corruption.

See Hour 3, Module 3 and Hour 4, Module 3.

Interview whiteboard diagram: three layers of automation, image → boot → run (Q31, Q32, Q35)Build time (Packer)OS patches · CIS hardeningMonitoring/security agents · runtimeTest → Gallery / AMI (versioned)Changes: weeklyBoot time (cloud-init)Hostname · environment tagsMount data disk (nofail)Fetch secrets using the instance identityRun only once (#37)RuntimeAnsible / State ManagerDrift detection (--check)Patch platform · monitoring agentOr: replace the instance (immutable)The further left, the slower it changes, the easier it is to test, and the faster it boots. The further right, the more flexible it is, and the easier it drifts.Identity runs through all three layers: managed identity / instance profile. Never store long-term keys in any layer.
Figure 7-1 uses "which layer does it belong in?" as the framework for answering every automation trade-off question.

Scenario question 7-1: moving 200 manually maintained VMs to an image pipeline

The company has about 100 "pet" Linux VMs on Azure and about 100 on AWS. Their configurations differ, and patching is done by hand. Give a 6-month migration plan.

Key points of the reference answer
  • Inventory: use Resource Graph, or AWS Config + SSM Inventory, to collect OS versions, packages, services, and open ports, then cluster them by role.
  • Baseline: first unify identity and access (Entra sign-in, SSM), monitoring agents, and the patch platform to reduce risk immediately.
  • Codify: write an Ansible role for each role type, and use check mode to compare against production. At the same time, build Packer pipelines (two tracks: Ubuntu 26.04 and AL2023).
  • Migrate: for each role, rebuild in staging with the new image and compare in parallel, then replace production in batches. Move stateful data to managed services or separate data disks.
  • Metrics: drift rate, patch compliance rate, average rebuild time, and SSH logins trending toward zero.

Scenario question 7-2: an SSRF vulnerability report

The security team reports that the "URL preview" feature in myapp has an SSRF vulnerability. It runs on AWS (AL2023) and Azure (Ubuntu). Assess the impact and fix it.

Key points of the reference answer
  • Impact: on AWS, IMDSv2 is in use (it is the AL2023 default). GET-style SSRF cannot obtain the token, but confirm that no instance has been switched back to optional (check HttpTokens with describe-instances). Azure IMDS requires the Metadata: true header, so assess whether the SSRF can set custom headers. Check CloudTrail and Entra sign-in logs for unusual use of instance identities.
  • Fix: on the application side, use a URL allowlist, block link-local and private network ranges, and route outbound traffic through a proxy. On the platform side, enforce IMDSv2 across the organization and apply least privilege to instance roles.
  • Follow-up: regression testing with a penetration test, WAF rules, and adding "block access to 169.254.169.254" to the outbound policy.

Scenario question 7-3: 30% of instances did not come back after patch night

After a Patch Manager maintenance window, about 30% of Ubuntu instances failed their status checks. How do you handle it, and how do you run the postmortem?

Key points of the reference answer
  • Stop the bleeding: pause the remaining batches. Confirm a kernel panic (#38) or emergency mode (#21) through the console output or the serial console.
  • Recovery: select the older kernel from GRUB, or rebuild initramfs from a rescue instance. For instances in an Auto Scaling group, replace them with the previous image.
  • Postmortem: why 30% and not all? Look for differences (instance type or driver, free space in /boot, custom initramfs configuration). Why did the canary miss it (it was not representative)? Improvements: canaries layered by instance type, automated reboot verification after patching, and automatic halting when a maintenance window exceeds a failure threshold.

Teaching videos (titles and channels verified via YouTube oEmbed)

▶
Understanding cloud-init - Azure Virtual Machines — AiceBreakers
English · cloud-init on Azure (Q26)
▶
How to connect to an EC2 instance without a key pair / Access EC2 with the AWS SSM Session Manager — Dennis Traub
English · SSH-free management (Q29)
▶
The Most Useful Tool You Have Never Heard Of (STRACE) — Mark Alexander
English · strace for debugging automation scripts
▶
20 Most Asked Linux Interview Questions 2026 | Linux Interview Questions & Answers | Intellipaat — Intellipaat
English · Comprehensive interview questions, to compare with this module

No verified video was found that specifically covers the IMDSv2 hop limit, golden image layering trade-offs, or multi-disk consistent snapshots. Storyboard:

Shot 1 (0:00) Draw the three layers from Figure 7-1. Examples: "Which layer does the Redis version go in?" and "Which layer does the environment name go in?"
Shot 2 (1:00) Demonstrate that an IMDSv1 GET returns 401, and that v2 succeeds in two steps. A container with hop limit 1 fails, and with hop limit 2 it succeeds.
Shot 3 (2:00) fsfreeze → multi-volume snapshot → unfreeze. Restore into an isolated environment and verify the Redis data.
Or score ≥ 70% on the quiz

Module 8 · Part B: Security, Performance, and Scenario Design (Interview 39–50)

52:00 – 60:00 · Hardening baselines, SELinux vs. AppArmor, auditing and forensics, incident response, the USE method, CPU/memory/I/O troubleshooting, eBPF, recovering access when locked out, platform design at the scale of a thousand machines, and late-night on-call
8 minMethodology → tools → decisions12 questions
Learning goals
  • Security questions: layered controls (prevention, detection, response), with specific Linux mechanisms and commands at each layer.
  • Performance questions: start from methodology (USE, the 60-second analysis), locate the problem with data, then reach for deeper tools such as perf and eBPF.
  • Scenario questions: answer in the order "clarify constraints → design → trade-offs → measure," and cite real incidents from Part A as evidence.

Skim the questions and focus areas first, and mark the ones you are unsure about. Click a row to jump to the full answer.

Q39. What is your hardening checklist for a newly launched Linux server? Intermediate
30-second answer

Use the CIS baseline as the reference, ordered by risk. (1) Identity and access: disable password and root SSH, centralize identity (Entra sign-in / SSM), and apply minimal sudo. (2) Attack surface: install only the packages you need, disable unnecessary services and ports, and default-deny the host firewall. (3) Patching: automatic security updates and platform-managed patching. (4) Mandatory access control: keep AppArmor or SELinux in enforcing mode. (5) Filesystem and kernel: mount /tmp with nodev,nosuid,noexec, and apply sysctl network hardening. (6) Service sandboxing: systemd Protect*, NoNewPrivileges, and capabilities. (7) Observability and auditing: auditd, centralized logs, and time sync. (8) Continuous validation: baseline scanning (OpenSCAP / usg (Ubuntu Security Guide) / Defender for Cloud / Inspector).

Deeper answer
sudo ss -ltnup; systemctl list-unit-files --state=enabled --type=service | head -30
sudo sshd -T | grep -E 'passwordauthentication|permitrootlogin'
sysctl net.ipv4.conf.all.rp_filter net.ipv4.conf.all.accept_redirects kernel.kptr_restrict
systemd-analyze security --no-pager | head -15
  • Hardening must be reversible and testable: run it and scan it in the image pipeline, and record every exception. Watch for side effects (#1 noexec, #31 firewall blocking platform addresses).
Common follow-ups
  • What is the difference between CIS Level 1 and Level 2? Level 1 has minimal impact and is broadly applicable. Level 2 is stricter and may affect functionality, so it is used in high-security environments.
Bonus points

Emphasize "baseline as code" (Ansible roles or images), plus compliance scan reports and an exception process.

Wrong answer

"Turn off SELinux, enable the firewall, and change the SSH port."

See Hour 6, Module 1: Linux Security Model and Hardening Baseline (CIS), Hour 6, Module 8.

Q40. How do SELinux and AppArmor differ? How do you handle a denial? Advanced
30-second answer

Both are LSM-based mandatory access control systems. SELinux (the default on the RHEL family) is label-based: processes have domains, and files and ports have types. Policy defines which operations each domain may perform on each type. It is powerful and fine-grained (including MLS/MCS, where container isolation uses MCS categories), but has a steep learning curve. AppArmor (the default on Ubuntu and SUSE) is path-based and profile-driven. It is easier to read and write, but protects less against things like hard links and renames. To handle a denial: confirm it is an LSM denial (audit log) → check the suggestions (audit2why / aa-logprof) → prefer booleans, labels, and minimal rules → verify → keep the change under version control. Never disable enforcement globally (#47, #48).

Deeper answer
sudo ausearch -m AVC -ts recent | audit2why  # SELinux
sudo semanage fcontext -a -t httpd_sys_content_t '/srv/www(/.*)?' && sudo restorecon -Rv /srv/www
sudo aa-status; sudo aa-complain /etc/apparmor.d/myapp; sudo aa-logprof  # AppArmor
  • Common pitfall (SELinux): mv keeps the original label, while cp inherits the label of the target directory. Container volume mounts need :z/:Z relabeling.
Common follow-up questions
  • What is permissive mode for? It only logs and does not block, so it is used for troubleshooting and policy development. You can set it for a single domain only (semanage permissive -a httpd_t).
Bonus points

Describe an experience where you dealt with a “security event after SELinux was turned off” or precisely fixed a problem using audit2why.

Wrong answer

“When you hit an SELinux problem, run setenforce 0.”

See Hour 6, Module 2.

Q41. How do you answer “who changed /etc/sudoers (or another key file), and when?” Intermediate
30-second answer

You must set this up in advance: auditd file watch rules (-w /etc/sudoers -p wa -k sudoers) record syscall-level events, including auid (the login UID, which is still the original user after sudo), the process, and the time. Supplement with sudo command records in journald, SSH/SSM session logs, and configuration management run records. After the fact, you can only rely on file timestamps (which can be tampered with), package manager logs, and comparison with backups. Logs must be forwarded in real time and stored centrally.

Deeper answer
echo '-w /etc/sudoers -p wa -k sudoers
-w /etc/sudoers.d/ -p wa -k sudoers
-w /etc/ssh/sshd_config -p wa -k sshd' | sudo tee /etc/audit/rules.d/50-lab8.rules
sudo augenrules --load
sudo ausearch -k sudoers -i | tail -20  # -i: resolve UIDs and similar values to names
sudo aureport -f -i --summary | head
  • Too many auditd rules hurt performance. Prioritize critical paths, privilege escalation, module loading, and time changes.
Common follow-up questions
  • Can root delete audit logs? Yes, which is why logs must be forwarded in real time. You can set -e 2 to lock the rules until the next reboot.
Bonus points

Mention cloud audit logs (Azure Activity Log / AWS CloudTrail). They record control-plane operations such as run-command and SSM sessions, and complement host auditing.

Wrong answer

“Check ~/.bash_history.”

See Hour 6, Module 5: Auditing with auditd and log forensics.

Q42. You suspect a Linux server in the cloud has been compromised. What do you do next? Advanced
30-second answer

Follow the incident response process, and do not reboot or delete anything first. ① Notify the team and start the incident process; ② Isolate: change the security group/NSG to allow only forensic access, remove the instance from the load balancer, and revoke its identity sessions (on AWS, revoke the role sessions; on Azure, remove the role assignments from the managed identity); ③ Preserve evidence: take disk snapshots, capture memory if needed (volatile data first), and export logs; ④ Investigate: analyze the snapshots in an isolated environment (login records, new users and keys, scheduled tasks and systemd units, suspicious processes and connections, recently modified files); ⑤ Eradicate and recover: rebuild from a trusted image rather than “cleaning up,” and rotate every credential that may have leaked; ⑥ Post-incident review and hardening.

Deeper answer
# Read-only, low-impact initial triage (write results to an external location, not the local disk)
last -Fai | head; sudo journalctl -u ssh --since -7d | grep -E 'Accepted|Failed' | tail
sudo ss -tunap | grep -v -E '127.0.0.1|::1'; ps -eo pid,ppid,user,lstart,cmd --sort=lstart | tail -20
systemctl list-timers --all; ls -la /etc/cron.* /var/spool/cron/crontabs 2>/dev/null
sudo find / -xdev -newer /etc/hostname -type f -perm -u+x 2>/dev/null | grep -vE '^/(proc|sys|run)' | head
  • Note: tools and output on a compromised host cannot be trusted, because a rootkit may have tampered with them. Rely on offline analysis and external logs.
Common follow-up questions
  • Why not just reinstall right away? Preserve the evidence first so you can identify the entry point and the scope of impact. Otherwise the vulnerability remains, and other hosts may already be compromised.
Bonus points

Mention advance preparation: an isolated subnet and account for forensics, automated snapshot scripts, a credential rotation runbook, and drill records.

Wrong answer

“Immediately kill the suspicious processes, delete the files, and reboot.”

See Hour 6, Module 5.

Q43. What is the USE method? After logging into a machine that has a problem, which commands do you run in the first 60 seconds? Intermediate
30-second answer

USE (Brendan Gregg): for each resource (CPU, memory, disks, network, and software resources such as file descriptors and connection queues), check Utilization, Saturation (queuing), and Errors. 60-second checklist: uptime → dmesg -T | tail → vmstat 1 → mpstat -P ALL 1 → pidstat 1 → iostat -xz 1 → free -m → sar -n DEV 1 → sar -n TCP,ETCP 1 → top.

Deeper answer
ResourceUtilizationSaturationErrors
CPUmpstat %usr+%sysvmstat r, PSI cpu, %stealsoft lockup #45
Memoryfree availablesi/so, PSI memoryOOM #39
Diskiostat %utilaqu-sz, await, PSI ioI/O error, #50
Networksar -n DEVListenOverflows #43, retransmissionsdrops, conntrack #42
Software resourcesfd count, task countQueue lengthEMFILE #41, EAGAIN #40
Common follow-up questions
  • What is the difference between USE and RED? USE is resource-oriented, while RED (Rate, Errors, Duration) is service-oriented. Use them together.
Bonus points

Emphasize that dmesg comes first in the list, because OOM kills, I/O errors, and a full conntrack table all show up there.

Wrong answer

“Just check top.” It shows only CPU and misses saturation and errors.

See Hour 7, Module 1.

Q44. A process is at 100% CPU. How do you locate the specific code path? Advanced
30-second answer

First determine whether the time is spent in user mode (%usr) or kernel mode (%sys), and whether it is one thread or all threads (top -H, pidstat -t). Then sample-profile it: perf record -F 99 -g -p PID plus a flame graph (FlameGraph, or feed perf script into a visualization tool). For interpreted languages, use language-specific tools (Python py-spy, Java async-profiler, Node --perf-basic-prof). If kernel-mode time is high, look at the system call distribution (perf trace -s, syscount) and softirqs (/proc/softirqs).

Deeper answer
top -H -p $(systemctl show -p MainPID --value myapp)
sudo perf top -p <PID>
sudo perf record -F 99 -g -p <PID> -- sleep 30 && sudo perf report --stdio | head -40
sudo py-spy record -o /tmp/myapp.svg --pid <PID> --duration 30
  • Containers and cloud: symbols must be available (debuginfod, or builds with frame pointers; packages have frame pointers enabled by default since Ubuntu 24.04).
Common follow-up questions
  • CPU use is not high, but it is still slow? Do off-CPU analysis (waiting on locks or I/O) with offcputime (bcc) or bpftrace.
Bonus points

Read flame graphs correctly: width is the share of samples, not time order. Look for flat tops.

Wrong answer

“Add more CPU cores.”

See Hour 7, Module 7: Advanced tools: strace, perf, and eBPF.

Q45. A service's memory grows every day until it is killed by the OOM killer. How do you troubleshoot it? Advanced
30-second answer

Confirm which memory is growing (anonymous RSS, page cache, shared memory, kernel slab), how fast it grows, and whether it correlates with traffic. Find the OOM evidence (the dmesg output in #39 and memory.events). Locate the source: per process with pidstat -r and /proc/PID/smaps_rollup; use language-level tools to find the objects (Python tracemalloc/memray, Java heap dumps); on the kernel side, use slabtop (for example, a spike in dentries). Mitigate: limit the blast radius with MemoryHigh/MemoryMax, recycle workers periodically (gunicorn --max-requests), and then fix the leak.

Deeper answer
pidstat -r -p $(pgrep -d, -f gunicorn) 60  # RSS every minute
sudo grep -E 'Rss|Pss|Anonymous' /proc/<PID>/smaps_rollup
cat /sys/fs/cgroup/system.slice/myapp.service/memory.stat | grep -E '^(anon|file|shmem|slab) '
sudo slabtop -o | head -15
  • Easy to misread: the memory.current of a cgroup includes page cache. The reclaimable file portion is not a leak.
Common follow-up questions
  • How do you prove the fix works? Run a long load test with the same workload and check that the RSS curve levels off. Then observe production for a week.
Bonus points

Mention PSI alerts and systemd-oomd, which let you handle memory pressure in a more controlled way before the kernel OOM killer acts.

Wrong answer

“Add swap, or restart every day on a schedule” as the final fix.

See Hour 7, Module 3.

Q46. How do you troubleshoot slow disk I/O? How do you tell whether the problem is the application, the file system, or the cloud disk? Intermediate
30-second answer

iostat -xz 1 shows r/w IOPS, throughput, await (latency), aqu-sz (queue), and %util for each device. pidstat -d or iotop shows which process is reading and writing. PSI io shows overall pressure. High await with IOPS or throughput near the cloud disk or VM limit → platform quota (Q37). High await without high IOPS → a backend problem or exhausted burst credits. A storm of synchronous writes (fsync) from one process → the application. Many metadata operations (lots of small files) → the file system layer (#19).

Deeper answer
iostat -xz 1 5; pidstat -d 1 5; cat /proc/pressure/io
sudo biolatency-bpfcc 10 1 2>/dev/null | tail -15  # bcc: block I/O latency distribution
sudo strace -f -e trace=fsync,fdatasync -c -p <PID>
  • Cloud-side evidence: the Azure disk IOPS/bandwidth “consumed percentage”, and AWS EBS VolumeQueueLength and BurstBalance.
Common follow-up questions
  • Is 100% %util full load? Not necessarily, for SSDs or cloud disks that can serve requests in parallel. Look at await and the queue together.
Bonus points

Discussing the latency distribution (histogram) is more valuable than discussing the average.

Wrong answer

“Just switch to an SSD.”

See Hour 7, Module 4.

Q47. What is eBPF? Which operations problems would you use it for? What are its risks? Advanced
30-second answer

eBPF loads small programs into the kernel, and the verifier checks them first. They run when attached to kprobe/uprobe, tracepoints, network hooks (XDP, tc), LSM hooks, and similar points, and they exchange data with user space through maps. Uses: low-overhead observability (bcc/bpftrace tools such as execsnoop, opensnoop, tcpretrans, biolatency, runqlat), networking (Cilium, load balancing), and security detection (Falco, Tetragon). Risks: it requires privileges (CAP_BPF and similar), kernel version compatibility (mitigated by CO-RE), and overhead from badly written probes on hot paths.

Deeper answer
sudo execsnoop-bpfcc -T | head  # which processes are forking and exec-ing frequently
sudo bpftrace -e 'tracepoint:syscalls:sys_exit_openat /args.ret < 0/ { @[comm, args.ret] = count(); }'  # errno statistics for failed opens
sudo tcpretrans-bpfcc | head
  • Compared with strace, eBPF aggregates data in the kernel and does not pause the process, so it is suitable for production.
Common follow-up questions
  • Who can load eBPF programs? It requires privileges. Most distributions disable unprivileged eBPF by default (kernel.unprivileged_bpf_disabled).
Bonus points

For example, use opensnoop to find the files leaked in #41, or use execsnoop to find short-lived processes that are saturating the CPU.

Wrong answer

“eBPF is just the new iptables.”

See Hour 7, Module 7.

Q48. Scenario: a production VM cannot be reached over SSH. How do you restore access step by step? Advanced
30-second answer

Locate the problem layer by layer. Network layer (timeout → check the security group/NSG, routing, and whether the instance is running). SSH service layer (connection refused → sshd is not running, or it is misconfigured). Authentication layer (Permission denied → keys, user, or permissions; #7, #33, #26). System layer (connects but hangs → resource exhaustion, #40, or a full disk, #18). Escalate through the tools in order, from those that depend least on software inside the instance to those that depend most: cloud agent channels (SSM, run-command) → serial console → boot diagnostics and console output → offline repair (ALAR, attaching the disk to a rescue instance) → rebuild from a snapshot or image.

Deeper answer
ssh -vvv -o ConnectTimeout=5 labadmin@10.0.0.4 2>&1 | grep -E 'Connecting|Connection|Authenticat|debug1: Server'
az network watcher test-ip-flow --vm vm-linux-lab -g rg-linux-lab --direction Inbound --protocol TCP --local 10.0.0.4:22 --remote 203.0.113.10:50000
aws ec2 get-console-output --instance-id i-0abc… --latest --output text | tail -30
az vm run-command invoke -g rg-linux-lab -n vm-linux-lab --command-id RunShellScript --scripts "systemctl status ssh --no-pager | head; df -h /; free -m"
  • After recovery, record the root cause, why monitoring did not catch it first, and whether the out-of-band channel worked, in the post-incident review.
Common follow-up questions
  • What about immutable infrastructure? Replace the instance directly from the ASG/VMSS, then isolate the old instance and analyze it offline.
Bonus points

Proactively mention preparation: boot diagnostics, the serial console, the account-level EC2 serial console setting, a break-glass account, and an approval process.

Wrong answer

Trying “a reboot” as the first step may turn emergency mode (#21) into a complete failure to boot, and it destroys the evidence on the machine.

See Hour 3, Module 7 and Hour 4, Module 7.

Q49. Design task: design an access, patching, configuration, and observability platform for 1,000 Linux servers across Azure and AWS. Advanced
30-second answer

Start by clarifying the constraints: compliance, team size, SLA, budget, and the number of OS types. Four main threads. ① Images: a dual-cloud Packer pipeline (Ubuntu 26.04, AL2023/Rocky 10), rebuilt weekly, scanned, signed, and versioned. ② Access: no public SSH; Entra sign-in with Bastion, and SSM Session Manager; group-based authorization and session auditing. ③ Patching and configuration: Azure Update Manager and SSM Patch Manager, rolled out in batches by environment; Ansible (AWX/AAP) manages runtime configuration and detects drift. ④ Observability: AMA + DCR or the CloudWatch Agent, or a unified OpenTelemetry/Prometheus stack, with centralized logs and SLO-based alerts. Deliver everything as IaC, with Azure Policy and AWS Config for continuous compliance.

Deeper answer
  • Metrics: patch compliance rate, average time to patch, drift rate, SSH login count, MTTR, and image age.
  • Trade-off: unified tools across both clouds (Ansible, OpenTelemetry) reduce cognitive load, while native services reduce operational work. Decide based on team skills and compliance requirements.
  • Risk: agent health becomes a single point of failure for the platform (#31, #35). Add heartbeats and automatic repair for the agents, and keep an out-of-band channel.
Common follow-up questions
  • How do you batch the rollout? Go by environment, then by service criticality, then gradually increase the share of each batch. Stop automatically when the failure threshold is reached (scenario 7-3).
Bonus points

Give a side-by-side comparison of the two clouds' capabilities, and point out that Arc and SSM hybrid nodes can bring on-premises servers under management.

Wrong answer

Listing only tool names, without discussing the process, metrics, and failure handling.

See Hour 5, Module 8 and Hour 6, Module 8: Comprehensive hardening architecture review.

Q50. Scenario: at 3 a.m. an alert fires for “myapp 5xx spike + disk usage at 100%.” Walk through your full handling process. Intermediate
30-second answer

Stop the bleeding first, then find the root cause. Confirm the scope of impact (how many machines, which users), and notify people if necessary. If there are multiple instances, first pull the failing instance out of the load balancer, or scale out and replace it. On the failing machine, free space: find the directories that are growing fastest and files that were deleted but are still held open (#18). Truncate logs that are still being written to rather than deleting them, and check inodes (#19). After recovery, verify the health checks and error rate. Then find the root cause: why the logs grew so fast (DEBUG left on? an error loop?), why the alert did not fire earlier (it only alerts at 100%, with no growth-rate alert), and follow through on the improvements in the post-incident review.

Deeper answer
df -h; df -i
sudo du -xh --max-depth=2 /var 2>/dev/null | sort -h | tail -8
sudo lsof -nP +L1 | sort -k7 -n | tail -5
journalctl --disk-usage; sudo journalctl --vacuum-size=500M
sudo truncate -s0 /var/log/myapp/debug.log; sudo systemctl restart myapp; curl -fsS localhost:5000/healthz
  • Post-incident outputs: send logs to journald with a size cap (#17), configure logrotate correctly, predict alerts from growth rate, fix the code that causes the error loop, and update the runbook.
Common follow-up questions
  • What else does a full root partition affect? SSH logins fail (lastlog and sessions cannot be written), package management fails, SSM sessions show a blank screen (noted in the official troubleshooting docs), and databases can crash.
Bonus points

Talk about communication: the incident channel, status page updates, and handoff records, and a “blameless post-incident review.”

Wrong answer

“rm -rf /var/log/*”.

See Module 2 of this hour (#17–#19) and Hour 7, Module 8: Comprehensive fault blind box.

Interview whiteboard diagram: the recovery ladder for when you cannot log in (Q48) and the intrusion response (Q42)① SSH / az ssh / SSM (depends on the network plus sshd or the agent)② run-command / Run Command (depends on the cloud agent)③ Serial console (depends on the kernel and getty)④ Boot diagnostics / console output (read-only)⑤ Offline repair: ALAR / attach the disk to a rescue instance / rebuildThe lower you go, the less you depend on software inside the instanceIntrusion response1 Notify · start the process2 Isolate the network · revoke instance identity3 Snapshot · memory · export logs4 Offline analysis (do not trust local tools)5 Rebuild from a trusted image · rotate credentials6 Post-incident review · hardening · detection rules
Figure 8-1: the two “flowcharts” that are most often asked to be drawn in senior-level interviews

Scenario question 8-1: a release that regresses performance

After the new myapp release, p99 latency rose from 80 ms to 600 ms, and CPU went from 30% to 45%, with no errors. How do you reach a conclusion within 30 minutes?

Key points of the reference answer
  • Roll back first or analyze first: when the rollback path is clear and users are affected, roll back first (or switch back from the canary), and keep one new-version instance for analysis.
  • Compare: flame graph differences between the old and new versions under the same load (perf/py-spy), off-CPU time (waiting on locks or I/O), the number of dependency calls (N+1 queries against Redis?), and ListenOverflows (#43).
  • Conclusion and prevention: add performance benchmarks to CI, and have releases pause or roll back automatically based on the SLO.

Scenario question 8-2: a compliance audit requires proof of “who has root access”

The audit requires a list of everyone who could obtain root on each server over the past 90 days, along with records of actual use. Design the data sources and the report.

Key points of the reference answer
  • Sources of authorization: the Entra group → “Virtual Machine Administrator Login” role assignment; the AWS IAM policy that allows SSM to run as root/sudo; local sudoers (the configuration management repository is the source of truth).
  • Usage records: SSM session logs, Bastion session logs, sudo logs (journald → centralized), auditd auid privilege escalation events, and cloud control-plane audit logs (run-command entries in the Activity Log or CloudTrail).
  • Report: automated queries, plus records of exception (break-glass) approvals, and a quarterly access review.

Scenario question 8-3: preventing another “disk full” incident

Last quarter there were four disk-related incidents (logs, inodes, temporary disks, and capacity expansion). Propose a systematic improvement plan.

Key points of the reference answer
  • Architecture: logs go only to journald and are centralized, data lives on a separate data disk, temporary disks hold only rebuildable content (#29), and sessions use Redis (#19).
  • Configuration: journald size caps (#17), tmpfiles cleanup, fstab nofail (#21), and lvextend -r as the standard procedure (#22).
  • Monitoring: alert on both block and inode metrics, predict “hours remaining” from the growth rate, and watch cloud disk performance metrics.
  • Process: runbooks plus automatic remediation (such as automatic vacuum), and quarterly drills. Include the checks in the image and in baseline tests.
or score ≥ 70% in the “Quiz”

Question quick reference + interview flashcards

50 “error → first diagnostic command → common fix” entries · 50 one-line key-point cards · printable
After class

A · Quick reference for 50 production problems

Type keywords to filter (such as denied, systemctl, No space, nvme, or oom). Click a number to jump to the matching module.

B · Flashcards for 50 interview questions

Read the question and recall your answer first, then expand the card to compare it with the one-line key point. For details, see the “interview question details” in the matching module.

General command cards

Permissions, users, and packages

namei -l /path/to/file; sudo -u myapp test -r FILE
findmnt -T FILE -no OPTIONS; lsattr FILE; getfacl FILE
id USER; sudo -l -U USER; sudo visudo -c
sudo fuser -v /var/lib/dpkg/lock-frontend; dpkg --audit
apt-cache policy PKG; dnf repolist -v

systemd and logs

systemctl status myapp; systemctl show myapp -p Result -p ExecMainStatus -p NRestarts
journalctl -u myapp -b -n 50 --no-pager; journalctl -k -b -p warning
systemctl cat myapp; systemctl edit myapp; systemd-analyze verify myapp.service
sudo systemctl reset-failed myapp; systemd-analyze security myapp
journalctl --disk-usage; systemd-cgtop

Storage

df -hT; df -i; sudo lsof -nP +L1
lsblk -f; sudo blkid; sudo pvs; sudo vgs; sudo lvs
sudo lvextend -r -L +5G VG/LV; sudo growpart DISK N; sudo xfs_growfs /MNT
sudo findmnt --verify; sudo mount -a
iostat -xz 1; cat /proc/pressure/io

Network

ss -ltnp; ss -s; ip -br a; ip route get IP
resolvectl status; resolvectl query NAME; getent ahosts NAME
sudo nft list ruleset; sudo ufw status verbose
sudo tcpdump -ni any 'tcp port 5000' -c 20
nstat -az | grep -E 'ListenOverflows|Retrans'; sudo conntrack -S

Cloud (Azure / AWS)

az vm boot-diagnostics get-boot-log -g RG -n VM
az serial-console connect -g RG -n VM
az vm run-command invoke -g RG -n VM --command-id RunShellScript --scripts "…"
az vm repair repair-button --button-command fstab -g RG -n VM
aws ec2 get-console-output --instance-id ID --latest --output text
aws ssm describe-instance-information; aws ssm start-session --target ID
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60')

Performance, kernel, and security

uptime; dmesg -T | tail; vmstat 1; mpstat -P ALL 1; pidstat 1; free -m
cat /sys/fs/cgroup/system.slice/myapp.service/memory.events
grep 'open files' /proc/PID/limits; systemctl show myapp -p TasksCurrent -p TasksMax
sudo perf top; sudo py-spy dump --pid PID
sudo ausearch -m AVC -ts recent | audit2why; sudo aa-status
chronyc tracking; timedatectl

Comprehensive drills + mock interview

8 mixed fault scenarios (read the symptoms, make your own judgment, then expand the answer) · a full mock interview with 10 questions drawn at random from 50 · final quiz
After class ≈ 40 minutes

I. Comprehensive fault drills

Each scenario combines several questions from Part A. Write down the first diagnostic command and your judgment before expanding the answer.

Scenario 1: The new deployment script fails in CI. After a manual fix, the service still won't start
deploy.sh: /bin/bash^M: bad interpreter: No such file or directory
(after fixing the line endings) Job for myapp.service failed because the control process exited with error code.
myapp.service: Main process exited, code=exited, status=203/EXEC
ls /opt/myapp/venv/bin/ → empty directory (the deploy script ran rm -rf on venv first)

Answer: the script was edited on Windows, so it has CRLF line endings (#2) → pin LF with .gitattributes. The script deleted the old venv first and then failed midway, so the gunicorn that ExecStart points to does not exist (#13) → rebuild the venv. Improvements: atomic release (a new directory plus switching a symlink), set -Eeuo pipefail and ShellCheck (Q33), and automatic rollback when the post-deploy health check fails.

Scenario 2: On Monday morning, myapp returns 500 errors and the disk is at 100%. After cleanup, the service keeps restarting and then stops
df -h / → 100%; still 100% after sudo rm /var/log/myapp/debug.log
lsof +L1 → myapp 7w … /var/log/myapp/debug.log (deleted)
myapp.service: Start request repeated too quickly.

Answer: the deleted log is still held open by the process (#18) → truncate /proc/PID/fd/N or restart the process. While the disk was full, the service kept crashing and hit the start rate limit (#14) → run reset-failed, then start it. Root fix: send logs to journald with a size cap (#17), alert on growth rate, and never leave DEBUG on permanently.

Scenario 3: A data disk was added to vm-linux-lab. After weekend platform maintenance the VM became unreachable, and once it was back, the Redis backup in /mnt was gone too
Boot diagnostics: [DEPEND] Dependency failed for /data. … emergency mode
/etc/fstab: /dev/sdc1 /data xfs defaults 0 2
/mnt/redis-backup does not exist; /mnt/DATALOSS_WARNING_README.txt

Answer: the device name changed during maintenance and there is no nofail (#28/#21) → repair it from the serial console or with ALAR, and switch to UUID=…,nofail. The backup was on the temporary disk and was lost during maintenance or redeployment (#29) → move it to a managed data disk or Blob. Review: on Azure, do not use /dev/sdX or /mnt to store persistent data.

Scenario 4: A new AL2023 instance in a private subnet: SSM cannot connect, SSH is rejected, and containers on the instance cannot get AWS credentials
An error occurred (TargetNotConnected) when calling the StartSession operation: i-0abc… isn't connected.
ubuntu@10.20.1.15: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Container: Unable to locate credentials; MetadataOptions.HttpPutResponseHopLimit = 1

Answer: the instance profile or the ssm/ssmmessages endpoints are missing (#35) → add them. The AL2023 username should be ec2-user (#33). The launch template set the hop limit to 1, so containers cannot obtain the IMDSv2 token (#34) → set it back to 2, or give the container its own workload identity.

Scenario 5: A new colleague cannot sign in to Azure, and on an RHEL-family test machine, nginx returns 502
az ssh vm … → Connection closed by 10.0.0.4 port 22
rhellab: connect() to 127.0.0.1:5000 failed (13: Permission denied) while connecting to upstream
avc:  denied  { name_connect } … scontext=system_u:system_r:httpd_t:s0 …

Answer: the new colleague is a Contributor but does not have the “Virtual Machine User/Administrator Login” role (#26) → assign it by group. SELinux does not allow httpd_t to connect to port 5000 (#47) → use setsebool -P httpd_can_network_connect 1 or adjust the port label, rather than turning SELinux off.

Scenario 6: Load test ahead of a sales promotion: p99 spikes, intermittent connection timeouts, and then the service is killed
kernel: nf_conntrack: nf_conntrack: table full, dropping packet
kernel: TCP: request_sock_TCP: Possible SYN flooding on port 0.0.0.0:5000. Sending cookies.
kernel: Memory cgroup out of memory: Killed process 2210 (gunicorn) …
myapp.service: Failed with result 'oom-kill'.

Answer: a storm of short-lived connections fills conntrack (#42) → increase the table size and have upstream services reuse connections. Workers cannot keep up, so the accept queue overflows (#43) → improve processing capacity and the backlog. After adding workers, memory exceeds MemoryMax (#39) → plan memory by peak RSS, or scale out horizontally. Conclusion: capacity planning must cover connections, queues, and memory together.

Scenario 7: After patch night, one VM won't boot, another boots but apt reports errors, and a third has the wrong time
VM-A: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
VM-B: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
VM-C: Release file … is not valid yet (invalid for another 3h 12min 5s).

Answer: A: initramfs generation failed because /boot is full (#38) → pick the old kernel from the serial console, clean up /boot, and rebuild the initramfs. B: the upgrade was interrupted (#10) → dpkg --configure -a. C: after restoring from a snapshot, the clock is behind and chrony has not synchronized (#49) → chronyc makestep, and allow NTP/NTS traffic. Improvements: check /boot and disk space before patching, and use batches with verified automatic reboots (scenario question 7-3).

Scenario 8: The server is “very slow”: load average is 40, 80% CPU is idle, and then the root filesystem becomes read-only
load average: 40.12 …; vmstat b=38 wa=55
kernel: INFO: task jbd2/sda1-8:245 blocked for more than 122 seconds.
kernel: EXT4-fs (sda1): Remounting filesystem read-only

Answer: tasks piling up in D state inflate the load average (#46). The root cause is storage: severe latency or failure on the cloud disk (#44), after which ext4 detected errors and switched to read-only (#50). Response: preserve a snapshot → run e2fsck in a rescue environment → check the platform disk health and quotas. In immutable environments, replace the instance and disk directly.

II. Full mock interview (10 questions drawn at random from 50)

Two-minute countdown per question. Answer out loud first (you can write key points in the text box), then expand the reference answer and self-rate as “answered / partial / didn't know.” At the end, the round's score and the cumulative mastery rate for each module are shown. Self-ratings are stored in this browser.

III. Open-ended self-check (6 questions)

  1. Draw the full path of ./deploy.sh from pressing Enter to the exit code. Mark the step where #1, #2, #4, #13, #19, and #40 each occur, and the errno or exit code that goes with each.
  2. Explain what “Connection refused,” “timeout,” and “Temporary failure in name resolution” each tell you about how far the packet got, and give two diagnostic commands for each.
  3. Write a production-grade systemd unit for myapp, and explain which problem in Part A each resource-limit option guards against.
  4. Neither the Azure VM nor the EC2 instance can be logged into. For each, list the five tools you would use, in order, and the component inside the instance that each one depends on.
  5. The team is upgrading from Ubuntu 24.04 to 26.04. List at least eight changes that need verification (sudo-rs, rust-coreutils, chrony, Dracut, APT 3.1, removal of cgroup v1, …) and how to verify each.
  6. Design a unified alert for exhaustion of three resource types: disk, memory, and connections. Cover the metrics, thresholds, alert text, and a runbook link.

IV. Final quiz (12 questions)

Sources and versions

Verified on: 2026-11-17 · Version baseline: Ubuntu Server 26.04 LTS (kernel 7.0, systemd 259, APT 3.1) · Rocky / AlmaLinux 10.2 · Amazon Linux 2023

Version and platform facts

ItemFacts used in this hourSources (accessed 2026-11-17)
Ubuntu 26.04 LTSResolute Raccoon, released 2026-04-23. Standard support runs five years to 2031-04, with Ubuntu Pro ESM for 10 years in total. Upgrading from 24.04: GA kernel 6.8→7.0 (HWE 6.17→7.0); systemd 255→259 (cgroup v1 removed; the last version that supports SysV service scripts); APT 2.7→3.1 (apt-key removed); sudo-rs is the default sudo (the original is renamed sudo.ws, and sudo-ldap is removed); core tools come from rust-coreutils (GNU versions are available with a gnu prefix, while cp/mv/rm are still GNU); new installs default to chrony (NTS); the default initramfs is Dracut; OpenSSH 10.2 (no longer generates DSA host keys); Netplan 1.2; Python 3.14.Ubuntu Releases · 26.04 release notes · Summary for LTS users
RHEL-family comparisonRocky Linux 10.2 and AlmaLinux 10.2 have been released (compatible with RHEL 10.2, mid-2026). The 10.x series is based on the 6.12 LTS kernel.Rocky Linux 10.2 · AlmaLinux blog
Linux kernel (upstream)mainline 7.4-rc3; stable 7.3.4 (2026-11-10); longterm 6.18.63, 6.12.117, 6.6.162, 6.1.192, 5.15.225, 5.10.274kernel.org releases.json
systemd (upstream)Latest v262.2 (2026-11-05); Ubuntu 26.04 ships 259systemd releases
Multipassv1.17.1 (2026-11-13). Launches the current LTS when no image is specified; snapshot/restore require the instance to be stopped first.Multipass releases
Amazon Linux 2023Latest version 2023.12.20261112. Instances launched from the AL2023 AMI require IMDSv2 by default, with a hop limit of 2 (the AMI's imds-support=v2.0). Token lifetime is 1 second to 6 hours. SSM Agent is preinstalled (AL2023, Ubuntu Server, and others).AL2023 release notes · AL2023 IMDSv2 · AMIs with SSM Agent preinstalled
AWS Session ManagerTargetNotConnected message and causes (configuration, cross-account/region, the ssm/ssmmessages endpoints, and before agent 3.3.40.0 also ec2messages, VPC BPA, resource pressure, agent not running, and a missing instance profile); agent log linesTroubleshooting Session Manager
Azure Entra sign-inExtension Microsoft.Azure.ActiveDirectory/AADSSHLoginForLinux. Requires a system-assigned managed identity. Roles: Virtual Machine Administrator Login / User Login; Owner and Contributor do not grant these automatically. Exit codes 22 (no managed identity) / 23 (old extension). “Connection closed by <ip> port 22”. Supports Ubuntu 16.04–26.04 and Rocky/Alma 10. VM needs at least 1 GB of memory.Sign in to a Linux VM with Entra ID
Azure fstab and temporary diskExample emergency-mode serial log, UUID + nofail, the serial console, az vm repair repair-button --button-command 'fstab' (ALAR). The temporary disk may lose data during maintenance, redeployment, or stop; on Linux it is usually /dev/disk/azure/resource.fstab boot issues · Managed disks overview

Source of the exact error text (strings checked against the source code)

Error / messageLocation (default branches upstream, 2026-11-17)
Job for %s failed because %s. See "%s status %s" and "%s -xeu %s" for details. · Explanatory text: the control process exited with error code / start of the service was attempted too often / of an out-of-memory (OOM) situationsystemd: src/shared/bus-wait-for-jobs.c
Start request repeated too quickly. · Failed with result '%s'.systemd: src/core/unit.c
The kernel OOM killer killed some processes in this unit. · Scheduled restart job, restart counter is at %u.systemd: src/core/cgroup.c, src/core/service.c
Warning: The unit file, source configuration file or drop-ins of %s changed on disk. Run 'systemctl%s daemon-reload' to reload units.systemd: src/systemctl/systemctl-util.c
Exit code names EXEC (203), CHDIR (200), USER (217), NAMESPACE (226)systemd: src/shared/exit-status.c; numbering in systemd.exec(5)
You are in %s mode. After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, or "exit" to continue bootup.systemd: src/sulogin-shell/sulogin-shell.c
%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%d · Memory cgroup out of memorylinux: mm/oom_kill.c
INFO: task %s:%d blocked%s for more than %ld seconds. (%s is empty, or “ in I/O wait”)linux: kernel/hung_task.c
BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]linux: kernel/watchdog.c
nf_conntrack: table full, dropping packetlinux: net/netfilter/nf_conntrack_core.c
%s: Possible SYN flooding on port %pI4:%u. %s. (Sending cookies / Dropping request)linux: net/ipv4/tcp_input.c
VFS: Unable to mount root fs on %s · VFS: file-max limit %lu reached · Remounting filesystem read-onlylinux: init/do_mounts.c, fs/file_table.c, fs/ext4/super.c
Authentication refused: %s · bad ownership or modes for directory %s · WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!openssh-portable: auth2-pubkeyfile.c, misc.c, sshconnect.c
Could not get lock %s. It is held by process %d (%s) · Unable to acquire the dpkg frontend lock (%s), … · dpkg was interrupted, you must manually run '%s' to correct the problem. · The following signatures couldn't be verified because the public key is not available: · Release file for %s is not valid yet (invalid for another %s).apt: apt-pkg/contrib/fileutl.cc, apt-pkg/deb/debsystem.cc, methods/gpgv.cc, apt-pkg/acquire-item.cc
wrong fs type, bad option, bad superblock on %s, missing codepage or helper program, or other errorutil-linux: libmount/src/context_mount.c
%s is not in the sudoers file. (sudo.ws) · I'm sorry {user}. I'm afraid I can't do that (sudo-rs)sudo: plugins/sudoers/logging.c; sudo-rs: src/common/error.rs, src/sudo/pipeline.rs
Connection in use: %s · Retrying in 1 second. · Can't connect to %sgunicorn: gunicorn/sock.py
errno text: Permission denied, Operation not permitted, No space left on device, Argument list too long, Too many open files, Resource temporarily unavailable, Read-only file system, Temporary failure in name resolutionerrno(3), getaddrinfo(3) (glibc strerror / gai_strerror)

Video verification note

All videos were checked on 2026-11-17 through the YouTube oEmbed endpoint (https://www.youtube.com/oembed?url=…&format=json) for titles and channels. oEmbed does not return duration or publication date, so those are not listed. Verified: Learn Linux TV, “Linux Crash Course - Understanding File & Directory Permissions” (4e669hSjaX8), “journalctl Basics: How to Easily Check Your Linux Logs” (0dG3vUYt7Uk), “Getting Started with cloud-init” (exeuvgPxd-E), “Linux Load Average: Simple Explanation for Beginners” (7Tx0DsHEuTM); Akamai Developers, “How to use chmod | Manage File Permissions in Linux” (ngJG6Ix5FR4), “Linux for Programmers #6 | Networking Commands” (vDWY3PuHMX8); SERVER LAB, “Fix Could Not Get Lock on Ubuntu 24.04: apt and dpkg” (eag5YHHE9F8); GEEKrar Guides, “FIXED: User is not in the sudoers file. This incident will be reported” (ZxOwFOtcaaA); Bo Morgan Tech, “fixing broken systemd services” (XPpj3VWNwnk), “Learn journalctl in 7 Minutes — Become the Linux Troubleshooting Hero” (iD0xmhJAjwk); Incidentverse Tech, “Linux Inode Exhaustion 🚨 | No Space Left on Device Even With Free Disk Space | SRE Incident” (xjqL8fOBgfY); Mike's Tech Tips, “How to get your Linux system out of emergency mode” (-2wca_0CpXY); DevOps Made Simple, “Linux Networking Troubleshooting Simply Explained (ip, ss, ufw)” (rupdY714Jaw); Microsoft Developer, “Troubleshoot and diagnose Azure Virtual Machines with Serial Console | Azure Friday” (KxKZW3VAcU4); Microsoft Azure, “How to use GRUB and the Azure Serial Console on a Linux Virtual Machine | Azure Tips and Tricks” (SnqwTqlvYkc); Amazon Web Services, “Why can't I connect to my Amazon EC2 Linux instance using SSH?” (ey4JtaoObqE), “How do I troubleshoot issues with AWS Systems Manager Session Manager?” (g7dp2rWj-3g); AiceBreakers, “Understanding cloud-init - Azure Virtual Machines” (YdlhpZonbrM); Dennis Traub, “How to connect to an EC2 instance without a key pair / Access EC2 with the AWS SSM Session Manager” (f5daHmVGyC8); Brendan Gregg, “Linux Performance Analysis in 60 seconds” (ZdVpKx6Wmc8), “Linux Performance Tools, Brendan Gregg, part 1 of 2” (FJW8nGV4jxY), “part 2 of 2” (zrr2nUln9Kk), “SCALE14x Broken Linux Performance Tools (2016)” (OPio8V-z03c); Nir Lichtman, “What Happens When Linux Runs Out of Memory?” (Cm3-6cOwICU); Red Hat, “Solve SELinux errors: Troubleshooting basics” (Rm1BeVChABE); ByteByteGo, “How Does Linux Boot Process Work?” (XpFsMB6FoOs); Joe Collins (EzeeLinux), “How Linux Boots” (EjrAzulPsT4); The Linux Foundation, “Tutorial: Debugging with Strace - A Peek Behind the Scenes of Linux Processes - Avikam Rozenfeld” (SUO0rQerpMk); tutoriaLinux, “Popular Linux Interview Questions for DevOps Interviews” (GdrjTVDelI0), “Top 10 Linux Job Interview Questions” (l0QGLMwR-lY); grobelDev, “Linux Performance Troubleshooting Demos” (rwVLa9me7e4); Mark Alexander, “The Most Useful Tool You Have Never Heard Of (STRACE)” (quQmdgIUCaU); LaurieWired, “Using Strace to Trace Linux Syscalls” (mBfurelWwPQ); Intellipaat, “20 Most Asked Linux Interview Questions 2026 …” (MxfLlmSofNc); onlineexamprep, “Top 50 Senior Linux Engineer Interview Questions & Answers …” (3E_AOdmxlUc). Not found: verified videos that specifically cover the CRLF interpreter error and chattr, the APT 3 key migration, deleted files that are still held open and LVM tiered expansion, Entra login roles and AMA/DCR association, the IMDSv2 hop limit, conntrack and accept queue overflow with ext4 read-only, trade-offs in golden image layering, or cloud intrusion response. The related pages provide storyboard scripts instead. Third-party videos, especially interview-style ones, vary in quality and may be based on older versions; use them for reference only.

Voice narration notes

The “Voice” tab uses the browser's built-in Web Speech API (en-US English voice). No data is uploaded, and the courseware has no embedded audio. An English voice pack must be installed on the system; otherwise, read the script directly or use another TTS tool.

Known limitations

  • The commands and reproduction experiments in this courseware have not been run in a real linuxlab, Azure, or AWS environment. All “expected output” is written from source code, official documentation, and tool conventions. PIDs, IPs, UUIDs, instance IDs, times, and version suffixes are illustrative values.
  • Strings marked “checked against source code” were compared with the default branches of each upstream project as of 2026-11-17. The versions shipped with Ubuntu 26.04 (systemd 259, APT 3.1, OpenSSH 10.2, kernel 7.0, and so on) may be worded slightly differently. The outer formats are illustrative: journald timestamps and prefixes, the TCP: / watchdog: / nf_conntrack: prefixes before kernel messages, the mount: /data: prefix, and the sudo: prefix for sudo and sudo-rs.
  • Messages marked “verify on your system” were not checked word for word: the original sudo's sudoers syntax error output and the matching wording in sudo-rs, the fork: retry text in bash, the error wording for /usr/bin/env under rust-coreutils, the text after the parentheses in curl errors, the dnf repository metadata error format, the status --long fields of cloud-init, the Azure VM agent status message and the full AADSSHLoginForLinux status text, the list of SSH authentication methods for EC2, the IMDS 401 response body, growpart output, the field order in SELinux AVC and AppArmor audit records, the NFS “not responding” kernel message, and the “Main process exited, code=…” and “Failed at step EXEC spawning …” lines in systemd.
  • Handled conservatively (follow the official documentation): this hour does not state the Amazon Linux 2023 support end date or the specific dnf version for the RHEL 10 series. It also does not detail the division of labor between cloud-init and walinuxagent on Azure, or the applicability of ResourceDisk.EnableSwap; the chrony configuration syntax for the Azure PTP clock source and AWS Time Sync; the query rate limit for AWS Route 53 Resolver; or Kubernetes' support status for swap. The ext4 default of 5% reserved blocks and the journald SystemMaxUse default (10%, capped at 4G) come from the general description in the man pages. The systemd DefaultLimitNOFILE default of 1024:524288 and DefaultStartLimitIntervalSec=10s / Burst=5 come from the general description in the systemd documentation.
  • Ubuntu 24.04 users: the sudo prompt, the time synchronization service (timesyncd), the initramfs tool (update-initramfs), and APT (2.7, which still has apt-key but deprecates it) differ from the 26.04 descriptions in this hour. These differences are noted in the relevant questions. WSL2 is not suitable for storage and kernel-level labs.
  • The cloud labs (3-C, 3-D) incur small charges and require the corresponding permissions. Lab 4-D needs the kernel module dm_delay for dm-delay. It is usually provided by the generic Ubuntu kernel; verify on your system.
  • Mock interview self-ratings are stored only in the current browser's localStorage, and they are lost if site data is cleared.