
Learn Linux basic command with this game.
| Level | Goal | Useful Commands |
|---|---|---|
| 1. Ground Zero | Find where you are and read the first hint | pwd, ls, cat |
| 2. The Dark Cellar | Navigate down into a folder and find a hidden file | cd, ls -a |
| 3. Path Traversal | Go back up the tree and into a nested path | cd |
| 4. Handling Spaces | Open a file that contains spaces in its name | cat |
| 5. Finding the Needle | Locate the secret flag inside a cluttered file | grep or cat / less |
Save this script as setup_hunt.sh on the target machine (or student lab VM/container), make it executable with chmod +x setup_hunt.sh, and run ./setup_hunt.sh.
Or copy the code and save as setup_hunt.sh
#!/usr/bin/env bash
set -e
BASE_DIR="treasure_hunt"
rm -rf "$BASE_DIR"
mkdir -p "$BASE_DIR"/{cellar,attic/storage,archives,vault}
# Level 1: Starting point
cat << 'EOF' > "$BASE_DIR/clue1.txt"
=== LEVEL 1: WHERE AM I? ===
Welcome, Explorer!
Rule 1: Always check where you are using 'pwd'.
Rule 2: Inspect your surroundings with 'ls'.
Your next clue has been hidden underground.
Enter the 'cellar' directory and see what lies in the dark.
EOF
# Level 2: Hidden dotfile in cellar
cat << 'EOF' > "$BASE_DIR/cellar/.hidden_note.txt"
=== LEVEL 2: UNSEEN PATHS ===
Great job using 'ls -a'! Dotfiles (.filename) are hidden by default in Linux.
Now, travel up and over:
Leave this room (using 'cd ..') and navigate all the way to:
attic/storage/
There you will find a physical relic left behind.
EOF
# Level 3 & 4: File with spaces in attic/storage
cat << 'EOF' > "$BASE_DIR/attic/storage/ancient scroll.txt"
=== LEVEL 3 & 4: SPACES AND STRINGS ===
Well done! File names with spaces require wrapping in "quotes"
or escaping with a backslash (\ ). Tab completion also auto-fills this!
Your next destination:
Head to the 'vault' directory at the root of the hunt.
Inside, inspect 'security_log.txt' to extract the secret passkey.
EOF
# Level 5: Cluttered log file in vault
LOG_FILE="$BASE_DIR/vault/security_log.txt"
for i in {100..160}; do
echo "2026-10-15 08:$((i % 60)):02 SYSTEM_STATUS_OK: Sector $i verified." >> "$LOG_FILE"
done
echo "2026-10-15 08:34:12 CRITICAL_ALERT: FLAG{TUX_MASTER_NAVIGATOR_2026} decrypted." >> "$LOG_FILE"
for i in {161..220}; do
echo "2026-10-15 08:$((i % 60)):45 SYSTEM_STATUS_OK: Sector $i verified." >> "$LOG_FILE"
done
# Decoy files for realism
touch "$BASE_DIR/archives/old_records.csv"
touch "$BASE_DIR/archives/manifest.txt"
touch "$BASE_DIR/attic/cobweb.txt"
echo "Treasure hunt initialized in ./$BASE_DIR"
echo "Direct students to run: cd $BASE_DIR && cat clue1.txt"
Main category
