Every level, in the open
Linux Sysadmin Pro
12 worlds · 131 levels · 11 bosses
SOLUTION HIDDENTeachers see answer keys in the classroom.
The sequel: recover boxes that will not boot, run real nginx, haproxy, chrony and dnsmasq, build real nftables walls, and harden a server to a checklist. GRUB/rescue, SELinux, firewalld/ufw, PAM and auditd are honest simulators (labelled SIM) that show the real RHEL and Ubuntu commands.
Guided levels show the command first. Alone levels give the goal only. Bosses and exams are timed.
Jump to a world
World 1Boot & Recovery
12 levelsGRUB, kernel args, rescue shells, lost root passwords and broken fstabs on a SIM RHEL console (next: real Rocky VMs), plus real fstab and sysctl.
Level 1: Power on
Objective: Attach to the RHEL box with console, read its kernel line with e, and boot it.
Every Linux box starts the same way: firmware → GRUB → kernel + initramfs → systemd. GRUB shows a menu; e shows the kernel line it is about to use.
Commands taught
sim-consolegrubLevel 2: The quiet room
Objective: Boot the box once into rescue.target by adding systemd.unit=rescue.target to its kernel line.
A kernel argument you add at the GRUB edit screen lasts one boot. systemd.unit=rescue.target boots a root shell with the disks mounted and no services: the quiet room for repairs.
Commands taught
kernel-argsLevel 3: Locked out
Objective: Reset the box's root password to Rescue-2026 with rd.break, and log in.
Nobody knows the root password. rd.break stops the boot in the initramfs, with the real disk read-only at /sysroot. From there you can change the password, if you remember SELinux.
Commands taught
rd-breakLevel 4: Read the entry, change the entry
Objective: On a running box, read the boot entry, add the argument audit=1 for good, take it away again, then reboot and boot the default entry.
The e key edits the boot line for ONE boot. grubby edits the boot entry itself, so a change stays for every boot. You will meet it in four small steps: look, add, remove, prove with a reboot.
Commands taught
grubbyLevel 5: The tattoo
Objective: Make the box always boot without "rhgb quiet", so the next outage shows its errors.
The e key changes one boot. grubby changes the boot entry itself, for every boot and every kernel.
Level 6: Promise vs contract
Objective: Set kernel.panic to 10 on this VM, now and after every reboot.
Back on your real VM. A kernel that panics should reboot itself after 10 s instead of hanging forever: kernel.panic=10. sysctl -w sets it now; /etc/sysctl.d makes it survive a reboot.
Commands taught
sysctl-dLevel 7: PID 1 is you
Objective: Another box, another lost password: reset root to Night-Shift-7 using init=/bin/bash, and log in.
init=/bin/bash replaces systemd with a bare shell as PID 1, on every distro. Remount / rw, fix, relabel, and hand over with hidden (never exit).
Commands taught
init-bashLevel 8: Peek into the backpack
Objective: Look inside the initramfs, rebuild it, then rebuild it with the nvme driver added.
Before the real root exists, the kernel unpacks a small backpack of drivers called the initramfs. lsinitrd looks inside it, hidden packs a new one, and --add-drivers puts one more driver in.
Commands taught
initramfsLevel 9: The forgotten backpack
Objective: Rebuild the box's initramfs with the virtio_blk driver, reboot and boot the normal entry.
The box moved to a new hypervisor whose disks need the virtio_blk driver. The initramfs lacks it, so the kernel never finds root; you booted the rescue entry (it has every driver) to fix it.
Level 10: You are in emergency mode
Objective: PAGER: rhel10 is stuck in emergency mode after maintenance, so fix its fstab and bring it to multi-user.
Someone pulled the backup disk but left its fstab line. The box stops in emergency mode with / read-only.
Commands taught
emergency-modeLevel 11: The wrong label
Objective: PAGER: /srv/llogs is empty after every reboot, so fix its /etc/fstab line (LABEL or the real UUID, plus nofail) to mount it at boot.
Real VM, real disk: the logs disk (label LOGS) has an fstab line with a stale UUID, so hidden fails and /srv/llogs is empty after every boot.
Level 12: BOSS: The box that won't boot
Objective: Bring rhel10 back: boot it once, reset root to Pager-Duty-42, fix the kernel entry and fstab for good, and log in.
A colleague "tidied up" rhel10 at 2 a.m.: a grubby typo in root=, a dead fstab line, and then he forgot the root password. Three faults, one console.
World 2Remote Doors
12 levelsThe new office server: ssh keys only, an honest clock with chrony, office names with dnsmasq, and shared folders (NFS exports = SIM).
Level 13: Test before you trust
Objective: Nobody can ssh into server since last night, so find the bad line with hidden, fix it, and prove ssh server@server works.
The ssh server rereads its config for every new connection. One bad line and every new login is refused. hidden tests the config and names the broken file and line.
Commands taught
sshd-testLevel 14: Keys only
Objective: Turn password logins off for good with a drop-in /etc/ssh/sshd_config.d/10-harden.conf, prove it with sudo sshd -T, and check your key still gets you in.
sshd reads /etc/ssh/sshd_config.d/*.conf in name order, and the FIRST value for a keyword wins. This VM ships ptr.conf with PasswordAuthentication yes, so your setting must live in a file that sorts first.
Commands taught
sshd-dropinssshd-hardeningLevel 15: Wait for the clock
Objective: Read the time sources, wait for a sync that cannot come, start the office time server, and wait again.
chronyc talks to chronyd, the time daemon. hidden lists the time servers (^* = synced to it, ^? = cannot reach it); chronyc waitsync waits until the clock is synced, then answers yes or no.
Level 16: What time is it?
Objective: Point chrony at the time server 127.0.0.2 instead of the pool, enable --now chronyd, run `hidden`, and get ^* in hidden.
chronyd keeps the clock in sync with NTP servers listed in chrony.conf (server NAME iburst). The office time server is 127.0.0.2. hidden shows ^* next to the server you are synced to.
Commands taught
chronyLevel 17: Test the names file
Objective: Test the office DNS config, add one name record, and test again.
dnsmasq is a tiny DNS server. Like sshd -t and nginx -t, it can test its own config before you start it: dnsmasq --test says "syntax check OK" or names the bad line.
Commands taught
dnsmasqLevel 18: Office names
Objective: Make the office DNS on 127.0.0.1 answer files.office.lan → 10.20.0.15 and ntp.office.lan → 127.0.0.2, and keep dnsmasq running across reboots.
dnsmasq is a small DNS server. A line host-record=NAME,IP in /etc/dnsmasq.conf answers NAME with IP. dnsmasq --test checks the file; dig @127.0.0.1 asks it directly.
Level 20: Sharing folders (SIM)
Objective: Export /srv/share read-only to 10.20.0.0/24 and /srv/scans read-write to the scanner 10.20.0.40 only, apply it, and check with hidden.
[SIM] An NFS server shares the folders in /etc/exports, one "path client(options)" per line, and exportfs -ra loads the file into the live table. This VM has no NFS server: exportfs and showmount are simulators with the real syntax.
Commands taught
sambaLevel 21: The guest list
Objective: In sshd_config.d/10-harden.conf: no root login, no passwords, only server allowed. sshd -t silent, and your key login still works.
AllowUsers server lets ONLY the listed users log in over ssh, key or not, and PermitRootLogin no refuses root by name. Add keys only and you have the classic hardened door.
Level 22: Clock drift
Objective: PAGER: the clock drifts and hidden shows ^? for 127.0.0.2, so make it sync to the office time server again and survive a reboot.
^? and Reach 0 in hidden mean the time server never answers: a chrony server only answers networks on an allow line. A client that is not enabled is gone after the next reboot.
Level 23: The wrong address
Objective: PAGER: files.office.lan points to the dead NAS 10.20.0.99. dig @127.0.0.1 files.office.lan must answer 10.20.0.15 and nothing else.
dnsmasq answers from its config AND from /etc/hosts. A stale hosts line or a typo in a record and half the office goes to the old NAS.
Level 24: BOSS: The new office server
Objective: Harden ssh (no root, keys only, only server), sync time to 127.0.0.2, serve files.office.lan, export /srv/share read-only, then reboot and prove it.
Ticket: the new office server goes live tonight, and Dave started the setup before his holiday. Door, clock, names and shares must all come back after a reboot.
World 3The Front Door
12 levelsReal nginx and HAProxy: serve a site, add server blocks, proxy to two backends, balance and health-check them, read the logs.
Level 25: Test before you serve
Objective: Test the web server config, fix the typo it names, test again, and list the files nginx reads.
nginx -t reads every config file and says "test is successful", or names the bad file and line. Run it after every edit, before any start or reload.
Level 26: Open the doors
Objective: Make nginx serve /var/www/site on port 80 instead of its 404 page, test it with `nginx -t`, and start it at boot.
nginx serves the folder named by root in a server { } block. nginx -t tests every config file; only a config that passes should ever be started.
Commands taught
nginxLevel 27: Two names, one door
Objective: Add a server block for shop.office.lan serving /var/www/shop in /etc/nginx/http.d/shop.conf, test it, and reload nginx.
One nginx serves many sites: each server { } block has a server_name, and the Host of the request picks the block. reload loads new blocks without dropping a single connection.
Commands taught
nginx-server-blocksLevel 28: Pass it back
Objective: Publish the app as app.office.lan: a server block in /etc/nginx/http.d/app.conf that proxies to 127.0.0.1:8081, tested and reloaded.
The office app runs on 127.0.0.1:8081, where nobody outside can reach it. location / { proxy_pass http://127.0.0.1:8081; } makes nginx forward requests to it and hand back the answer.
Commands taught
reverse-proxyLevel 29: Two cooks
Objective: Make app.office.lan use both backends (8081 and 8082) through an upstream block, so that requests alternate between app1 and app2.
A second copy of the app runs on 127.0.0.1:8082. An upstream block names both servers, and proxy_pass http://apps; makes nginx take turns between them.
Commands taught
nginx-upstreamLevel 30: Check before you start
Objective: Check the live HAProxy config, check a draft with a typo in ~/lb.cfg, fix it and check again.
HAProxy can check a config file the way nginx -t does: haproxy -c -f FILE. -c = check only, -f = which file. A broken file prints the line to fix and exits with an error; a good one says "Configuration file is valid".
Commands taught
haproxyLevel 31: HAProxy
Objective: Add a frontend on 127.0.0.1:8080 and a roundrobin backend with app1 and app2 to /etc/haproxy/haproxy.cfg, check it, and run HAProxy at boot.
HAProxy is a dedicated load balancer: a frontend binds an address and port, a backend lists the servers, balance roundrobin takes turns. haproxy -c -f checks the file like nginx -t.
Level 32: sed: remember a piece
Objective: Practise on a small file, ~/menu.txt: remember a word, then add a word to the end of each line, then save it.
In a sed replacement, \( ... \) remembers what it matched, and \1 pastes it back. So "keep the line, add a word at the end" is: s/^\(the whole line\)$/\1 and the new word/. You need it next to add check to every server line.
Level 33: A cook goes home
Objective: Every request to 127.0.0.1:8080 must succeed while app2 is down: add health checks to both servers (keep app2 in the config) and restart HAProxy.
app2 just crashed, and HAProxy still sends it every second request: those visitors get 503. A check on each server line makes HAProxy test them and skip the dead one.
Commands taught
health-checksLevel 34: 502 at lunch
Objective: PAGER: app.office.lan answers 502 Bad Gateway, so find the bad backend address in nginx's error.log and fix it.
502 Bad Gateway means nginx could not talk to a backend. access.log only has the 502; error.log says which upstream address refused the connection.
Commands taught
nginx-logsLevel 35: Address already in use
Objective: PAGER: the intranet is down after Dave's maintenance, so find what holds port 80, stop it for good, and get nginx serving again across reboots.
nginx is enabled but failed: bind() to 0.0.0.0:80 failed (98: Address in use). Only one program can listen on a port, and ss -ltnp names it.
Level 36: BOSS: The front door is down
Objective: Bring the chain back: HAProxy on 127.0.0.1:8080, nginx on port 80, app.office.lan reaching app1 AND app2, and all of it after a reboot.
nginx on :80 forwards app.office.lan to HAProxy on 127.0.0.1:8080, which balances app1 and app2. After Dave's "HAProxy upgrade" the whole chain is down.
World 4Firewalls for Real
13 levelsReal nftables walls tested from a second machine, rules that survive reboot, port redirects, then firewalld and ufw (SIM, real nft).
Level 37: Read the wall
Objective: Read the live ruleset, find the port it blocks, and prove it from the client.
In Basics the firewall was a text file; now the kernel holds the rules and hidden prints them. Your VM is the server, and a second machine, "client", sits at 10.9.0.2.
Commands taught
fw-labnft-listLevel 38: Your first rule
Objective: The dev app on 8080 is visible from the client: build table inet fw, a base chain input and a rule that drops 8080, keeping port 80 open.
nft builds a tree: a table (family inet = IPv4+IPv6) holds chains; a base chain hooks into the kernel ("hook input" = packets for this machine); rules inside run top to bottom.
Commands taught
nft-buildLevel 39: Default drop
Objective: Chain inet fw input is ready (policy accept): accept replies, lo, ssh and http, then set policy drop so only 22 and 80 get in.
An allow-list: accept what you name, drop the rest with the chain policy. Two accepts nobody names but everybody needs: ct state established,related (replies to YOUR connections) and iif lo (the machine talking to itself).
Commands taught
nft-policyLevel 40: Dry run, then edit a file
Objective: Check ~/draft.nft, preview a new line with sed, save it with -i, and check again.
Rules in a file can be tested without loading them: nft -c -f FILE checks the syntax and changes nothing. And to change one line of a file from the command line, sed can add a line after a match: sed '/pattern/a new line' FILE.
Commands taught
nft-persistLevel 41: Survive the reboot
Objective: Yesterday's wall (22 and 80 only, policy drop) is live but not saved: make it survive a reboot (the check reboots and tests again).
Live rules live in the kernel and die with it. At boot the nftables service loads /etc/nftables.nft, so what is not in that file does not exist after a reboot.
Level 42: The app moved
Objective: The shop app listens on 8080 only, but every client still types http://10.9.0.1/: make port 80 from the network land on 8080.
A nat chain on hook prerouting rewrites where an incoming packet is going, before the filter sees it. redirect to :PORT is DNAT to this same machine.
Commands taught
nft-dnatLevel 43: Meet firewall-cmd
Objective: Look at the zones, open https for good, and make it live.
This box plays a RHEL server: firewalld (SIM) keeps zones and services. firewall-cmd talks to it. Two views: runtime (live now) and permanent (saved). --permanent writes the saved one, --reload makes live match saved.
Commands taught
firewall-cmdLevel 44: Red Hat's way
Objective: Open http for good, let ONLY the admin network (10.8.0.0/24) reach the app on 8080 (rich rule, for good), then read what firewalld really wrote.
This box plays a RHEL server: firewalld (SIM) is running with zone public (ssh only). firewall-cmd changes runtime (live) or, with --permanent, the saved zone file; --reload makes live = saved. It writes real nft rules.
Level 45: Undo a service, forward a port
Objective: mysql is open in the saved config: close it for good, then forward port 2222 to ssh (22).
The same firewall-cmd, two more verbs: --remove-service closes a service, --add-forward-port sends one port to another. Both are saved with --permanent and applied with --reload.
Level 46: Meet ufw
Objective: Build a small wall with ufw, enable it, then delete one rule by its number.
This box plays Ubuntu: ufw (SIM) is the friendly front of nftables. The safe order is always: default deny, allow ssh first, allow what you need, then enable. status numbered gives each rule a number so you can delete one.
Commands taught
ufwLevel 47: Ubuntu at 5 p.m.
Objective: Before 5 p.m.: default deny incoming, allow 22/tcp and 80/tcp, delete the old database rule and enable ufw, so the client reaches only 22 and 80.
This box plays Ubuntu: ufw (SIM) is installed but inactive, and an old rule from a past project is still in its list. ufw writes real nft (table ip filter).
Level 48: Monday after the reload
Objective: Make it right for good (permanent AND live): http open, mysql closed, and port 2222 forwarded to ssh (22) for the old jump-host scripts.
On the RHEL box someone fixed the web with runtime-only commands. The weekly --reload threw it all away, and the saved config still opens mysql to the world.
Level 49: BOSS: Lockdown without lockout
Objective: Lock it down (ssh only from 10.8.0.0/24, http for all, replies allowed, the rest dropped), load it atomically and make it survive a reboot.
The audit is tomorrow and the prod box is wide open (3306 and 8080 for everybody). A colleague left a draft in ~/lockdown.nft with two bugs, and one of them locks the admins out of ssh.
Commands taught
fw-lockout
World 5SELinux
13 levelsThe 403 chmod cannot fix: labels, restorecon, semanage, booleans and AVCs, as a SIM warm-up of the RHEL policy before a real Rocky VM.
Level 50: Is the bouncer awake?
Objective: The bakery page gives 403 with good permissions: prove SELinux is the cause with a one-minute permissive test, then put enforcing back.
This box plays a RHEL server with SELinux (SIM). A second lock next to rwx: the policy says what each service may touch. getenforce shows the mode; hidden (permissive) only logs denials, hidden (enforcing) blocks them.
Commands taught
selinux-simmac-distrosgetenforceLevel 51: The note on the fridge
Objective: Someone left this server in permissive two years ago, in the file AND live: make it enforcing now and after a reboot (the check reboots).
/etc/selinux/config decides the mode at boot (SELINUX=enforcing|permissive|disabled). setenforce changes the running kernel only. sestatus shows both: Current mode and Mode from config file.
Commands taught
selinux-configLevel 52: Name tags
Objective: Read the name tags: the web server's domain, the one page with the wrong file type, and your own context.
Every process, file and port wears a context user:role:TYPE:level. -Z shows it: ps -eZ for processes, ls -Z for files, id -Z for you. The policy mostly reads the TYPE: domain httpd_t may read httpd_sys_content_t files.
Commands taught
selinux-labelsLevel 53: Moved, not copied
Objective: Publish ~/sale.html with mv, see the 403 and its AVC, then fix the label (no permissive, no booleans).
mv keeps a file's label (it moves the same inode); cp makes a new file that takes its new directory's label. A page made in your home and mv'd into /var/www/html still says user_home_t, and httpd_t may not read that. restorecon -v puts the default label back.
Commands taught
restoreconausearchLevel 54: Teach the policy a new default
Objective: A new folder /srv/cafe holds a web page. Teach the policy its label, then apply it.
restorecon puts back the label the POLICY says a path should have. For a brand new folder the policy has no opinion, so restorecon puts back the wrong one. semanage fcontext writes a new rule into the policy; restorecon -R then applies it to every file inside.
Commands taught
semanage-fcontextLevel 55: A shop in /srv
Objective: The new shop in /srv/shop (httpd.conf already points there) gives 403: make it served for good, so it still works after a full relabel.
restorecon only restores what the policy calls the default. For /srv/shop the default is var_t, so restorecon "fixes" it to the wrong type. semanage fcontext -a -t TYPE '/srv/shop(/.*)?' teaches the policy a new default; restorecon -Rv then applies it.
Level 56: Ports have types too
Objective: List the ports httpd may open, add port 8082 to that type, and check it is there.
SELinux labels network ports too, and a service may only open ports whose type it is allowed to use. semanage port -l lists the types, semanage port -a adds a port to one.
Commands taught
semanage-portLevel 57: The door on 8081
Objective: The new site must answer on port 8081 (httpd.conf already says Listen 8081) but httpd will not start: get it running on 8081.
Ports have types too, and httpd_t may only bind ports of type http_port_t (80, 443, 8443 ...). After Listen 8081, httpd fails to start with "(13)Permission denied: make_sock". semanage port -a gives 8081 the http_port_t type.
Level 58: Policy switches (booleans)
Objective: An app cannot reach its Redis. Read the denial, find the switch, flip it, then save it.
The policy has on/off switches called booleans. audit2why reads a denial from the audit log and names the switch to flip, getsebool reads a switch, setsebool changes it. Without -P the change lasts until reboot; with -P it is saved.
Commands taught
seboolaudit2whyLevel 59: The proxy that could not call
Objective: /api is proxied to the inventory service on 127.0.0.1:3000 and answers 503: find why with audit2why and fix it for good (the check reboots).
Booleans are switches in the policy: httpd_can_network_connect lets httpd open outgoing connections (a reverse proxy to an API). setsebool -P flips one now AND for the next boot. audit2why reads an AVC and names the boolean.
Level 60: Night shift: read the log
Objective: Pager says "menu page broken": find the recent denial among the old noise and fix it properly before the morning rush.
The audit log is full of old denials from other days. ausearch -ts recent keeps only the last 10 minutes; sealert -a turns each denial into ranked advice. Fix what is broken NOW, the way the top suggestion says.
Commands taught
sealertLevel 61: The migration
Objective: Migration night: the site now lives in /web/bakery and the cut-over is in 8 minutes, so make it served, for good, still enforcing.
The site moved to a new disk mounted at /web, and new top-level paths get default_t, which httpd_t may neither read nor even walk through. A rule must cover the parent too.
Level 62: BOSS: The 3-fault outage
Objective: Bring the shop back on 8088 (httpd running, pages 200, /api 200 after a reboot): read the denials and fix each cause, never permissive.
After a "quick change" the shop is down three ways: httpd moved to port 8088 and will not start, the pages were rebuilt in a home directory and mv'd in, and /api cannot reach the inventory. SELinux must stay enforcing the whole time.
Commands taught
selinux-interview
World 6Hardening & Audit
15 levelsHarden a server to a checklist: loose files, services, kernel knobs, least-privilege sudo, PAM and auditd (SIM), logrotate, lynis, then the audit.
Level 63: Compare two lists
Objective: Find the two programs in ~/suid-new.txt that are not in ~/suid-old.txt, one grep switch at a time.
grep -f FILE reads its patterns from a file, one per line. With -v (match none), -x (whole lines) and -F (plain text, not a regex), grep tells you what is new in a list.
Level 64: Loose files
Objective: Close the world-writable files in /srv/app, give the orphaned files to root, and find + defuse the SUID program that is not in the baseline.
An audit starts with three find searches: world-writable files (-perm -0002), files owned by a deleted user (-nouser), and SUID programs compared against a baseline list.
Commands taught
perm-auditLevel 65: Password rules
Objective: Require 14 chars from 3 classes, lock after 5 failures for 15 minutes, unlock bob and make him change his password every 90 days.
On RHEL and Ubuntu, PAM reads /etc/security/pwquality.conf (how good a new password must be) and /etc/security/faillock.conf (lock after N failures). Alpine has no PAM: pwscore and faillock here are a SIM over those real files. chage is real.
Commands taught
pwqualityfaillockLevel 66: Rules that come back
Objective: List the live rules, write one rule file, load it with augenrules, and check that both sets agree.
[SIM] auditd has two rule sets: the live one (auditctl -l) and the files in /etc/audit/rules.d. augenrules --load makes the files the live set; augenrules --check only says whether they differ.
Level 67: Who touched passwd?
Objective: Watch /etc/passwd and /etc/shadow (key identity), make the rules survive a reboot, then catch a change in the trail.
auditd watches files: auditctl -w FILE -p wa -k KEY logs every write or attribute change with your key; ausearch -k KEY finds the events. Live rules die at reboot, rules in /etc/audit/rules.d come back. (auditd is a SIM here; the rules.d files are real.)
Commands taught
auditdLevel 68: The log that ate /var
Objective: Give /var/log/webapp/*.log a daily rotation (keep 7, compressed, quiet when missing or empty), dry-run it, then force one rotation.
logrotate renames a log to .1, compresses it, keeps N copies and starts a fresh one. Each app gets a block in /etc/logrotate.d/NAME; logrotate -d is a dry run, -f forces a rotation now.
Commands taught
logrotateLevel 69: Too many doors
Objective: Stop and disable telnetd, rpcbind and avahi-daemon while the shop app webapp keeps running.
Every running service is code waiting for input. On a shop server, telnet (cleartext logins), rpcbind (NFSv3, not used here) and avahi (mDNS) have no business running. disable --now stops them AND keeps them off after reboot.
Commands taught
disable-servicesLevel 70: Apply a sysctl file
Objective: Write a one-line sysctl file, apply it with sysctl -p, and tidy up.
A file in /etc/sysctl.d is a promise for the next boot. To apply it right now without rebooting: sysctl -p FILE reads the file and sets every key in it.
Level 71: Kernel knobs
Objective: In /etc/sysctl.d/60-net-harden.conf: net.ipv4.conf.all. accept_redirects = 0, send_redirects = 0, log_martians = 1, applied now.
Hardening guides set three network knobs on every server: accept ICMP redirects no, send them no, log martian packets yes. Live changes vanish at reboot; /etc/sysctl.d makes them stick (the check reboots to prove it).
Commands taught
sysctl-hardenLevel 72: Least privilege
Objective: Replace /etc/sudoers.d/lpro-deploy: deploy may only run /usr/bin/systemctl restart webapp as root, no password (visudo -cf the draft first).
The CI user deploy has "ALL=(ALL) NOPASSWD: ALL": a root shell for anyone who steals its key. It only ever needs to restart webapp.
Commands taught
sudoers-leastLevel 73: Start lynis, then stop it
Objective: Start a lynis audit in the background, see that it runs, then stop it.
lynis is a real security auditor and it is SLOW (minutes). So you never wait for it in the foreground: you start it in the background with & at the end of the line, keep working, and check on it with pgrep. Here you only learn the shape of the command, then stop it.
Commands taught
lynisLevel 74: The long scan
Objective: Run a full lynis audit in the background, wait for it, then save the hardening index to ~/index.txt and the test id of one warning to ~/warning.txt.
lynis is a real host audit: ~240 tests, a hardening index (0-100) and a list of warnings in /var/log/lynis-report.dat. Here it takes a few minutes, so you start it in the background with & and keep an eye on it with pgrep.
Level 75: Read a checklist
Objective: Run the checklist, ask what 1.1 wants, fix it, and run again. Then peek at the full list.
cis-check runs a checklist and prints [PASS] or [FAIL] for each control. --explain ID says what one control wants, --full adds the bigger controls. Run it, read it, fix one thing, run it again.
Commands taught
cis-checkLevel 76: The checklist
Objective: Run hidden, fix every FAIL (use --explain) and re-run it until the score is full.
cis-check turns a CIS-style checklist into [PASS]/[FAIL] lines, one command per control. --explain ID says what a control wants. The auditor arrives in eight minutes.
Level 77: BOSS: Pass the audit
Objective: Make hidden pass, then prove it after a reboot.
Final audit: cis-check --full, and the auditor re-runs it after a reboot. Live-only fixes do not count.
World 7Hypervisors
13 levelsMachines inside the machine: KVM, QEMU and libvirt with virsh for power, autostart, XML, qcow2 disks, snapshots, clones and networks (SIM).
Level 78: Machines in the machine
Objective: Meet this KVM host (SIM): ask virsh what runs here and find the VM that is switched off.
One host runs many virtual machines (VMs): type 1 hypervisors sit on bare metal (KVM, ESXi, Hyper-V), type 2 are desktop apps (VirtualBox). On Linux, KVM (kernel) lends the CPU, QEMU builds a fake PC per VM, and libvirt manages them, with virsh as its command line.
Commands taught
hypervisorsvirsh-simvirshLevel 79: The power buttons
Objective: Read web's ID card, power it on and off cleanly, then power on cache by yourself.
virsh dominfo NAME is the ID card of a VM (state, CPUs, memory, autostart). virsh start NAME powers it on. virsh shutdown NAME presses the power button once: the guest OS gets the request and shuts itself down cleanly.
Commands taught
virsh-powerhyper-distrosLevel 80: Pull the plug
Objective: db is frozen and blocks the backups: try the polite way, then pull the plug on db only, and bring it back.
shutdown only asks the guest, so a hung guest OS ignores it. virsh destroy NAME pulls the plug: QEMU stops at once, and despite the name nothing is deleted (the VM and its disk stay, start brings it back).
Commands taught
virsh-destroyLevel 81: Who wakes up after a reboot?
Objective: The host gets patched tonight: web and test must come back on their own after the reboot, cache must not.
When the host reboots, every VM stops. libvirt then starts only the VMs marked autostart (a link in /etc/libvirt/qemu/autostart/). virsh autostart NAME sets the mark, --disable takes it away, and hidden shows the marked ones.
Commands taught
virsh-autostartLevel 82: The blueprint
Objective: Read web's blueprint part by part, then write down where its disk lives.
libvirt keeps every VM as an XML blueprint. <domain type='kvm'> holds <name>, <memory> (most RAM, in KiB), <vcpu> (virtual CPUs) and <devices>: a <disk> whose <source file=...> is the image, and an <interface> whose <source network=...> is its network.
Commands taught
libvirt-xmlLevel 83: Change the blueprint
Objective: web needs 2 GiB of RAM, 2 CPUs, and its disk moved to /srv/vm: change the blueprint and load it.
To change a VM: save its XML to a file (hidden), edit the file, then hidden so libvirt stores the new config. Never edit /etc/libvirt/qemu/web.xml by hand: libvirt keeps its own copy. virsh edit web does the same three moves in an editor.
Commands taught
virsh-defineLevel 84: Disks made of files
Objective: In the image folder: make a new 2 GiB disk, read it, then build test overlays on top of the shared base image.
A VM disk is a file. qemu-img makes and inspects them. qcow2 is thin: a 2 GiB disk starts as a tiny file that grows as the guest writes. A qcow2 can also sit on a read-only backing file (-b): the new overlay stores only the changes, so many test VMs can share one base image.
Commands taught
qemu-imgLevel 85: The shelf and the boxes
Objective: A colleague made logs.qcow2 with qemu-img and libvirt cannot see it: find the pool, list it, refresh it.
libvirt groups disk images into storage pools: a pool is a place (here the folder /var/lib/libvirt/images), each image in it is a volume. libvirt keeps its own list of volumes, and a file added behind its back (qemu-img, cp) only shows up after virsh pool-refresh.
Commands taught
virsh-poolsLevel 86: A VM from a blueprint
Objective: Bring the mail VM to life from ~/mail.xml (its 10G qcow2 disk /var/lib/libvirt/images/mail.qcow2 is missing), running now and at every boot.
A new VM needs a blueprint (virsh define FILE) and a disk image (qemu-img create): define does not check the disk, start does. Autostart keeps it coming back after reboots.
Level 87: Snapshot before you patch
Objective: Patch web the safe way: snapshot, update, and when the update breaks the boot, revert and bring web back.
virsh snapshot-create-as VM NAME saves the VM as it is now (inside its qcow2 disk). snapshot-list shows the saved points, snapshot-revert VM NAME goes back to one. "Snapshot before you patch" is a rule in every ops team.
Commands taught
virsh-snapshotsvirt-customizeLevel 88: Two of a kind
Objective: The sale starts tomorrow: clone web into web2 and run both.
virt-clone copies a whole VM: the disk is copied and the config gets a new name, a new UUID and a new MAC address, so the copy can run next to the original. The original must be off while it is copied.
Commands taught
virt-cloneLevel 89: Wires that are not there
Objective: The new app VM plugs into the network lan: find out why it will not start, fix it now and for every boot.
VMs plug into libvirt virtual networks: default is NAT, VMs get 192.168.122.x addresses and reach out through the host (bridge virbr0) like phones behind a home router. A network is active and autostarted or not, like a VM, and a VM cannot start while its network is down.
Commands taught
virsh-networksLevel 90: BOSS: The morning after
Objective: Get web running again (db stays up), then make sure it comes back by itself after the next reboot.
After the host reboot web stayed off although it is marked autostart, because a start that fails at boot fails the same way by hand. virsh start prints why, one cause at a time: fix it and retry until it runs, keeping db up the whole time.
Commands taught
hyper-interview
World 8Rescue Night (real VM)
6 levelsA real Rocky Linux 9 server on a serial console: catch the real GRUB menu, fix rescue and emergency boots, survive real reboots.
Level 91: First light
Objective: Boot the box ONCE with the extra kernel argument pv.hello=1, added at the GRUB menu. The menu waits 90 seconds this time.
This terminal is the serial console of a real Rocky Linux 9 server. When it boots, the real GRUB menu waits a few seconds: e edits the highlighted entry, Ctrl-E jumps to the end of a line, Ctrl-X boots your edit. An edit at the menu lasts one boot only.
Commands taught
grub-serialLevel 92: The quiet room
Objective: The box hangs at boot. Get in through rescue mode (root password Lab-Root-1) and stop pv-hang from starting at boot. Keep its unit file.
A unit that never finishes can hold the boot back forever. Rescue mode (systemd.unit=rescue.target on the kernel line) starts only the basics and gives you a root shell. There, systemctl disable keeps a unit from starting at the next boot.
Level 93: The wrong default
Objective: The default target is rescue. Make the box boot to multi-user.target for good. Root password: Lab-Root-1. CHECK reboots it.
hidden shows the target a box boots to. set-default changes it for every boot. isolate and hidden only switch the running box: the next boot forgets.
Commands taught
isolate-vs-defaultLevel 94: The missing disk
Objective: The backup disk is gone: the box stops in emergency mode. Boot clean and KEEP the /backup line. Root password: Lab-Root-1.
An fstab line for a disk that is not there makes systemd wait 90 seconds, then stop in emergency mode with / read-only. nofail in the options column lets the box boot without that disk. Fix it, reboot from the console, then press CHECK.
Level 95: Two faults, one boot
Objective: Pressure: a mount option typo AND a wrong default target. Boot clean to multi-user.target with /boot mounted. Root password: Lab-Root-2.
Real outages rarely have one cause. Fix one fault and reboot, and the second one stops you again. Read every red line before you reboot.
Level 96: BOSS: The Citadel won't boot
Objective: Bring the Citadel back: a clean multi-user boot, SELinux enforcing, all three faults fixed for good. Root password: Pager-Duty-42.
Three faults on one real box: a unit that hangs the boot, an fstab line for a missing disk, and a systemd.unit=rescue.target argument saved in the boot entry with grubby. A one-shot GRUB edit gets you in, but only fixes on disk survive the reboot.
World 9Locked Out (real VM)
4 levelsNobody knows root on a real Rocky Linux 9 server. Get in with rd.break, the RHEL 9 way and init=/bin/bash, then lock the door behind you.
Level 97: The classic
Objective: Set root's password to Rescue-2026 with rd.break, then log in as root on the console. The GRUB menu waits 90 seconds.
rd.break stops the boot inside the initramfs, with the real disk read-only at /sysroot. Remount it, chroot into it, change the password, and leave a note for SELinux: hidden. You did this on the simulator; now the disk, the kernel and SELinux are real.
Commands taught
load-policyLevel 98: The fast way
Objective: Set root's password to Night-Shift-7 the fast way: rd.break enforcing=0, no relabel, then hidden and hidden.
The RHEL 9 docs skip the full relabel: boot with rd.break enforcing=0, change the password, boot on permissive (this boot only), then label the one file that changed: hidden, and hidden.
Commands taught
grub2-setpasswordLevel 99: PID 1 is you
Objective: Set root's password to Pid-One-9 with init=/bin/bash (not rd.break), keep SELinux happy, and boot on to a login.
init=/bin/bash makes a shell the very first process (PID 1). No initramfs stop, no systemd, no SELinux policy loaded. Root is mounted read-only. Exit that shell and the kernel panics.
Level 100: BOSS: Lock the door behind you
Objective: Root's password is Rescue-2026. Log in as root, lock GRUB editing with grub2-setpassword, and give student passwordless sudo back (0440, valid).
Getting in is half the job. Lock the GRUB editor with a password, so the next stranger at the console cannot do rd.break. Then give student its sudo back with a clean drop-in file.
World 10SELinux for Real (real VM)
7 levelsThe Seal Room with real seals: a real Rocky 9 server, real httpd, real denials. Fix labels, ports and booleans for good, SELinux always on.
Level 101: Enforce for good
Objective: This real box runs permissive, live AND in /etc/selinux/config. Make it enforcing now and at the next boot. No reboot needed: CHECK reads both.
SELinux has two switches: the live mode (setenforce, lost at reboot) and /etc/selinux/config (read at every boot). sestatus shows both: Current mode and Mode from config file.
Level 102: Moved, not copied
Objective: /var/www/html/sale.html answers 403 Forbidden. Fix its label: no chmod tricks, no permissive, no booleans.
mv keeps a file's SELinux label. A page made in /root and moved to the docroot still wears admin_home_t, and httpd answers 403. matchpathcon shows the label the rules want; restorecon puts it back.
Level 103: A shop in /srv, for good
Objective: /srv/shop is the docroot now (already set in httpd) and answers 403. Make it served for good: it must survive a full relabel.
/srv has no web rule, so files there are var_t and httpd gets 403. chcon would work until the next relabel. semanage fcontext writes a rule, restorecon applies it, and restorecon -n (dry run) proves a full relabel would change nothing.
Commands taught
semanage-realLevel 104: The door on 8081
Objective: httpd must also answer on 8081 (Listen 8081 is set) but will not start. Get it running and keep it running: CHECK reboots the box.
httpd_t may only bind ports labelled http_port_t. After Listen 8081 the real httpd fails with "Permission denied: make_sock". 8081 already has a type (transproxy_port_t), so semanage port -m (not -a) gives it http_port_t, saved for every reboot.
Level 105: The proxy that could not call
Objective: /api (a reverse proxy to 127.0.0.1:3000) answers 503. The API itself is up. Find why with ausearch and audit2why, and fix it for good: CHECK reboots the box.
httpd_t may not open outgoing connections unless the boolean httpd_can_network_connect is on. On a real box the denial is in /var/log/audit/audit.log: ausearch finds it, audit2why names the switch, setsebool -P saves it.
Level 106: Uploads, and only uploads
Objective: Pressure: the upload script /cgi-bin/up.cgi fails. Read the recent denial and give ONLY /var/www/uploads the read-write type, for good.
A CGI script may read web content but not write it. The directory it writes to needs httpd_sys_rw_content_t, with a rule so a relabel keeps it. Not the boolean httpd_unified: that opens all of httpd's files for writing.
Commands taught
httpd-rw-contentLevel 107: BOSS: The three-seal outage
Objective: Bring the web server back: httpd on 80 and 8088, every page 200, /api 200, all fixes saved (CHECK reboots). Never permissive.
Three seals broke at once: the shop must listen on 8088 (httpd will not start), the pages were moved in from a home folder, and the /api proxy may not call out. Each has a precise fix. None of them is hidden.
World 11Hypervisors for Real (real VM)
4 levelsA real Rocky 9 host running real libvirt and QEMU: start, console, define, snapshot and revert tiny VMs, then rescue a host after a reboot.
Level 108: A real hypervisor
Objective: Check what this host can do, then boot the tiny guest and watch it on its console.
This Rocky VM runs real libvirt and QEMU, and inside it a tiny real guest (CirrOS). virt-host-validate says whether KVM works here (nested) or QEMU must emulate the CPU (TCG). virsh console attaches to the guest's serial line; Ctrl+] leaves.
Commands taught
virt-host-validateLevel 109: Born from XML
Objective: Turn ~/lab.xml into a running VM that also starts at every boot.
~/lab.xml is a complete domain XML: name, memory, disk, network. virsh define loads it into libvirt for good, start boots it, autostart brings it back after every host boot. The disk is a qcow2 overlay on the CirrOS base.
Level 110: A real time machine
Objective: Snapshot tiny, make a bad change to its config, then revert it.
A snapshot of a shut off VM with a qcow2 disk is stored inside the disk, with a copy of the VM config. snapshot-revert puts both back: disk and XML.
Level 111: BOSS: The real morning after
Objective: Get web running (128 MiB, its real disk, network pvnet), and make sure web and pvnet both come back by themselves after the next boot.
The host rebooted. web is marked autostart but stayed off: libvirt tried and failed. hidden prints why, one cause at a time. web needs 128 MiB and its disk is now pv-web-2025.qcow2 in the same folder.
Final examThe Pro Exam
20 levelsTwenty tickets on one server, two hours and no hints, and every fix must survive the reboot at the end.
Level 112: Ticket 1: Locked out of rhel10
Objective: Reset the root password of rhel10 to Exam-Root-26, log in, then quit the console.
rhel10 (console) waits at its GRUB menu and nobody knows its root password.
Level 113: Ticket 2: Reboot after a panic
Objective: Make this VM reboot itself 10 seconds after a kernel panic, now and after every reboot.
A panicked kernel waits forever by default (kernel.panic = 0).
Level 114: Ticket 3: The archive disk
Objective: Get the ARCHIVE disk mounted on /srv/larchive at every boot, and make sure a missing disk can never stop the boot.
The archive disk (filesystem label ARCHIVE) was reformatted, and its fstab line still names the old UUID.
Level 115: Ticket 4: Lock the front door
Objective: Harden sshd: no root logins, no passwords, only the user server may log in, sshd -t clean, and your key login to server@server still works.
sshd reads sshd_config.d/*.conf in name order and the first value of each keyword wins.
Level 116: Ticket 5: Office time
Objective: Make chronyd sync from the office time server 127.0.0.2 (^* in hidden) and start at every boot.
The office time server answers on 127.0.0.2; this box still asks the internet pool, which the lab cannot reach.
Level 117: Ticket 6: The file server name
Objective: dig @127.0.0.1 files.office.lan must answer 10.20.0.15 and nothing else, and ntp.office.lan 127.0.0.2, also after a reboot.
The office DNS is dnsmasq on 127.0.0.1. It also answers from /etc/hosts.
Level 118: Ticket 7: Share the handbook (SIM)
Objective: Export /srv/share read-only to 10.20.0.0/24 and to nobody else, saved in /etc/exports and applied.
NFS exports live in /etc/exports; exportfs -ra loads them (this VM has no NFS server: exportfs is a SIM).
Level 119: Ticket 8: The shop shows the intranet
Objective: http://shop.office.lan/ must show the Office Shop (/var/www/shop) and http://localhost/ the intranet, also after a reboot.
nginx picks the server block by the Host name; a name nobody claims lands on the default_server.
Level 120: Ticket 9: Both cooks
Objective: Make app.office.lan send its requests to app1 AND app2 in turn, through an upstream block.
app.office.lan is proxied by nginx; the app runs twice, on 127.0.0.1:8081 (app1) and 127.0.0.1:8082 (app2).
Level 121: Ticket 10: The dead third server
Objective: Every request to 127.0.0.1:8080 must succeed: keep app3 in the config, let HAProxy skip it while it is down, and run HAProxy at boot.
HAProxy on 127.0.0.1:8080 balances app1, app2 and app3; app3 (127.0.0.1:8083) is down for a rebuild.
Level 122: Ticket 11: Save the wall
Objective: Make the live firewall load again at every boot from /etc/nftables.nft, without doubling rules when it is loaded twice.
The live nftables wall (table inet fw: policy drop, lo, replies, 22 and 80) exists only in memory.
Level 123: Ticket 12: The bouncer sleeps
Objective: Make SELinux enforcing right now and at every boot.
SELinux (SIM) on this box is permissive, live and in /etc/selinux/config.
Level 124: Ticket 13: 403 on port 81
Objective: Make http://localhost:81/ serve the shop with SELinux labels that survive a full relabel.
httpd (SIM) on port 81 serves /srv/shop and answers 403; the file permissions are fine.
Level 125: Ticket 14: /api says 503
Objective: Make http://localhost:81/api answer 200 for good, with SELinux enforcing.
httpd (SIM) proxies /api to the inventory service on 127.0.0.1:3000; the audit log knows why it fails.
Level 126: Ticket 15: Password policy
Objective: Require passwords of 14 characters from 3 classes, and lock an account for 15 minutes after 5 failures.
pam_pwquality reads /etc/security/pwquality.conf, pam_faillock reads /etc/security/faillock.conf.
Level 127: Ticket 16: Who touched sudoers?
Objective: Audit every write and attribute change to /etc/sudoers under the key actions, live now and at every boot.
auditd (SIM) watches files with -w PATH -p PERMS -k KEY; rules.d/*.rules is what survives a reboot.
Level 128: Ticket 17: Least privilege
Objective: Let deploy run only /usr/bin/systemctl restart webapp as root without a password, and keep sudoers valid (mode 0440).
/etc/sudoers.d/lpro-deploy gives the deploy user ALL commands as root.
Level 129: Ticket 18: Too many doors
Objective: Stop telnetd and rpcbind now and for every boot, while webapp keeps running.
telnetd and rpcbind run on this box; webapp is the shop and must stay up.
Level 130: Ticket 19: Kernel network knobs
Objective: In /etc/sysctl.d/60-net-harden.conf set net.ipv4.conf.all accept_redirects = 0, send_redirects = 0 and log_martians = 1, applied now.
The auditor wants ICMP redirects ignored and not sent, and martian packets logged.
Level 131: Ticket 20: Loose files
Objective: Leave no world-writable file and no ownerless file under /srv/app (give them to root), and no SUID file under /usr/local.
The audit found world-writable files and files with no owner under /srv/app, and one SUID program that is not in the baseline.
For teachers
Use these levels with a class
SOLUTION HIDDEN Teachers see answer keys in the classroom.