██ Linux Foundations S6 Session: S6 Is Your Site Actually Working? Today you will: • follow a web request; • investigate your own site; • write a checker that makes decisions. 1 / 31 ██ Network Warm-Up: Ping ICMP (Internet Control Message Protocol) carries diagnostics. Ping asks for echo replies. ping -c 3 1.1.1.1
• -c 3: three requests to a public address.
• Read packet loss and average time in milliseconds. 2 / 31 ██ Quick Demo: Traceroute Send probes one hop farther each time: traceroute -m 8 1.1.1.1
-m 8: up to eight hops toward this public address.
*: no reply, not proof of a broken route. Ctrl-C cancels.
3 / 31 ██ Start On The Classroom Server Open your classroom SSH session and load the objective: guide now
For S6, take the provided report script: mkdir -p ~/scripts
cp -i /docs/guides/resources/maker-report.sh ~/scripts/
chmod u+x ~/scripts/maker-report.sh
Your committed version stays in ~/src. cp -i asks before overwriting.
4 / 31 ██ What Happens When You Open A Page? web address -> find an IP address -> connect -> request a page ->
response
• IP (Internet Protocol) address: where to connect. • Port: which service. Which step could fail? 5 / 31 ██ DNS: Find The Address DNS (Domain Name System): look up a name's addresses. $ host lf2607.kolamayermakers.org
lf2607.kolamayermakers.org has address 213.163.207.98
lf2607.kolamayermakers.org has IPv6 address
2a04:3543:1000:2310:2cdf:9ff:fe55:6e95
6 / 31 ██ HTTP: Ask For A Page HTTP (Hypertext Transfer Protocol): a request and a response. request: GET /~learner/maker-report.html
response: status 200, content-type text/html, HTML body
HTTPS adds TLS (Transport Layer Security): encryption and server verification. The browser renders HTML. Curl shows the response. 7 / 31 ██ HTTP Status Codes Family │ Meaning │ Examples ───────┼───────────────────────────────┼──────────────────────────────────── 2xx │ Success │ 200 OK
3xx │ Redirection or further action │ 301, 302, 308: read Location
4xx │ Request cannot be fulfilled │ 403 forbidden; 404 not found
5xx │ Server failure │ 500 internal error; 502 bad gateway
8 / 31 ██ Look At Headers First -I sends HEAD: headers, no body.
Example headers (excerpt): $ curl -I "https://lf2607.kolamayermakers.org/~$USER/"
HTTP/2 200
content-type: text/html; charset=utf-8
server: Caddy
content-length: 5019
$ curl -I
"https://lf2607.kolamayermakers.org/~$USER/maker-report.html"
HTTP/2 200
content-type: text/html; charset=utf-8
server: Caddy
content-length: 2683
Both return 200. content-length describes the body size in bytes.
9 / 31 ██ Get The Actual Page Without -I: GET the body.
$ curl
"https://lf2607.kolamayermakers.org/~$USER/maker-report.html"
Example body (excerpt): <h1 id="foo-bar">foo bar</h1>
...
<li>Hostname: lf2607</li>
...
<h2 id="shell-fields-in-etcpasswd">Shell fields in /etc/passwd</h2>
Find your report title in the HTML. Try -i: headers and body. Different from -I.
10 / 31 ██ Make A Safe 404 Request an unpublished path, without deleting any files: $ curl -I
"https://lf2607.kolamayermakers.org/~$USER/not-a-page.html"
HTTP/2 404
server: Caddy
Response excerpt: the server replied, but the path is missing. Remove -I. Does the error have a body?
11 / 31 ██ Follow A Redirect -L follows the URL in Location.
$ curl -I "http://lf2607.kolamayermakers.org/~$USER/"
HTTP/1.1 308 Permanent Redirect
Location: https://lf2607.kolamayermakers.org/~$USER/
$ curl -L -I "http://lf2607.kolamayermakers.org/~$USER/"
HTTP/1.1 308 Permanent Redirect
Location: https://lf2607.kolamayermakers.org/~$USER/
HTTP/2 200
content-type: text/html; charset=utf-8
Example excerpts use $USER in place of the returned username.
Our lesson example checks for 200 without following redirects.
12 / 31 ██ Build The Checker mkdir -p ~/scripts
cd ~/scripts
micro site-check.sh
Start with one page: #!/bin/bash
set -euo pipefail
base_url="https://lf2607.kolamayermakers.org/~$USER"
page="$1"
url="$base_url/$page"
curl -I "$url"
$1 is the first argument. Save, then run bash site-check.sh maker-report.html.
13 / 31 ██ Ask Curl For Just The Code Replace curl -I "$url" with:
curl -sS -I --max-time 10 -o /dev/null -w '%{http_code}\n' "$url"
• -sS: hide progress, keep errors.
• --max-time 10: ten-second limit.
• -o /dev/null: discard the headers.
• -w: print the status code.
14 / 31 ██ Store The Answer Capture it: status=$(curl -sS -I --max-time 10 -o /dev/null -w '%{http_code}'
"$url")
printf 'status=<%s>\n' "$status"
$() captures stdout. Stderr stays visible.
What is stored in status?
15 / 31 ██ Let The Script Decide Replace the status printf with:
if [[ "$status" == "200" ]]; then
printf 'OK: %s returned HTTP 200\n' "$url"
else
printf 'CHECK: %s returned HTTP %s\n' "$url" "$status"
fi
• [[ ... ]] tests a condition; keep spaces inside.
• == compares text.
• then / else: two branches. fi: end.
16 / 31 ██ Your Script So Far Save this in ~/scripts/site-check.sh:
#!/bin/bash
set -euo pipefail
base_url="https://lf2607.kolamayermakers.org/~$USER"
page="$1"
url="$base_url/$page"
status=$(curl -sS -I --max-time 10 -o /dev/null -w '%{http_code}'
"$url")
if [[ "$status" == "200" ]]; then
printf 'OK: %s returned HTTP 200\n' "$url"
else
printf 'CHECK: %s returned HTTP %s\n' "$url" "$status"
fi
Run bash ~/scripts/site-check.sh maker-report.html.
17 / 31 ██ Exercise: Make Both Branches Run Same script, different arguments. Predict each result: bash ~/scripts/site-check.sh maker-report.html
bash ~/scripts/site-check.sh not-a-page.html
200 selects OK; 404 selects CHECK. No script edits needed.
Trace the missing-page check with bash -x ~/scripts/site-check.sh not-a-page.html.
18 / 31 ██ Check Every Page In One Loop Extend $1 (the first argument) to "$@" (all arguments). The loop makes page from
each supplied argument: for page in "$@"; do
url="$base_url/$page"
printf 'Checking %s\n' "$url"
done
Put this in your script below base_url, replacing the one-page body. Run bash
~/scripts/site-check.sh "" maker-report.html: "" is a real argument that selects the
homepage; any other supplied path is accepted too. Replace the printf with your curl capture and your if decision, inside the loop.
page comes from the loop now, not $1.
19 / 31 ██ No Arguments: Print Usage Add this after set -euo pipefail, before building URLs:
if [[ "$#" -eq 0 ]]; then
printf 'Usage: site-check.sh PAGE [PAGE ...] (use "" for
homepage)\n' >&2
exit 2
fi
$# counts arguments. Zero prints help and exits 2; one empty argument checks the
homepage. 20 / 31 ██ The Complete Checker Keep the usage guard above base_url; the body is now:
base_url="https://lf2607.kolamayermakers.org/~$USER"
for page in "$@"; do
url="$base_url/$page"
status=$(curl -sS -I --max-time 10 -o /dev/null -w '%{http_code}' "$url")
if [[ "$status" == "200" ]]; then
printf 'OK: %s returned HTTP 200\n' "$url"
else
printf 'CHECK: %s returned HTTP %s\n' "$url" "$status"
fi
done
Run bash ~/scripts/site-check.sh "" maker-report.html. Reverse the arguments or
supply just one page; the loop visits the supplied paths. 21 / 31 ██ Give A Useful Repair Hint Before the existing else, add:
elif [[ "$page" == "maker-report.html" && "$status" == "404" ]];
then
printf 'MISSING: maker-report.html returned HTTP 404\n'
printf 'Run ~/scripts/maker-report.sh "S5 Report", then
build-website.\n'
elif: another test. &&: both conditions must be true.
Inside the final else, also add:
printf 'Inspect headers with: curl -I %s\n' "$url"
22 / 31 ██ HTTP Status vs Exit Code HTTP status: the server's response. Exit code: did curl succeed? curl -I "https://lf2607.kolamayermakers.org/~$USER/not-a-page.html"
printf 'curl exit code: %s\n' "$?"
• HTTP 404, curl exit code 0: a response arrived.
• Nonzero exit code: curl failed. With -w '%{http_code}', curl prints 000 when no HTTP response code was received. It
is not an HTTP status or an exit code. 23 / 31 ██ If Can Test A Command Too Try a name that should not resolve: if curl -I --max-time 3 https://s6-network-test.invalid; then
printf 'A response arrived. Read its status.\n'
else
printf 'The request failed. Read the curl error.\n'
fi
Exit code 0 selects then; nonzero selects else. Which branch ran?
24 / 31 ██ Handle A Failed Request Replace the capture and decision inside the loop: curl_exit_code=0
status=$(curl -sS -I --max-time 10 -o /dev/null -w '%{http_code}'
"$url") \
|| curl_exit_code=$?
if [[ "$curl_exit_code" -eq 0 ]]; then
if [[ "$status" == "200" ]]; then
printf 'OK: %s returned HTTP 200\n' "$url"
elif [[ "$page" == "maker-report.html" && "$status" == "404" ]];
then
printf 'MISSING: maker-report.html returned HTTP 404\n'
printf 'Run ~/scripts/maker-report.sh "S5 Report", then
build-website.\n'
else
printf 'CHECK: %s returned HTTP %s\n' "$url" "$status"
printf 'Inspect headers with: curl -I %s\n' "$url"
fi
else
printf 'CONNECTION FAILED: %s\n' "$url"
printf 'Read the curl error: check name, connection, or
certificate.\n'
fi
|| captures failure without stopping under set -e. -eq compares numbers.
25 / 31 ██ Exercise: Predict The Message Without editing the script, predict the message for each case: Page │ Curl exit code │ HTTP status ─────────┼────────────────┼─────────────────────────────── Homepage │ 0 │ 404
Report │ 0 │ 404
Either │ 0 │ 302 or 500
Either │ 6 │ No response
Report │ 28 │ 200 printed before curl failed
Then check your real pages: bash -n ~/scripts/site-check.sh
bash ~/scripts/site-check.sh "" maker-report.html
bash ~/scripts/site-check.sh not-a-page.html
26 / 31 ██ Check With Guide guide now or guide check runs your script locally as your learner account, varying
page arguments and order. It tells you the next case to fix; the cases are the ones from the exercise above. 27 / 31 ██ Exit Goal Explain to your neighbour: • What do DNS, ping, and HTTP each tell you? • Why can HTTP 404 give curl exit code 0?
• What does each if decide?
• Can the homepage return 200 while the report returns 404? Why?
28 / 31 ██ Between-Session Practice Practice DNS, ping, HTTP headers, and the checker with the S6 quests. Use guide now to find your next task and keep progressing at your own pace.
Keep site-check.sh. Optional: preserve it in Git.
29 / 31 ██ Next Session: Your Page On The Wire S7: 2026-09-19 • Compare generated HTML with fetched HTML. • Add and link another page. • Inspect raw HTTP and the separate service route. Same site, a closer look. 30 / 31 ██ Optional: Repeat While A Condition Holds while repeats while its test succeeds:
remaining=3
while [[ "$remaining" -gt 0 ]]; do
printf '%s\n' "$remaining"
remaining=$((remaining - 1))
done
-gt compares numbers. $((...)) calculates a new value.
When does it stop? Without the update, it loops forever. Ctrl-C cancels.
31 / 31