Linux course index · Linux Advanced 2 category · Lesson 7 of 7
AI disclosure — AI-generated content, posted as is. AI can make mistakes. This extension adds new material and links related posts from this site. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.
Learning goal
Demonstrate Linux service deployment, evidence-led incident diagnosis, and recovery in one lab.
Concepts and setup
Use a disposable VM with Bash, curl, tar, and Python 3. Everything in this capstone starts in a temporary lab directory and binds only to loopback. Keep the same shell for the whole exercise. The site’s boot, Apache, networking, and archive posts inform the checklist. The Python web server is for a local lab, not a production HTTP service.
The service is healthy only when the expected content is served, not merely when a PID exists. Save a baseline, introduce one known file fault, collect evidence before changing anything else, and prove the service returns to its original response.
Build the baseline and archive the fixture
lab=$(mktemp -d)
mkdir "$lab/site"
printf 'course-check=ready\n' > "$lab/site/index.html"
tar -czf "$lab/site.tgz" -C "$lab/site" index.html
port=8089
# Make sure this local port is free before starting.
ss -ltn "sport = :$port"
python3 -m http.server "$port" --bind 127.0.0.1 --directory "$lab/site" \
> "$lab/server.log" 2>&1 &
pid=$!
# Wait for the server to start before the next check.
curl -fsS "http://127.0.0.1:$port/index.html"
ps -p "$pid" -o comm=
Possible output
State Recv-Q Send-Q Local Address:Port Peer Address:Port
course-check=ready
python3
If another process already listens on 8089, choose another unused unprivileged port. Stop if the baseline response does not match your fixture.
Create one controlled fault and restore
mv "$lab/site/index.html" "$lab/index.saved"
curl -sS -o /dev/null -w 'HTTP %{http_code}\n' "http://127.0.0.1:$port/index.html"
tail -n 3 "$lab/server.log"
tar -tzf "$lab/site.tgz"
tar -xzf "$lab/site.tgz" -C "$lab/site" index.html
cmp "$lab/index.saved" "$lab/site/index.html"
curl -fsS "http://127.0.0.1:$port/index.html"
kill -TERM "$pid"
wait "$pid" 2>/dev/null || true
Possible output
HTTP 404
... code 404, message File not found
... "GET /index.html HTTP/1.1" 404 -
index.html
course-check=ready
Only signal the child started by this shell in the first block. This fault leaves the listener intact. A restart is not necessary because the file, not the process, was broken.
What to submit and how it is graded
Submit a short runbook and a table with baseline, fault, and restored state. Include the command, timestamp, and relevant output for each observation. Do not submit secrets or host identifiers. Score out of 20. Award 5 for a reproducible baseline, 5 for using logs and checks to isolate the fault, 5 for restoring and verifying content, and 5 for a credible improvement with an acceptance test.
Questions only
Quick-check questions
- What did the HTTP 404 establish about the network and service path?
- Why keep pre-repair evidence?
Assessment questions
- Write a short incident narrative with symptom, cause, evidence, repair, and verification.
- What observations would change if the process itself had exited?
- Propose one security or recovery improvement and a test to prove it works.
Questions and answers
Quick-check answers
- What did the HTTP 404 establish about the network and service path?
Answer — The client reached an HTTP listener and received a valid response, but the named resource was unavailable. - Why keep pre-repair evidence?
Answer — It lets you separate cause from coincidence and verify that repairs changed the expected symptom.
Assessment answer key
- Write a short incident narrative with symptom, cause, evidence, repair, and verification.
Answer — Example: the baseline served the marker, moving index.html produced 404 with matching logs, the archive restored that exact member, cmp matched, and curl returned the original marker. - What observations would change if the process itself had exited?
Answer — The listener should disappear and curl could fail to connect rather than receiving a valid status. Verify process and binding separately. - Propose one security or recovery improvement and a test to prove it works.
Answer — For example, put the fixture under a restricted service identity and show it still serves the intended page, but cannot read data outside the allowed directory.
Related source articles on this site
- Q & A: Linux: Switch Users, Boot Process, File System
- Basic Commands for Networking in Linux
- On Thursday and Friday tar all contents of /etc folder into /export/home/shell/test/etc.tar .. do misc logs #Linux/Unix: Shell Programming – 001
- Using Let’s Encrypt With Apache2 (HTTPS Setup)
- Linux: Disk Space, Memory Space, Running Processes
- ইউনিক্সঃ সিস্টেম লগিং (Unix – System Logging)
Continue the course
Previous lesson 06 — Encrypted Backups and Restore Drills. This is the last lesson in this level. See the course index for the next level.
Linux course index · Linux Advanced 2 category · Lesson 7 of 7
