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 3

Lab 3 of 8 · Packages, updates and patching

Patch your server and automate security updates

Inspect packages, apply updates, check whether a restart is needed, and switch on automatic security updates.

Time
45 minutes
Cost
Free.

What you learn

Most break-ins use known holes that already have a fix. Keeping packages patched, automatically where possible, is one of the highest-value jobs a sysadmin does.

  • Installing, inspecting and removing packages with apt
  • Security updates and your security status
  • Automatic security updates with unattended-upgrades
  • Knowing when a restart is needed

In the AI era: AI can summarise a list of updates in seconds, but version numbers and security notices are facts you check on the system and in official advisories, not in a chat answer.

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

  • 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 See what is waiting

    apt update refreshes the list of available versions; it does not install anything.

    Run this on your lab server
    sudo apt update
    apt list --upgradable 2>/dev/null | head -n 20
    You should see:

    A list of packages with newer versions, or nothing if the server is up to date.

  2. 2 Check your security status

    Ubuntu's pro tool summarises which installed packages receive security updates.

    Run this on your lab server
    pro security-status
    You should see:

    A summary of installed packages and where their security updates come from.

  3. 3 Install, inspect and remove a package

    apt show describes a package; dpkg -L lists every file it installed.

    Run this on your lab server
    sudo apt install -y tree
    apt show tree 2>/dev/null | head -n 8
    dpkg -L tree | head
    tree -L 1 /etc | head
    sudo apt remove -y tree
    You should see:

    The version and source of tree, the files it installed, and a short tree of /etc.

  4. 4 Apply updates and check for a restart

    Kernel and core library updates only take effect after a restart, and Ubuntu leaves a marker file when one is needed.

    Run this on your lab server
    sudo apt upgrade -y
    if [ -f /var/run/reboot-required ]; then cat /var/run/reboot-required.pkgs; else echo "No restart needed"; fi
    You should see:

    Updates install, then either No restart needed or the packages that need one. If needed, run sudo reboot, wait a minute and open a new shell.

  5. 5 Turn on automatic security updates

    unattended-upgrades installs security updates every day. The dry run shows what it would do without changing anything.

    Run this on your lab server
    sudo apt install -y unattended-upgrades
    sudo dpkg-reconfigure -f noninteractive unattended-upgrades
    cat /etc/apt/apt.conf.d/20auto-upgrades
    sudo unattended-upgrade --dry-run --debug 2>&1 | tail -n 5
    You should see:

    20auto-upgrades contains APT::Periodic::Unattended-Upgrade "1";.

  6. 6 Ask AI to explain the update history, then check it

    Print the recent update history and ask your AI assistant to summarise what changed. Then check one package it mentions with apt-cache policy (replace openssl with a package from your log): the installed version on the server is the fact.

    Run this on your lab server
    tail -n 30 /var/log/apt/history.log
    apt-cache policy openssl
    You should see:

    Installed: and Candidate: lines; after updating they usually match.

  7. 7 Write your notes

    Create the file with nano notes/03-patching.md.

    File: notes/03-patching.md
    # Patching my server
    
    ## What I updated
    - Date: ...
    - Number of packages: ...
    - Restart needed? Why: ...
    
    ## Automatic updates
    - What unattended-upgrades does: ...
    - How I check it is working: ...
    
    ## AI check
    - What the AI summary said, and what `apt-cache policy` showed: ...
    
  8. 8 Commit and push

    Save your work to GitHub from the server.

    Run this on your lab server
    git add notes
    git commit -m "Add patching notes"
    git push

You are done when

  • Your server has no pending updates, or you know which ones are waiting and why.

  • Automatic security updates are switched on.

  • notes/03-patching.md records what you updated and whether a restart was needed.

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.