Linux Administration Course — Start Here and Lesson Index

Learn Linux from your first terminal session through server administration and recovery. The 33 numbered lessons use examples and topics from the Open Education archive, with new labs where the older examples need updating or the topic is missing.

AI disclosure — AI-generated content, posted as is. AI can make mistakes. The lessons link to original Open Education articles and identify related background for new topics. The newly written explanations and lab examples may be freely reused. Linked source material retains its own terms.

How to work through the course

  1. Start with Basics 01 if you are new to the shell. If you already know navigation, permissions, and pipes, try the Basics assessments before moving on.
  2. Run the worked example and compare your results to the possible output. Paths, versions, process IDs, timestamps, and log formatting may differ.
  3. Answer the questions-only section before reading the repeated questions with answers. Keep short notes on the test, evidence, and outcome of each lab.
  4. Use disposable virtual machines and snapshots for administration exercises. Keep DNS, DHCP, and other service labs on the specified isolated segment rather than your normal network.
  5. Suggested pacing is two or three lessons per week, with extra lab time for networking, storage, and the capstone.

Linux Basics — 8 lessons

Start with the terminal and end by recovering a file from an archive. No administrator privileges are needed for the Basics exercises. Browse the category.

  1. Linux, the Shell, and Your First Lab — Tell the kernel, distribution, terminal, and shell apart, then identify the system you are actually using.
  2. Paths, Files, and Links — Navigate confidently, copy and rename a file, and explain the difference between hard links and symbolic links.
  3. Editing Text and Reading Files — Edit a text file in a terminal and verify the exact lines you saved.
  4. Pipes, Redirection, and Exit Status — Route input, normal output, and errors, then detect a command failure inside a pipeline.
  5. Finding Files and Filtering Text — Choose find for names, grep for lines, cut for fields, and sed for transforming text.
  6. File Permissions and umask — Read a permission string, predict umask results, and choose a minimal permission change.
  7. Processes, Jobs, and Signals — Identify a process you own, inspect its state, and stop it gracefully.
  8. Archives, Compression, and a Restore Test — Create and inspect an archive, then prove that you can recover a file from it.

Linux Intermediate — 9 lessons

Write and debug Bash, manage access without broad permissions, and diagnose services, networks, remote access, and mounted storage. Browse the category.

  1. Users, Groups, sudo, and Special Permissions — Inspect identity records, understand sudo, and build a group-inheriting directory in a disposable VM.
  2. Access Control Lists and Shared Directories — Grant and remove a narrowly scoped named-user ACL and distinguish a grant from effective access.
  3. Bash Variables, Quoting, and Input — Write Bash variables, capture a command result, and accept input without losing spaces or misinterpreting nonnumeric input.
  4. Bash Conditions, Loops, Functions, and Debugging — Use a case statement, a function, and a loop to generate a multiplication chart and test invalid input.
  5. Package Managers and Repositories — Inspect installed packages and repositories before taking action, and tell a package database from a dependency resolver.
  6. Boot, Services, Logs, and Timers — Trace the boot-to-service path, inspect logs, and create a timer that runs a tiny user service.
  7. IP Addresses, Routes, and Name Resolution — Separate the problems of link state, addressing, routing, name resolution, and listening services.
  8. SSH Keys, Host Identity, and File Transfer — Verify an SSH host’s identity, use a passphrase-protected key, and transfer a non-sensitive file.
  9. Block Devices, Filesystems, and Mounts — Distinguish a block device from a filesystem and a mount point, and inspect each layer without changing it.

Linux Advanced — 9 lessons

Build and verify Linux server features in a disposable VM. Use the Ubuntu or Red Hat-family lab identified in each lesson. Browse the category.

  1. LVM and Controlled Filesystem Growth — Create and expand an isolated LVM stack without touching the system disk.
  2. NFS and On-Demand Mounting with AutoFS — Create an indirect AutoFS map and distinguish a running automounter from a successful NFS mount.
  3. SELinux Contexts, Booleans, and Denials — Diagnose ordinary permission and SELinux policy problems separately and set a persistent file context.
  4. Firewall Zones and Runtime Rules — Identify the active zone and compare a timed runtime firewall rule with permanent policy.
  5. Authoritative DNS with BIND — Build an authoritative forward zone and distinguish an authoritative answer, NXDOMAIN, and no response.
  6. DHCP Leases and a Kea Lab — Validate a Kea DHCPv4 pool and verify a lease issued to a VM on an isolated segment.
  7. Time Synchronization with chrony — Distinguish clock display from synchronization and show whether chrony selected a source.
  8. Apache Virtual Hosts and HTTPS — Test Apache name-based routing locally and verify HTTPS with certificate and renewal checks.
  9. MariaDB Service Accounts and Restore Verification — Check a Linux-hosted MariaDB service, identify least-privilege database roles, and test a logical restore.

Linux Advanced 2 — 7 lessons

Extend the archive with modern tools and a capstone. Work through isolation, repeatability, performance, and recovery before running the final incident drill. Browse the category.

  1. Hardening a systemd Service — Run a small systemd service with a dedicated dynamic identity and a narrow writable directory.
  2. Rootless Containers with Podman — Serve a fixture with rootless Podman and verify that its port is published only on loopback.
  3. Repeatable Configuration with Ansible — Convert a small configuration task into an Ansible playbook and demonstrate idempotence.
  4. Performance Triage with vmstat and PSI — Use related signals to decide whether to investigate CPU, memory, disk I/O, or an application bottleneck.
  5. Kernel Modules and Resource Limits — Read kernel module information and identify the current process’s resource-control group without changing the kernel.
  6. Encrypted Backups and Restore Drills — Create an encrypted Restic snapshot and verify a real restore into a separate directory.
  7. Capstone: Build, Diagnose, and Recover a Linux Service — Demonstrate Linux service deployment, evidence-led incident diagnosis, and recovery in one lab.

Explore the source archive

The new series groups older posts by learning level. Original posts and their categories remain unchanged. The archive includes English and Bengali material, historical command logs, and some cross-posted versions. Follow the source links inside each lesson for the examples most relevant to that topic.

Linux Advanced 2 07 — Capstone: Build, Diagnose, and Recover a Linux Service

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

  1. What did the HTTP 404 establish about the network and service path?
  2. Why keep pre-repair evidence?

Assessment questions

  1. Write a short incident narrative with symptom, cause, evidence, repair, and verification.
  2. What observations would change if the process itself had exited?
  3. Propose one security or recovery improvement and a test to prove it works.

Questions and answers

Quick-check answers

  1. 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.
  2. Why keep pre-repair evidence?
    Answer — It lets you separate cause from coincidence and verify that repairs changed the expected symptom.

Assessment answer key

  1. 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.
  2. 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.
  3. 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

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

Linux Advanced 2 06 — Encrypted Backups and Restore Drills

Linux course index · Linux Advanced 2 category · Lesson 6 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

Create an encrypted Restic snapshot and verify a real restore into a separate directory.

Concepts and setup

The site shows tar archives and database dumps. This extension introduces encrypted, deduplicated repository snapshots. A repository check can find some consistency problems, but only a restore exercise proves you can retrieve the specific data you need. Recovery point objective (RPO) describes tolerable data loss in time. Recovery time objective (RTO) describes tolerable unavailability. This is a local fixture, not a disaster-resilient storage design.

Use a disposable VM with restic and a new temporary directory. Choose a lab-only passphrase when prompted and remember it for the four commands. In real operations, use an approved secret mechanism and keep separate protected copies of both the data and the recovery credentials.

Initialize and check a repository

lab=$(mktemp -d)
mkdir "$lab/data" "$lab/restore"
printf 'release=training\n' > "$lab/data/settings.txt"
export RESTIC_REPOSITORY="$lab/repo"
restic init
restic backup --tag oe-recovery "$lab/data"
restic snapshots
restic check

Possible output

created restic repository ...
...
snapshot 92d7e125 saved
...
no errors were found

Never put the real passphrase in shell history. The sample ID changes. A normal check does not necessarily read every data pack. Discuss the time and bandwidth cost of deeper checks in production.

Restore separately and compare actual bytes

restic restore latest --tag oe-recovery --target "$lab/restore"
restored=$(find "$lab/restore" -type f -name settings.txt -print -quit)
test -n "$restored" && cmp "$lab/data/settings.txt" "$restored" &&
  printf 'restored bytes match\n'
unset RESTIC_REPOSITORY

Possible output

restoring snapshot 92d7e125 ... to /tmp/tmp.ABC/restore
...
restored bytes match

This fixture contains one uniquely named file. Production restores should use an identified snapshot, preserve expected metadata, and verify application-level data as well.

Questions only

Quick-check questions

  1. Why is a snapshot ID more precise than latest?
  2. Why keep recovery credentials apart from the protected data?

Assessment questions

  1. A new snapshot is needed at most every hour and service must be restored within four hours. Identify RPO and RTO.
  2. Name two steps to prove a restore worked beyond seeing the command exit 0.
  3. What problem remains if both the original and the repository live on one laptop?

Questions and answers

Quick-check answers

  1. Why is a snapshot ID more precise than latest?
    Answer — It selects a known version even if newer snapshots appear.
  2. Why keep recovery credentials apart from the protected data?
    Answer — Losing the only recovery credentials can make the encrypted repository unreadable.

Assessment answer key

  1. A new snapshot is needed at most every hour and service must be restored within four hours. Identify RPO and RTO.
    Answer — RPO is one hour and RTO is four hours.
  2. Name two steps to prove a restore worked beyond seeing the command exit 0.
    Answer — For example, compare expected contents and metadata, query restored data, or test the recovered service from a client.
  3. What problem remains if both the original and the repository live on one laptop?
    Answer — The same device loss, compromise, or storage failure can destroy both copies.

Related source articles on this site

Technical references

Continue the course

Previous lesson 05 — Kernel Modules and Resource Limits. Next lesson 07 — Capstone: Build, Diagnose, and Recover a Linux Service.

Linux course index · Linux Advanced 2 category · Lesson 6 of 7

Linux Advanced 2 05 — Kernel Modules and Resource Limits

Linux course index · Linux Advanced 2 category · Lesson 5 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

Read kernel module information and identify the current process’s resource-control group without changing the kernel.

Concepts and setup

The site’s kernel and device-driver posts point to low-level Linux internals. This operational lab gives you a read-only way to inspect them. Modules are loadable kernel code. Built-in drivers may not appear in lsmod, and loading a module is not required just to learn its metadata. Control groups organize processes into resource-accounting and control hierarchies. Namespaces provide isolated views. These are different mechanisms and both can be involved in running containers.

Inspect the kernel and a module record

uname -r
lsmod | head -n 6
# If loop is present as a module or discoverable as built-in:
modinfo -F filename loop
journalctl -k -b -n 5 --no-pager

Possible output

6.x.x-example
Module                  Size  Used by
loop                   45056  0
...
/lib/modules/6.x.x-example/kernel/drivers/block/loop.ko.zst
... kernel: ...

Your actual kernel and modules differ. The loop driver can be built in or absent, and logs can require authorized access. Do not load or remove modules merely to make the output match.

Find the current cgroup and inspect a limit where supported

cat "/proc/$$/cgroup"
stat -fc '%T' /sys/fs/cgroup
group=$(awk -F: '$1=="0" && $2=="" {print $3}' "/proc/$$/cgroup")
if test -n "$group" && test -r "/sys/fs/cgroup$group/memory.max"; then
  cat "/sys/fs/cgroup$group/memory.max"
fi

Possible output

0::/user.slice/user-1000.slice/session-2.scope
cgroup2fs
max

This example uses the unified cgroup v2 hierarchy. Containers can change the cgroup view and filesystem layout. The word max means no numeric limit at this level, not necessarily no limit at any ancestor.

Questions only

Quick-check questions

  1. Does absence from lsmod prove that Linux has no such driver?
  2. What is the difference between a cgroup and a namespace?

Assessment questions

  1. Which read-only command identifies the running kernel release?
  2. In cgroup v2, why can a process hit a memory limit even if its memory.max says max?
  3. How would you collect kernel evidence without reloading a driver?

Questions and answers

Quick-check answers

  1. Does absence from lsmod prove that Linux has no such driver?
    Answer — No. It can be built into the kernel or otherwise not listed as a loaded module.
  2. What is the difference between a cgroup and a namespace?
    Answer — A cgroup groups processes for accounting and resource controls. A namespace isolates a view of a system resource.

Assessment answer key

  1. Which read-only command identifies the running kernel release?
    Answer — uname -r.
  2. In cgroup v2, why can a process hit a memory limit even if its memory.max says max?
    Answer — A parent cgroup may enforce a narrower quota.
  3. How would you collect kernel evidence without reloading a driver?
    Answer — Use boot kernel logs, lsmod and modinfo where available, and record the actual running kernel and timestamps.

Related source articles on this site

Technical references

Continue the course

Previous lesson 04 — Performance Triage with vmstat and PSI. Next lesson 06 — Encrypted Backups and Restore Drills.

Linux course index · Linux Advanced 2 category · Lesson 5 of 7

Linux Advanced 2 04 — Performance Triage with vmstat and PSI

Linux course index · Linux Advanced 2 category · Lesson 4 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

Use related signals to decide whether to investigate CPU, memory, disk I/O, or an application bottleneck.

Concepts and setup

The archive introduces free, vmstat, top, and process inspection. This lesson adds Pressure Stall Information (PSI), when the kernel exposes it. PSI reports when tasks are delayed by scarce CPU, memory, or I/O. A resource can be busy without causing observable stalls, and a stalled request can involve more than one resource. Ignore the first vmstat row when comparing recent samples because it commonly summarizes data since boot. Compare telemetry to the time of the application symptom.

Collect a short read-only baseline

date -u '+%FT%TZ'
uptime
free -h
vmstat -w 1 4
for resource in cpu memory io; do
  path="/proc/pressure/$resource"
  if test -r "$path"; then printf '%s\n' "$resource"; cat "$path"; fi
done

Possible output

2026-11-16T20:00:00Z
... load average: 0.12, 0.10, 0.08
...
cpu
some avg10=0.06 avg60=0.02 avg300=0.00 total=721540
memory
some avg10=0.00 avg60=0.00 avg300=0.00 total=2198
full avg10=0.00 avg60=0.00 avg300=0.00 total=661
io
some avg10=0.00 avg60=0.00 avg300=0.00 total=55385

The output is an abbreviated example. PSI percentages use rolling windows of roughly 10, 60, and 300 seconds. Missing files mean this interface is not available in that environment, not that pressure is zero.

Check who is consuming resources

ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 6
df -h "$HOME"
# If iostat is installed:
iostat -xz 1 3

Possible output

PID COMMAND       %CPU %MEM
234 python3        9.8  1.6
...
Filesystem      Size Used Avail Use% Mounted on
/dev/vda1        30G 5.1G   23G  19% /
...

ps %CPU is normally averaged over a process lifetime rather than an instantaneous sample. df answers a capacity question, not an I/O latency question. If iostat is available, inspect interval data and compare it with the time and symptoms.

Questions only

Quick-check questions

  1. Why is free memory alone a poor measure of memory trouble?
  2. What does a sustained increase in I/O pressure tell you?

Assessment questions

  1. vmstat shows a sustained runnable queue and CPU PSI is elevated while memory and I/O pressure are low. Which resource comes first?
  2. How would you distinguish a full filesystem from slow disk requests?
  3. What would make you suspect the application rather than visible host resource pressure?

Questions and answers

Quick-check answers

  1. Why is free memory alone a poor measure of memory trouble?
    Answer — Linux uses memory for cache that can often be reclaimed. Consider available memory, swap activity, pressure, and the workload.
  2. What does a sustained increase in I/O pressure tell you?
    Answer — At least some work is stalling for I/O. It does not identify which device or request caused the stall.

Assessment answer key

  1. vmstat shows a sustained runnable queue and CPU PSI is elevated while memory and I/O pressure are low. Which resource comes first?
    Answer — Investigate CPU scheduling and top CPU consumers first, then correlate with application latency.
  2. How would you distinguish a full filesystem from slow disk requests?
    Answer — Use df for capacity and interval I/O telemetry plus PSI for activity, queue and waiting symptoms.
  3. What would make you suspect the application rather than visible host resource pressure?
    Answer — A reproducible slowdown with no corresponding resource pressure makes application logs, dependencies, and request timing worth examining.

Related source articles on this site

Technical references

Continue the course

Previous lesson 03 — Repeatable Configuration with Ansible. Next lesson 05 — Kernel Modules and Resource Limits.

Linux course index · Linux Advanced 2 category · Lesson 4 of 7

Linux Advanced 2 03 — Repeatable Configuration with Ansible

Linux course index · Linux Advanced 2 category · Lesson 3 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

Convert a small configuration task into an Ansible playbook and demonstrate idempotence.

Concepts and setup

The archive often records administration as terminal history. That shows what someone typed but does not guarantee the final state on another host. Ansible describes a desired result. Idempotence means applying that same configuration to a system already at the desired state makes no further change. This lab needs Ansible and Python, uses localhost only, and never escalates privileges. Do not use diff output on files that contain secrets.

Write a config playbook and preview it

lab=$(mktemp -d)
cd "$lab" || exit
cat > lab.yml <<'YAML'
---
- name: Maintain one lab settings file
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - name: Install the intended settings
      ansible.builtin.copy:
        content: "service=demo\n"
        dest: "{{ playbook_dir }}/service.conf"
        mode: "0644"
YAML
ansible-playbook -i localhost, lab.yml --syntax-check
ansible-playbook -i localhost, lab.yml --check --diff
test ! -e service.conf && printf 'preview did not write\n'

Possible output

playbook: lab.yml
...
changed: [localhost]
preview did not write

The comma in localhost, makes it an inline inventory. This module can predict a file change without writing it.

Apply the playbook twice

ansible-playbook -i localhost, lab.yml
ansible-playbook -i localhost, lab.yml
cat service.conf
stat -c '%a' service.conf

Possible output

... localhost : ok=1 changed=1 ...
... localhost : ok=1 changed=0 ...
service=demo
644

The first run changes the fixture. The next makes no change. If the playbook also manages a service, follow configuration verification with a health check.

Questions only

Quick-check questions

  1. What does changed=0 mean on the repeated run?
  2. Why use a copy module instead of echo in a shell task?

Assessment questions

  1. How would you demonstrate correction of drift?
  2. Why can a clean check-mode run miss a production problem?
  3. Name two steps before extending the inventory beyond localhost.

Questions and answers

Quick-check answers

  1. What does changed=0 mean on the repeated run?
    Answer — The module found that the resource already matches the declared state.
  2. Why use a copy module instead of echo in a shell task?
    Answer — The module compares state and can manage content and permissions repeatably.

Assessment answer key

  1. How would you demonstrate correction of drift?
    Answer — Deliberately change the lab file, preview and apply the playbook, check that the correct state came back, then confirm a repeated run shows changed=0.
  2. Why can a clean check-mode run miss a production problem?
    Answer — Some effects are not simulated, and actual target runtime conditions can differ.
  3. Name two steps before extending the inventory beyond localhost.
    Answer — Review and authorize targets, protect secrets, stage changes, and test rollback. Any two.

Related source articles on this site

Technical references

Continue the course

Previous lesson 02 — Rootless Containers with Podman. Next lesson 04 — Performance Triage with vmstat and PSI.

Linux course index · Linux Advanced 2 category · Lesson 3 of 7

Linux Advanced 2 02 — Rootless Containers with Podman

Linux course index · Linux Advanced 2 category · Lesson 2 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

Serve a fixture with rootless Podman and verify that its port is published only on loopback.

Concepts and setup

The site discusses Docker, Vagrant, MicroK8s, and isolated lab networks. Here, an image provides the container’s starting filesystem, a bind mount exposes one chosen host path, and port publishing maps a host listener to a container port. Rootless mode avoids using host root to run the engine. It does not give the same isolation model as a VM. Use Podman as a regular user in a disposable VM. Use approved registry sources, and record a digest to identify the exact image used.

Run a loopback-only test site

lab=$(mktemp -d)
mkdir -m 755 "$lab/site"
printf 'rootless lab page\n' > "$lab/site/index.html"
chmod 644 "$lab/site/index.html"
podman info --format '{{.Host.Security.Rootless}}'
podman run -d --name oe-linux-web \
  -p 127.0.0.1:8088:80 \
  -v "$lab/site:/usr/share/nginx/html:ro,Z" \
  docker.io/library/nginx:1.28-alpine
podman port oe-linux-web
curl -fsS http://127.0.0.1:8088/

Possible output

true
...
80/tcp -> 127.0.0.1:8088
rootless lab page

Use an unused name and free port. Allow the service a moment to start. :ro applies inside the container. :Z is for private SELinux labeling of this disposable fixture, not your whole home or system data.

Inspect and remove the container

podman inspect --format '{{.State.Status}} {{.Image}}' oe-linux-web
podman logs --tail 4 oe-linux-web
podman stop oe-linux-web
podman rm oe-linux-web

Possible output

running sha256:...
... "GET / HTTP/1.1" 200 ...
oe-linux-web
oe-linux-web

Removing this container leaves the bind-mounted host folder. Remove that test folder only when done.

Questions only

Quick-check questions

  1. Why are direct remote connections not accepted here?
  2. Does :ro make the host directory read-only to the owner?

Assessment questions

  1. If curl refuses the connection, what are your first checks?
  2. Why record a digest instead of only a tag?
  3. How could you prove the file comes from the bind mount?

Questions and answers

Quick-check answers

  1. Why are direct remote connections not accepted here?
    Answer — The listener is bound to loopback.
  2. Does :ro make the host directory read-only to the owner?
    Answer — No. The option applies to the container’s mount.

Assessment answer key

  1. If curl refuses the connection, what are your first checks?
    Answer — Check podman state, logs and port mapping, then ss -ltn. Confirm no other program uses the port.
  2. Why record a digest instead of only a tag?
    Answer — The tag can point to a different build later, while the digest identifies exact image content.
  3. How could you prove the file comes from the bind mount?
    Answer — Change the host fixture to contain one unique marker, fetch it again, and compare.

Related source articles on this site

Technical references

Continue the course

Previous lesson 01 — Hardening a systemd Service. Next lesson 03 — Repeatable Configuration with Ansible.

Linux course index · Linux Advanced 2 category · Lesson 2 of 7

Linux Advanced 2 01 — Hardening a systemd Service

Linux course index · Linux Advanced 2 category · Lesson 1 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

Run a small systemd service with a dedicated dynamic identity and a narrow writable directory.

Concepts and setup

The site’s boot, logging, and SELinux posts explain separate layers of service control. This extension adds systemd isolation. DynamicUser allocates a temporary identity. StateDirectory provides one managed writable path. ProtectSystem=strict otherwise makes the service’s filesystem view mostly read-only. NoNewPrivileges blocks privilege gains through execution. Use a disposable systemd VM, an unused unit name, and console access. Check application behavior separately from the security score.

Write and start the restricted unit

sudo tee /etc/systemd/system/oe-linux-hardening.service >/dev/null <<'EOF'
[Unit]
Description=Open Education service isolation lab
[Service]
Type=oneshot
DynamicUser=yes
StateDirectory=oe-linux-hardening
ProtectSystem=strict
ProtectHome=yes
NoNewPrivileges=yes
PrivateTmp=yes
ExecStart=/usr/bin/touch /var/lib/oe-linux-hardening/check
ExecStart=/usr/bin/echo state-write-ok
EOF
sudo systemd-analyze verify /etc/systemd/system/oe-linux-hardening.service
sudo systemctl daemon-reload
sudo systemctl start oe-linux-hardening.service
sudo journalctl -u oe-linux-hardening.service -n 8 --no-pager
sudo test -f /var/lib/oe-linux-hardening/check && printf 'proof exists\n'

Possible output

... state-write-ok
... Finished Open Education service isolation lab.
proof exists

StateDirectory is an explicit writable exception to the service’s read-only view. A successful oneshot can be inactive after the command exits.

Inspect controls and remove the fixture unit

systemctl show oe-linux-hardening.service -p DynamicUser -p NoNewPrivileges -p ProtectSystem
systemd-analyze security oe-linux-hardening.service
sudo systemctl stop oe-linux-hardening.service
sudo rm /etc/systemd/system/oe-linux-hardening.service
sudo systemctl daemon-reload

Possible output

DynamicUser=yes
NoNewPrivileges=yes
ProtectSystem=strict
...
Overall exposure level for oe-linux-hardening.service: ...

The score is a checklist aid, not a guarantee. Removing the unit does not remove persistent state. Retire the named lab directory after recording results.

Questions only

Quick-check questions

  1. Which directive supplies the writable directory?
  2. Does a good security score demonstrate that the application works?

Assessment questions

  1. Why use controls and an application check?
  2. Name two controls that restrict this unit at the operating-system level.
  3. ProtectHome breaks a service. How might you keep that control without breaking the service?

Questions and answers

Quick-check answers

  1. Which directive supplies the writable directory?
    Answer — StateDirectory, here for oe-linux-hardening.
  2. Does a good security score demonstrate that the application works?
    Answer — No. Verify the task outcome and logs.

Assessment answer key

  1. Why use controls and an application check?
    Answer — Controls reduce what is accessible. A check confirms the service can still do its intended work.
  2. Name two controls that restrict this unit at the operating-system level.
    Answer — Examples include DynamicUser, ProtectSystem, NoNewPrivileges, ProtectHome, and PrivateTmp.
  3. ProtectHome breaks a service. How might you keep that control without breaking the service?
    Answer — Move only necessary inputs to a managed application directory with narrowly scoped access and retest.

Related source articles on this site

Technical references

Continue the course

Next lesson 02 — Rootless Containers with Podman.

Linux course index · Linux Advanced 2 category · Lesson 1 of 7

Linux Advanced 09 — MariaDB Service Accounts and Restore Verification

Linux course index · Linux Advanced category · Lesson 9 of 9

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Check a Linux-hosted MariaDB service, identify least-privilege database roles, and test a logical restore.

Concepts and setup

The archive’s RHCE notes cover MariaDB packages, service operation, configuration, accounts, and backup. The server is a daemon, while the client sends it queries. Distribution packages vary in service names and default authentication. Use only necessary packages and keep the database off untrusted networks.

Use a disposable VM and its authorized local administration account. Real applications should use dedicated accounts with only required privileges. This fixture uses two unused schemas and InnoDB. It is not a full server backup.

Check the service and create a test database

systemctl is-active mariadb
sudo mariadb <<'SQL'
CREATE DATABASE oe_linux_demo;
CREATE TABLE oe_linux_demo.checks (
  id INT PRIMARY KEY,
  status VARCHAR(15) NOT NULL
) ENGINE=InnoDB;
INSERT INTO oe_linux_demo.checks VALUES (1,'ready'),(2,'verified');
SELECT id, status FROM oe_linux_demo.checks ORDER BY id;
SQL

Possible output

active
id  status
1   ready
2   verified

If the distribution does not enable socket authentication for sudo mariadb, use the lab’s authorized local authentication path. Do not put credentials into command history or lab reports.

Define a read-only role without creating a login

sudo mariadb <<'SQL'
CREATE ROLE oe_linux_reader;
GRANT SELECT ON oe_linux_demo.checks TO oe_linux_reader;
SHOW GRANTS FOR oe_linux_reader;
SQL

Possible output

Grants for oe_linux_reader
GRANT USAGE ON *.* TO `oe_linux_reader`
GRANT SELECT ON `oe_linux_demo`.`checks` TO `oe_linux_reader`

The exact display varies. The role defines scoped read access but is not itself the application’s login. In a real deployment, configure an approved application account, grant the role, and verify both an allowed SELECT and a denied write from that account. Remove the lab role when retiring the two fixture schemas.

Export locally and verify a separate restore

lab=$(mktemp -d)
( umask 077; sudo mariadb-dump --single-transaction oe_linux_demo > "$lab/demo.sql" )
sudo mariadb -e 'CREATE DATABASE oe_linux_restore;'
sudo mariadb oe_linux_restore < "$lab/demo.sql"
sudo mariadb -N -e 'SELECT id,status FROM oe_linux_restore.checks ORDER BY id;'
sudo mariadb -N -e 'SELECT COUNT(*) FROM oe_linux_restore.checks;'

Possible output

1  ready
2  verified
2

Stop at any error. The transaction helps for InnoDB data, not all engines and object types. Avoid concurrent schema changes. After verification, retire only your fixture schemas and securely handle the dump.

Questions only

Quick-check questions

  1. Why restore into a different schema?
  2. Can a running service prove the dump is valid?

Assessment questions

  1. Name two checks that provide evidence of recovery beyond a dump file’s size.
  2. What rights would you give a reporting application account?
  3. Why can –single-transaction be insufficient for a mixed-engine database?

Questions and answers

Quick-check answers

  1. Why restore into a different schema?
    Answer — It avoids modifying the original and gives a separate verification target.
  2. Can a running service prove the dump is valid?
    Answer — No. Test an actual restore and query it.

Assessment answer key

  1. Name two checks that provide evidence of recovery beyond a dump file’s size.
    Answer — Compare expected row counts and known rows or checksums, then test representative application queries.
  2. What rights would you give a reporting application account?
    Answer — Only the required SELECT rights on specified tables or schemas, with appropriate account location and authentication restrictions.
  3. Why can –single-transaction be insufficient for a mixed-engine database?
    Answer — Nontransactional engines do not share the same consistent transaction snapshot. Concurrent changes to schema definitions can also invalidate assumptions.

Source articles on this site

Continue the course

Previous lesson 08 — Apache Virtual Hosts and HTTPS. This is the last lesson in this level. See the course index for the next level.

Linux course index · Linux Advanced category · Lesson 9 of 9

Linux Advanced 08 — Apache Virtual Hosts and HTTPS

Linux course index · Linux Advanced category · Lesson 8 of 9

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Test Apache name-based routing locally and verify HTTPS with certificate and renewal checks.

Concepts and setup

A virtual host maps the requested host and port to settings and a DocumentRoot. A client sends an HTTP Host header. For HTTPS, TLS starts before HTTP and SNI usually helps the server choose a certificate. The site’s Certbot procedure assumes an authorized public domain. You cannot get a public certificate for a private .test hostname. Use a disposable Ubuntu or Debian VM with Apache installed for the first lab.

Create one name-based vhost and test it from the same VM

sudo install -d -m 0755 /var/www/oe-linux-test
printf 'Open Education Apache lab\n' | sudo tee /var/www/oe-linux-test/index.html
sudo tee /etc/apache2/sites-available/oe-linux-test.conf >/dev/null <<'EOF'
<VirtualHost *:80>
    ServerName web.example.test
    DocumentRoot /var/www/oe-linux-test
</VirtualHost>
EOF
sudo a2ensite oe-linux-test
sudo apachectl configtest && sudo systemctl reload apache2
curl -fsS --resolve web.example.test:80:127.0.0.1 http://web.example.test/

Possible output

Open Education Apache lab
Enabling site oe-linux-test.
Syntax OK
Open Education Apache lab

Use unused file names. –resolve targets loopback while keeping the requested hostname. After testing, run a2dissite oe-linux-test, test and reload the config, and remove only these fixture files.

On a separate domain you manage, verify trust and renewal

# Replace www.example.com with your authorized domain.
curl -IsS https://www.example.com/
# On that server, after legitimate Certbot setup:
sudo certbot certificates
sudo certbot renew --dry-run

Possible output

HTTP/2 200
...
Certificate Name: www.example.com
...
Congratulations, all simulated renewals succeeded: ...

These commands verify an existing deployment. To obtain a certificate, use the CA’s supported validation procedure. HTTP-01 uses incoming port 80. DNS-01 uses a DNS TXT challenge and can suit a service that is not public over HTTP. Do not use curl -k as evidence of trust.

Questions only

Quick-check questions

  1. Why can a browser reject a certificate from a known CA?
  2. Does apachectl configtest prove that the client sees the right website?

Assessment questions

  1. The default vhost answers instead of the new site. What do you verify?
  2. What evidence should a certificate-renewal checklist include?
  3. When would you consider DNS-01 instead of HTTP-01?

Questions and answers

Quick-check answers

  1. Why can a browser reject a certificate from a known CA?
    Answer — The requested name may not match, the certificate may be expired, or the chain may be unsuitable.
  2. Does apachectl configtest prove that the client sees the right website?
    Answer — No. It validates configuration syntax, not application routing.

Assessment answer key

  1. The default vhost answers instead of the new site. What do you verify?
    Answer — Inspect apachectl -S, the enabled vhost, listener port, ServerName, and the name the client actually sends.
  2. What evidence should a certificate-renewal checklist include?
    Answer — Verify hostname and chain from a client, check expiry, perform an authorized renewal dry run, and confirm automatic scheduling.
  3. When would you consider DNS-01 instead of HTTP-01?
    Answer — When you control DNS validation and do not want to make the web server publicly reachable on port 80, or need a wildcard certificate.

Source articles on this site

Technical references

Continue the course

Previous lesson 07 — Time Synchronization with chrony. Next lesson 09 — MariaDB Service Accounts and Restore Verification.

Linux course index · Linux Advanced category · Lesson 8 of 9