PleinIQ
Menu
Language

Choose your language

This page is only in English for now. Choosing a language opens its home page.

Other languages

Your browser can translate any page into almost any language.

Other browsers: Open the browser menu and look for “Translate”.

Your resume, your downloads and lab commands are never translated.

Roadmaps / Linux / Lab 7

Lab 7 of 8 · Logs, monitoring and troubleshooting

Break a service on purpose and fix it with a method

Break your status page the way a bad deployment would, find the cause from logs and system checks, fix it, and write a runbook.

Time
45 minutes
Cost
Free.

What you learn

When something breaks at 3 a.m., a calm method beats guessing: check the service, read the logs, check resources, change one thing, and write down what fixed it.

  • A repeatable troubleshooting method
  • Filtering logs with journalctl
  • Checking CPU, memory and disk with uptime, free, df and vmstat
  • Writing a runbook other people can follow

In the AI era: AI is good at suggesting causes from an error message. Give it the real log lines with secrets, hostnames and addresses removed, then confirm its suggestion with evidence before you change anything.

Get set up

Commands use Homebrew in the Terminal app. Already have a tool? Skip it.

  • Install
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    Use the Terminal app. The command installs Homebrew, which the other macOS commands use.

Before you start

  • Finish lab 4 (you need the status-page service).

  • Start your server and open your repository: run multipass start sysadmin-lab and multipass shell sysadmin-lab on your computer, then cd linux-admin-lab on the server.

Step by step

  1. 1 Take a health snapshot

    Knowing what normal looks like makes problems easier to spot.

    Run this on your lab server
    uptime
    free -h
    df -h /
    vmstat 1 5
    systemctl --failed --no-pager
    You should see:

    Load averages, memory, disk use, five lines of activity, and 0 loaded units listed.

  2. 2 Break the service

    This simulates a bad deployment: the unit now points at a program that does not exist. If your unit has a different ExecStart, change its program path to a wrong one by hand.

    Run this on your lab server
    sudo sed -i 's#/usr/bin/python3#/usr/bin/python4#' /etc/systemd/system/status-page.service
    sudo systemctl daemon-reload
    sudo systemctl restart status-page
    sleep 15
    curl -s http://localhost:8080 || echo "The status page is down"
    You should see:

    The status page is down.

  3. 3 Investigate: status first, then logs

    Start broad and narrow down.

    Run this on your lab server
    systemctl status status-page --no-pager
    journalctl -u status-page -n 20 --no-pager
    systemctl --failed --no-pager
    You should see:

    activating (auto-restart) or failed, with status 203/EXEC, and log lines saying the program could not be run.

  4. 4 Ask AI for likely causes, then confirm one

    Paste the log lines into your AI assistant and ask for the most likely cause and how to confirm it. They contain nothing secret here; on a real server, remove hostnames, addresses and tokens first. Confirm before changing anything:

    Run this on your lab server
    systemctl cat status-page | grep ExecStart
    ls -l /usr/bin/python4 /usr/bin/python3
    You should see:

    python4 does not exist and python3 does. The evidence, not the AI's confidence, confirms the cause.

  5. 5 Fix it and confirm

    Change one thing, then prove it worked.

    Run this on your lab server
    sudo sed -i 's#/usr/bin/python4#/usr/bin/python3#' /etc/systemd/system/status-page.service
    sudo systemctl daemon-reload
    sudo systemctl reset-failed status-page
    sudo systemctl restart status-page
    curl -s http://localhost:8080
    You should see:

    Your <h1> line again.

  6. 6 Write the runbook

    A runbook lets someone else fix this at 3 a.m. without you. Create it with mkdir -p runbooks and nano runbooks/status-page-down.md, and add one more cause you can think of.

    File: runbooks/status-page-down.md
    # Runbook: status page is down
    
    ## Symptoms
    - `curl http://localhost:8080` fails, or someone reports the page is down.
    
    ## Check, in this order
    1. `systemctl status status-page --no-pager`: is it running? What is the result?
    2. `journalctl -u status-page -n 50 --no-pager`: the latest errors.
    3. `free -h` and `df -h /`: is the server out of memory or disk?
    4. `sudo ss -tlnp | grep 8080`: is something else using the port?
    
    ## Known causes and fixes
    | Cause | How to confirm | Fix |
    |-------|----------------|-----|
    | Wrong program path in the unit (`203/EXEC`) | `systemctl cat status-page` | Correct `ExecStart`, then `daemon-reload` and `restart` |
    | ... | ... | ... |
    
    ## After fixing
    - Run `sudo systemctl reset-failed status-page` and confirm with `curl`.
    - Write down what happened, when, and what fixed it.
    
  7. 7 Commit and push

    Save your work to GitHub from the server.

    Run this on your lab server
    git add runbooks
    git commit -m "Add status page troubleshooting runbook"
    git push

You are done when

  • You found the cause from systemctl status and journalctl, not by guessing.

  • You confirmed the AI's suggestion with evidence before changing anything.

  • runbooks/status-page-down.md is on GitHub.

Finished? Get your proof page

We check your public GitHub repository and give you a page to share with recruiters, and can add the project to your resume.

Join PleinIQ Updates

What are you interested in?

Read how we handle your information in our privacy notice.