How To

LFCS Practice Questions: Hands-On Tasks with Full Solutions

LFCS practice questions are only useful when they feel like the real work. You get a shell on a live Linux box and a task in plain English, and a grader inspects the system after you leave. The Linux Foundation Certified System Administrator credential is scored exactly that way, so a multiple choice bank tells you very little about whether you can revive a service that will not start or grow a full volume while it stays mounted.

Original content from computingforgeeks.com - post 194298

We built two small Ubuntu 24.04 VMs, node01 and nas01, and worked through 28 tasks that cover all five LFCS domains: operations, networking, storage, essential commands, and users and groups. Every task has the statement, the commands, the output we got and the check that proves it, including the places where our first attempt failed. I ran through all of it in November 2026 and rebooted node01 at the end to make sure every change came back on its own.

How LFCS tasks are graded

The Linux Foundation LFCS page lists the five domains with their weights, and the candidate instructions describe the sitting itself. The table pulls together the facts that change how you should practice.

ItemWhat the Linux Foundation states
FormatOnline, proctored, performance based tasks on the command line
Length17 to 20 tasks, expected to take 2 hours
Passing score67% or above
DomainsOperations Deployment 25%, Networking 25%, Storage 20%, Essential Commands 20%, Users and Groups 10%
DistributionIndependent of distribution specific tasks
Allowed helpman pages and documentation installed with the distribution
Retake and simulatorOne retake, plus two killer.sh simulator sessions of 36 hours each
Validity2 years

Two rules in the instructions shaped this whole page:

  • Reach each task host with ssh <nodename>, then sudo -i
  • Never reboot the base system

Together they mean your changes have to be correct the first time and persistent by design, because nobody tells you which reload you forgot. The rule only names the base host, but a reboot on a task node costs minutes you do not have. So what does a safe answer look like when you would rather not reboot to test it? We settled on four habits and used them on every task below:

  1. Write the change to a file (a drop-in, fstab, netplan, a unit)
  2. Validate the file with the tool’s own checker
  3. Enable the service, not just start it
  4. Prove the result with a read only command

Step 2 saves the most time, and these are the checkers we leaned on:

  • sshd -t before any SSH restart
  • nft -c -f before loading a ruleset
  • nginx -t before a reload
  • findmnt --verify after any fstab edit

Each one takes a second, and each one caught a mistake in our lab before it could lock us out or hang a boot. Treat every checker as part of the answer rather than an optional extra, because a grader only sees the final state and never the command you meant to run.

The practice lab is two Ubuntu VMs

Several LFCS competencies need a second machine: a time server, an NFS export, an LDAP directory, an SSH target and a backend for the load balancer. We gave those roles to nas01 and did the client side on node01, so every task you see below runs from one shell. Two extra 10 GB disks on node01 carry the LVM tasks. The interface name ens4, the 10.128.0.0/9 lab range and the two addresses below belong to our cloud network, so swap in your own interface and subnet wherever they appear.

HostAddressSizeRoles
node01.lab.example.com10.128.0.622 vCPU, 8 GB RAM, disks sdb and sdcClient for every task, Docker, nginx proxy, LVM, libvirt
nas01.lab.example.com10.128.15.1922 vCPU, 2 GB RAMchrony server, SSH target, nftables NAT, NFS, OpenLDAP, Git remote, web backend

Both VMs run Ubuntu 24.04 LTS with a sudo user called kibet. The domain list says the tasks are independent of the distribution, so if you practice on Rocky Linux instead, swap apt for dnf and netplan for NetworkManager and the rest carries over. Our RHCSA practice tasks cover that Red Hat flavour of the same skills, and doing both sets is the fastest way to stop depending on one package manager.

Part 1: Operations deployment tasks

Operations Deployment carries a quarter of the score and covers the most ground: kernel tuning, services, scheduling, packages, recovery, virtual machines and containers. These seven tasks touch each of those areas on node01, and several of them set up state that later tasks reuse, so work through them in order. The one exception is Task 7, which repairs the mount Task 15 creates, so come back to it after Part 3.

Task 1: Set kernel parameters that survive a reboot

Task: enable IPv4 forwarding and set vm.swappiness to 10, persistently. Check the current values first, so you know what you are changing and can tell later whether your file did anything.

sysctl vm.swappiness net.ipv4.ip_forward

Our node01 started from the Ubuntu defaults, with forwarding off and swappiness at 60:

vm.swappiness = 60
net.ipv4.ip_forward = 0

sysctl -w changes the running kernel only, so it is the wrong answer to any task that says “persistently”. The persistent answer is a file under /etc/sysctl.d/, named with a high number so it is applied after the distribution defaults:

sudo vim /etc/sysctl.d/90-lfcs.conf

Add both settings:

net.ipv4.ip_forward = 1
vm.swappiness = 10

Writing the file changes nothing until something reads it. sysctl --system loads every sysctl file in the same order the boot process does, so it also proves your file will be picked up at the next boot:

sudo sysctl --system | grep 90-lfcs
sysctl vm.swappiness net.ipv4.ip_forward

The file was applied and both values changed:

* Applying /etc/sysctl.d/90-lfcs.conf ...
vm.swappiness = 10
net.ipv4.ip_forward = 1

Watch for one trap here. Without sudo, sysctl -w vm.swappiness=30 printed permission denied on key "vm.swappiness", ignoring, then echoed vm.swappiness = 30 and exited 0. The value stayed at 10, so a check that trusts the exit code would report a change that never happened. Always read the key back after you set it.

Task 2: Fix a service that will not start

Task: the heartbeat service is enabled but keeps failing. Find out why, fix it, and leave it running and enabled. The unit itself is short, which tells you the problem is probably not in the unit:

[Unit]
Description=Heartbeat logger
After=network-online.target

[Service]
ExecStart=/usr/local/bin/heartbeat.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

To stage the fault yourself, save the unit as /etc/systemd/system/heartbeat.service, write this two line script to /usr/local/bin/heartbeat.sh without making it executable, and enable the service:

#!/bin/bash
while true; do date >> /var/log/heartbeat.log; sleep 30; done

Start with the status rather than the logs, because systemd records why a start failed even when the program never ran:

systemctl status heartbeat.service --no-pager -n 0

The service sits in an auto restart loop with exit status 203:

● heartbeat.service - Heartbeat logger
     Loaded: loaded (/etc/systemd/system/heartbeat.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2026-11-23 02:07:22 UTC; 7ms ago
    Process: 2302 ExecStart=/usr/local/bin/heartbeat.sh (code=exited, status=203/EXEC)
   Main PID: 2302 (code=exited, status=203/EXEC)
        CPU: 2ms

Status 203/EXEC means systemd could not execute the file at all, so the script never ran and left nothing of its own to read. Our first journalctl -u heartbeat.service as kibet returned nothing, because an ordinary user outside the adm group cannot read the system journal. With sudo, the journal says the same thing as the status, so check the file itself:

ls -l /usr/local/bin/heartbeat.sh

The script has no execute bit, which matches the 203 code exactly:

-rw-r--r-- 1 root root 74 Nov 23 02:07 /usr/local/bin/heartbeat.sh

Make it executable and restart the unit. Check both the running state and the boot state, because a task that says “leave it running” is usually graded after a fresh boot as well:

sudo chmod 755 /usr/local/bin/heartbeat.sh
sudo systemctl restart heartbeat.service
systemctl is-active heartbeat.service; systemctl is-enabled heartbeat.service

Both checks pass:

active
enabled

Other 2xx codes point at the same layer. A missing interpreter, a wrong path in ExecStart or a bad User= all fail before the program starts, which is why the status line is a better first stop than application logs. If you see a 2xx code, look at the unit and the file it points to before you read a single log line.

Task 3: Schedule a cron job and a systemd timer

Task: as kibet, log root filesystem usage every 15 minutes with cron. Then, as root, delete files in /tmp older than 7 days every night at 02:30 with a systemd timer that catches up after downtime. The cron half is one line, but the way you add it matters:

(crontab -l 2>/dev/null; echo '*/15 * * * * /usr/bin/df -h / >> /home/kibet/df.log 2>&1') | crontab -
crontab -l

The subshell prints any existing entries before the new one, so you append instead of replacing the whole crontab. That matters when a task host already has jobs you were not told about:

*/15 * * * * /usr/bin/df -h / >> /home/kibet/df.log 2>&1

A timer needs two units with the same name: a service that does the work and a timer that triggers it. Create the service first:

sudo vim /etc/systemd/system/tmpclean.service

It is a oneshot that runs find and exits, so it has no [Install] section of its own:

[Unit]
Description=Clean /tmp files older than 7 days

[Service]
Type=oneshot
ExecStart=/usr/bin/find /tmp -xdev -type f -mtime +7 -delete

Then the timer that triggers it:

sudo vim /etc/systemd/system/tmpclean.timer

Persistent=true is the “catches up after downtime” part of the task. Without it, a run missed while the host was off is simply skipped:

[Unit]
Description=Run tmpclean daily at 02:30

[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true

[Install]
WantedBy=timers.target

Enable the timer, not the service. Enabling the service would do nothing useful, because it has no install target and the timer is what starts it:

sudo systemctl daemon-reload
sudo systemctl enable --now tmpclean.timer
systemctl list-timers tmpclean.timer --no-pager

The timer is waiting for 02:30:

NEXT                         LEFT LAST PASSED UNIT           ACTIVATES
Mon 2026-11-23 02:30:00 UTC 22min -         - tmpclean.timer tmpclean.service

1 timers listed.

Two more checks are worth the seconds they take. systemd-analyze calendar '*-*-* 02:30:00' prints the normalized expression and the next elapse, so you catch a typo in OnCalendar today instead of the night it should have run. Running sudo systemctl start tmpclean.service and then systemctl show tmpclean.service -p Result --value returned success, which proves the job itself works and not just its schedule.

Task 4: Install, hold and verify packages, and add a vendor repository

Task: install tree and hold it at its current version, repair a package whose files were changed, and install nginx from the nginx.org repository instead of the Ubuntu archive.

On our first try the install printed nothing useful (we had silenced it), and the hold that followed failed with E: Unable to locate package tree. The fresh cloud image had no package lists yet, so the install had quietly done nothing. Run sudo apt-get update first on any new host, then install and hold:

sudo apt-get update
sudo apt-get install -y tree
sudo apt-mark hold tree
apt-mark showhold

The hold is recorded and listed:

tree set on hold.
tree

To practice validation, we deleted one of the package files and asked dpkg to compare what is on disk against its own records:

sudo rm /usr/share/doc/tree/README.gz
dpkg -V tree

dpkg reports the damage but still exits 0, so you have to read its output rather than its return code:

missing     /usr/share/doc/tree/README.gz

A reinstall puts the file back, and a second dpkg -V tree prints nothing at all, which is what a clean package looks like. Next, add the nginx.org repository with its signing key in a dedicated keyring. A keyring per repository is the modern replacement for apt-key, because the key then only vouches for the one source that names it:

sudo apt-get install --reinstall -y tree
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg
sudo vim /etc/apt/sources.list.d/nginx.sources

Ubuntu 24.04 uses the deb822 format for sources, so the file is a set of fields rather than a single line:

Types: deb
URIs: https://nginx.org/packages/ubuntu
Suites: noble
Components: nginx
Signed-By: /usr/share/keyrings/nginx-archive-keyring.gpg

Refresh the lists and ask apt where nginx would come from before you install anything:

sudo apt-get update
apt-cache policy nginx | head -6

The candidate now comes from nginx.org:

nginx:
  Installed: (none)
  Candidate: 1.30.7-1~noble
  Version table:
     1.30.7-1~noble 500
        500 https://nginx.org/packages/ubuntu noble/nginx amd64 Packages

Install it with sudo apt-get install -y nginx. Leave it installed, because Task 14 builds on it. The habit to keep is apt-cache policy before every install from a new source. It tells you which repository wins before anything changes on disk, so you never have to undo a package from the wrong place.

Task 5: Run a container with a restart policy and log rotation

Task: configure the container engine to rotate JSON logs at 10 MB with 3 files, then run an nginx container named web on host port 8081 that serves /srv/web read only and restarts unless someone stops it. We used the docker.io package from the Ubuntu archive, and the Docker CE install on Ubuntu works the same for this task.

sudo apt-get install -y docker.io
sudo vim /etc/docker/daemon.json

The daemon reads its defaults from this JSON file, and a stray comma stops it from starting, so keep it small:

{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}

Restart the daemon first, then create the content and start the container:

sudo systemctl restart docker
sudo mkdir -p /srv/web && echo 'hello from a container' | sudo tee /srv/web/index.html
sudo docker run -d --name web --restart unless-stopped -p 8081:80 -v /srv/web:/usr/share/nginx/html:ro docker.io/library/nginx:1.29-alpine

A running container proves very little on its own. Check all three requirements: the port answers, the restart policy is set, and the log options reached this container:

curl -s http://localhost:8081
sudo docker inspect web --format '{{.HostConfig.RestartPolicy.Name}} {{json .HostConfig.LogConfig.Config}}'

Each part checks out:

hello from a container
unless-stopped {"max-file":"3","max-size":"10m"}

Order matters here. Log options in daemon.json only apply to containers created after the daemon restart, so a container started before the change keeps its old logging until you recreate it. If a task gives you an existing container, remove it and run it again after the daemon change, otherwise the inspect output will show the old settings.

Task 6: Create a libvirt VM and change its memory

Task: define a VM called vm1 with 512 MB of RAM on the default network, mark it to start at boot, then raise its maximum memory to 1 GiB with 768 MiB assigned. Our node01 has no /dev/kvm, so we passed --virt-type qemu for software emulation. On hardware with KVM you leave that flag out.

sudo apt-get install -y --no-install-recommends qemu-system-x86 qemu-utils libvirt-daemon-system libvirt-clients virtinst dnsmasq-base
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/vm1.qcow2 2G
sudo virt-install --name vm1 --memory 512 --vcpus 1 --disk /var/lib/libvirt/images/vm1.qcow2,bus=virtio --import --os-variant generic --network network=default --virt-type qemu --graphics none --noautoconsole

That install line is the consolidated form of what we added to node01 over several runs. Keep dnsmasq-base on it. It is only a recommended package of libvirt, and the default network needs it for DHCP, so dropping recommends without it leaves the network inactive. Our node01 already had it from the Docker packages in Task 5. Our first run did not have qemu-utils, so qemu-img failed with command not found and there was no disk to import. With the package installed and the disk in place, the domain is created and running. The warning only says that a generic OS type gets generic virtual hardware:

WARNING  Using --osinfo generic, VM performance may suffer. Specify an accurate OS for optimal results.

Starting install...
Creating domain...                                          |    0 B  00:00
Domain creation completed.

Set autostart, then stop the VM and change the memory in its saved configuration. setmaxmem has to come first, because the assigned memory can never exceed the maximum and libvirt rejects the change in the other order:

sudo virsh autostart vm1
sudo virsh destroy vm1
sudo virsh setmaxmem vm1 1G --config
sudo virsh setmem vm1 768M --config
sudo virsh start vm1
sudo virsh dumpxml vm1 --inactive | grep -iE "<memory|currentMemory"

The saved definition holds both values:

  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>786432</currentMemory>

Two things in our run will confuse you if you practice with an empty disk like we did. virsh dominfo on the running VM still reported 1048576 KiB used, because with no guest operating system there is no balloon driver to hand memory back. virsh shutdown vm1 also left it running, since a graceful shutdown asks the guest to power off and nothing was listening. Use virsh destroy for a hard stop, and keep our virsh commands cheat sheet nearby for the rest of the domain commands.

Task 7: Recover from a bad fstab line and check a filesystem

Task: someone added a broken entry to /etc/fstab. Find it before it breaks a boot, remove it, then run a full check of the ext4 filesystem on /dev/datavg/applv (built in Task 15). We added a bad line on purpose and asked findmnt to validate the file:

echo 'UUID=0000-bad /srv/missing ext4 defaults 0 2' | sudo tee -a /etc/fstab
sudo findmnt --verify 2>&1 | tail -4

findmnt names the unreachable source and reminds you that systemd still runs on the old copy:

   [E] unreachable on boot required target: No such file or directory
   [E] unreachable on boot required source: UUID=0000-bad
   [W] your fstab has been modified, but systemd still uses the old version;
       use 'systemctl daemon-reload' to reload

Why does one bad line matter so much? A required mount that cannot be found drops the boot into emergency mode, and on a remote node with no console that is the hardest outcome to fix. Delete the line, reload systemd, then unmount and check the filesystem. If umount reports the target as busy, sudo lsof +D /srv/appdata names the process holding it. e2fsck must never run on a mounted filesystem, because it would repair structures the kernel is still writing to:

sudo sed -i '/0000-bad/d' /etc/fstab
sudo systemctl daemon-reload
sudo umount /srv/appdata
sudo e2fsck -f -y /dev/datavg/applv
sudo mount /srv/appdata && findmnt -no SOURCE,TARGET /srv/appdata

All five passes came back clean and the volume is mounted again:

e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
appdata: 11/786432 files (0.0% non-contiguous), 73424/3145728 blocks
/dev/mapper/datavg-applv /srv/appdata

The Operations Deployment domain also lists SELinux. Ubuntu ships AppArmor rather than SELinux, so we did not run an SELinux task on these hosts. Practice it on a Red Hat family VM instead: Task 20 on the RHCSA practice page walks through ports, contexts and booleans with enforcing mode on.

Part 2: Networking tasks

Networking is the other quarter of the score, and it is where a single typo can cut you off from the host you are working on. Every task in this part was done over SSH, so each one also had to keep port 22 reachable. If you practice the same way, you will feel that risk on every change, which is the point.

Task 8: Set the hostname and resolve a peer by name

Task: set the static hostname of node01 to node01.lab.example.com and make nas01 resolve to 10.128.15.192 without DNS.

sudo hostnamectl set-hostname node01.lab.example.com
echo '10.128.15.192 nas01.lab.example.com nas01' | sudo tee -a /etc/hosts
getent hosts nas01

getent follows the same lookup order as every program on the box, so it is a better check than dig, which only asks DNS and would miss the hosts file entirely:

10.128.15.192   nas01.lab.example.com nas01

hostnamectl set-hostname writes /etc/hostname, so the name is persistent by itself. The reboot in Part 6 confirms it stayed on node01. On other cloud images, check that cloud-init is not set to rewrite the hostname at boot before you trust that.

Task 9: Serve time from nas01 and sync node01 to it

Task: make nas01 an NTP server for 10.128.0.0/9, point node01 at it as the preferred source, and set the node01 time zone to Africa/Nairobi. On nas01, the allow rule goes in a drop-in:

echo 'allow 10.128.0.0/9' | sudo tee /etc/chrony/conf.d/lfcs-allow.conf
sudo systemctl restart chrony

Back on node01, set the zone and add the source in its own drop-in:

sudo timedatectl set-timezone Africa/Nairobi
echo 'server nas01.lab.example.com iburst prefer' | sudo tee /etc/chrony/sources.d/lfcs.sources
sudo chronyc reload sources

This looked finished, but chronyc sources still listed only the cloud metadata server. The stock Ubuntu chrony.conf includes both directories, but the one on our cloud image had been replaced by the image builder and contains neither a confdir nor a sourcedir line, so both drop-in directories were silently ignored. Check for the include lines before you trust a drop-in:

grep -cE '^(confdir|sourcedir)' /etc/chrony/chrony.conf

A count of 2 or more means the stock file is in place and nothing needs adding. A count of 0 means you have to add the include yourself. Append confdir /etc/chrony/conf.d to chrony.conf on nas01 and sourcedir /etc/chrony/sources.d on node01, restart chrony on both, and look at the sources again:

chronyc sources
chronyc tracking | grep -E 'Reference ID|Stratum|Leap status'

The asterisk marks nas01 as the selected source, and node01 now sits one stratum below it:

chronyc sources showing nas01 selected as the time source with stratum 4 tracking

Reach is an octal record of the last eight polls, so 17 means the last four all got answers. Leap status : Normal means the clock is synchronised. If nas01 shows a ? instead, the server is not answering, and on a host with a default drop firewall that usually means UDP 123 is closed. Task 11 opens it on nas01.

Task 10: Harden the SSH server and set up key logins

Task: on nas01, make sshd listen on ports 22 and 2222, refuse root logins and allow only kibet and deploy. On node01, let kibet run ssh nas01 as deploy on port 2222 with a key. Finally, turn password logins off. The deploy account has to exist on nas01 with a password before anything else, because ssh-copy-id logs in with it once:

sudo useradd -m -s /bin/bash deploy
sudo passwd deploy

Then write the server drop-in. AllowUsers is a whitelist, so put the name you are logged in as in it too. Ours was kibet, and yours may not be:

sudo vim /etc/ssh/sshd_config.d/50-lfcs.conf

Password logins stay on for now so ssh-copy-id can install the key. Turning them off first would leave you no way to copy it:

Port 22
Port 2222
PermitRootLogin no
PasswordAuthentication yes
AllowUsers kibet deploy

The file name is deliberate. The Ubuntu cloud image already ships 50-cloudimg-settings.conf and 60-cloudimg-settings.conf, and the 60 file holds PasswordAuthentication no. sshd keeps the first value it reads for each keyword and loads drop-ins in lexical order, so any name below 60 wins that keyword. sudo sshd -T printed passwordauthentication yes after our file went in. Before you restart anything, open a second SSH session to nas01 and leave it alone: a restart keeps established connections, so that session is your way back if the new settings lock you out. Test the syntax, then restart the socket, because Ubuntu 24.04 starts sshd through ssh.socket and the listening ports belong to it:

sudo sshd -t && echo syntax-ok
sudo systemctl daemon-reload
sudo systemctl restart ssh.socket
sudo ss -tlnp | grep -E ':(22|2222) '

systemd now listens on both ports for IPv4 and IPv6, which is the socket activation at work:

syntax-ok
LISTEN 0      4096         0.0.0.0:22        0.0.0.0:*    users:(("systemd",pid=1,fd=68))
LISTEN 0      4096         0.0.0.0:2222      0.0.0.0:*    users:(("systemd",pid=1,fd=66))
LISTEN 0      4096            [::]:22           [::]:*    users:(("systemd",pid=1,fd=69))
LISTEN 0      4096            [::]:2222         [::]:*    users:(("systemd",pid=1,fd=67))          

Switch to the client side next. Create a key and copy it to deploy on port 2222, which asks for the deploy password once. Then write a client entry so the short name carries the user and port:

ssh-keygen -q -t ed25519 -N '' -f ~/.ssh/id_ed25519 -C kibet@node01
ssh-copy-id -o StrictHostKeyChecking=accept-new -p 2222 deploy@nas01
vim ~/.ssh/config

The client entry maps the alias to the full name, user, port and key:

Host nas01
    HostName nas01.lab.example.com
    User deploy
    Port 2222
    IdentityFile ~/.ssh/id_ed25519

Our first ssh nas01 after this failed with Host key verification failed. The key was right and known_hosts was not. ssh-copy-id had stored the host key as [nas01]:2222, while the config now sends ssh to nas01.lab.example.com, which had no entry. Record the key under the name ssh actually uses:

chmod 600 ~/.ssh/config
ssh-keyscan -p 2222 -t ed25519 nas01.lab.example.com >> ~/.ssh/known_hosts
ssh nas01 'whoami; hostname'

The alias now lands as deploy on nas01:

deploy
nas01.lab.example.com

Only now is it safe to turn passwords off. Over on nas01, change the drop-in to PasswordAuthentication no, run sudo sshd -t, then sudo systemctl reload ssh. A forced password attempt from node01 proves the lock:

ssh -o PubkeyAuthentication=no -o PreferredAuthentications=password -p 2222 [email protected] true

The server no longer even offers a password prompt, while ssh nas01 with the key still works:

[email protected]: Permission denied (publickey).

Keep that second session open until the key login has worked from a fresh terminal. Close it any earlier, and one typo in AllowUsers means console access is the only way back in.

Task 11: Filter, NAT and redirect ports with nftables

Task: on nas01, drop inbound traffic except SSH, ICMP, NTP and NFS from the lab range. Masquerade a private 192.168.100.0/24 network out through ens4, and redirect TCP 8088 to the local web server on port 80. nas01 already serves a one line page on port 80: install the Ubuntu nginx package and put the words backend nas01 in /var/www/html/index.html, which Task 14 reuses. The private network is a network namespace with a veth pair:

sudo ip netns add lab
sudo ip link add veth-host type veth peer name veth-lab
sudo ip link set veth-lab netns lab
sudo ip addr add 192.168.100.1/24 dev veth-host
sudo ip link set veth-host up
sudo ip netns exec lab ip addr add 192.168.100.2/24 dev veth-lab
sudo ip netns exec lab ip link set veth-lab up
sudo ip netns exec lab ip link set lo up
sudo ip netns exec lab ip route add default via 192.168.100.1

Forwarding must be on for NAT to work, so persist it the same way as Task 1 with net.ipv4.ip_forward = 1 in /etc/sysctl.d/90-forward.conf. Even with forwarding on, a ping from the namespace to node01 lost every packet, because nothing translated the 192.168.100.2 source address and node01 had no way to reply. Back up the stock ruleset and write the new one:

sudo cp /etc/nftables.conf /etc/nftables.conf.orig
sudo vim /etc/nftables.conf

We kept everything in one table of our own instead of the flush ruleset line the stock file starts with:

#!/usr/sbin/nft -f

table inet lfcs
delete table inet lfcs

table inet lfcs {
    chain input {
        type filter hook input priority filter; policy drop;
        ct state established,related accept
        ct state invalid drop
        iif "lo" accept
        meta l4proto { icmp, ipv6-icmp } accept
        tcp dport { 22, 2222 } accept
        ct status dnat accept
        ip saddr 10.128.0.0/9 udp dport 123 accept
        ip saddr 10.128.0.0/9 tcp dport 2049 accept
    }

    chain forward {
        type filter hook forward priority filter; policy drop;
        ct state established,related accept
        iifname "veth-host" oifname "ens4" accept
    }

    chain prerouting {
        type nat hook prerouting priority dstnat; policy accept;
        tcp dport 8088 redirect to :80
    }

    chain postrouting {
        type nat hook postrouting priority srcnat; policy accept;
        ip saddr 192.168.100.0/24 oifname "ens4" masquerade
    }
}

The first two lines make the file safe to load again. They create the table if it is missing and then delete it, so the full definition always starts clean. flush ruleset would also wipe tables that other software owns: our nft list tables on node01 showed ip nat, ip filter and ip raw tables that Docker created, and flushing those breaks container networking. The own table only protects them on load and reload, though: the Ubuntu nftables unit runs nft flush ruleset when it stops, so after the first start use systemctl reload nftables and never restart. Check the syntax and enable the service:

sudo nft -c -f /etc/nftables.conf && echo config-ok
sudo systemctl enable --now nftables

Then test each rule from the side that uses it: the namespace ping for masquerade, port 8088 for the redirect, and port 80 for the drop policy:

nftables redirect rule from port 8088 to 80 and a masqueraded ping from a network namespace

Port 8088 returns the page while port 80 times out with curl exit code 28, which is the drop policy doing its job. Why does the redirected request still get through? After the redirect, the destination of the packet is port 80, and without ct status dnat accept the input chain would drop it like any other port 80 packet. The ping replies with ttl 63 confirm one routed hop through nas01, with the source address rewritten on the way out.

Task 12: Add a persistent static route

Task: on node01, route 192.168.100.0/24 through nas01 (10.128.15.192) and keep it across reboots. Before the change, ask the kernel which way it would send that range today:

ip route get 192.168.100.2

The answer is the VPC gateway, 10.128.0.1:

192.168.100.2 via 10.128.0.1 dev ens4 src 10.128.0.62 uid 1002
    cache 

Netplan merges every YAML file in /etc/netplan/, so a separate file can add the route without touching the config the cloud image generated:

sudo vim /etc/netplan/60-static-route.yaml

Our cloud network hands each VM a /32 address and routes everything through its gateway, so node01 has no connected route to nas01. The route needs on-link to tell the kernel the next hop is reachable directly on ens4 anyway:

network:
  version: 2
  ethernets:
    ens4:
      routes:
        - to: 192.168.100.0/24
          via: 10.128.15.192
          on-link: true

Netplan warns about files other users can read, so tighten the mode before applying:

sudo chmod 600 /etc/netplan/60-static-route.yaml
sudo netplan apply
ip route show 192.168.100.0/24
ip route get 192.168.100.2

The route is installed as static and the lookup now goes through nas01:

192.168.100.0/24 via 10.128.15.192 dev ens4 proto static onlink
192.168.100.2 via 10.128.15.192 dev ens4 src 10.128.0.62 uid 1002
    cache 

Be honest with yourself about what this proves. We verified the routing decision, not traffic through nas01: on a cloud network that also needs the provider’s own route and IP forwarding settings, while on a flat LAN or a homelab bridge the route alone is enough. ip route get is the check that tells you your part is right.

Task 13: Bond two interfaces in active-backup mode

Task: create bond0 from two interfaces in active-backup mode with dummy0 as primary and address 192.168.50.10/24. Our VM has one NIC, so we used netplan dummy devices as the two members:

sudo vim /etc/netplan/70-bond0.yaml

Swap dummy0 and dummy1 for real interface names on hardware, and nothing else changes:

network:
  version: 2
  bonds:
    bond0:
      interfaces: [dummy0, dummy1]
      addresses: [192.168.50.10/24]
      parameters:
        mode: active-backup
        primary: dummy0
        mii-monitor-interval: 100
  dummy-devices:
    dummy0: {}
    dummy1: {}

Apply it and read the bonding driver’s own view of the bond, which is more trustworthy than any config file:

sudo chmod 600 /etc/netplan/70-bond0.yaml
sudo netplan apply
grep -E 'Bonding Mode|Currently Active|MII Status' /proc/net/bonding/bond0

The bond is up with dummy0 active:

Bonding Mode: fault-tolerance (active-backup)
Currently Active Slave: dummy0
MII Status: up
MII Status: up
MII Status: up

A bond is only proven when it fails over. We took dummy0 down and Currently Active Slave changed to dummy1. Bringing dummy0 back up returned the role to dummy0 within a second, because it is the primary. Run sudo ip link set dummy0 down and up yourself and grep the same file in between, so you have seen both states before anyone asks you to.

Task 14: Put nginx in front of two backends

Task: on node01, answer for app.lab.example.com on port 80 and balance requests across nas01 port 8088 and the container on local port 8081, passing the client address through. Write a new server block and disable the default site:

sudo vim /etc/nginx/conf.d/app.conf

The upstream block holds the pool, and the headers tell the backends who really asked:

upstream app_pool {
    server nas01.lab.example.com:8088;
    server 127.0.0.1:8081;
}

server {
    listen 80;
    server_name app.lab.example.com;

    location / {
        proxy_pass http://app_pool;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Test the configuration, enable nginx, reload it, and send a batch of requests with the right Host header:

sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled
sudo nginx -t
sudo systemctl enable --now nginx; sudo systemctl reload nginx
for i in $(seq 1 8); do curl -s -H 'Host: app.lab.example.com' http://127.0.0.1/; done | sort | uniq -c

Eight requests split evenly between the two backends:

      4 backend nas01
      4 hello from a container

Do not judge round robin on four requests. Our first test of four all came back from nas01, which looked like a broken pool. This VM has two CPUs and nginx runs a worker per CPU, and without a zone directive in the upstream block each worker keeps its own run time state. Short bursts can therefore land unevenly, so send at least eight requests before you decide anything is wrong.

Part 3: Storage tasks

Storage is a fifth of the score, and every storage task ends with an fstab entry or an automounter map. Those files are read at boot, so a mistake in them does not show up until a reboot, which is why Task 7 matters so much. Test every entry with the same command boot uses, and you will never meet that mistake at the worst moment.

Task 15: Create a logical volume and grow it online

Task: build volume group datavg on /dev/sdb, create a 6 GB ext4 logical volume applv labelled appdata, mount it persistently on /srv/appdata, then grow it by 6 GB without unmounting. The UUID in fstab keeps the entry valid even if the device names change:

sudo pvcreate /dev/sdb
sudo vgcreate datavg /dev/sdb
sudo lvcreate -n applv -L 6G datavg
sudo mkfs.ext4 -q -L appdata /dev/datavg/applv
sudo mkdir -p /srv/appdata
echo "UUID=$(sudo blkid -s UUID -o value /dev/datavg/applv) /srv/appdata ext4 defaults 0 2" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload; sudo mount -a
df -h /srv/appdata

mount -a reads fstab exactly as boot does, so a clean mount here is your proof the entry is valid:

Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/datavg-applv  5.9G   24K  5.6G   1% /srv/appdata

The first grow attempt failed, which is the realistic version of this task. A 10 GB disk minus a 6 GB volume leaves about 4 GB, so the volume group had to grow before the volume could. lvextend -r resizes the filesystem in the same step:

sudo lvextend -r -L +6G datavg/applv
sudo vgextend datavg /dev/sdc
sudo lvextend -r -L +6G datavg/applv
sudo vgs datavg; sudo lvs datavg
df -h /srv/appdata

The first lvextend refuses for lack of extents, and the second one, after vgextend, grows the volume and the filesystem together:

lvextend failing with insufficient free space, then succeeding after vgextend adds a second disk

vgextend initialised /dev/sdc as a physical volume by itself, so no separate pvcreate was needed. resize2fs then grew the mounted ext4 filesystem online, and df shows 12G without a remount. If you forget -r, the volume grows but the filesystem does not, and df keeps showing the old size. Run sudo resize2fs /dev/datavg/applv afterwards to finish the job.

Task 16: Add swap on a volume and a swap file with priorities

Task: add 2 GB of swap on a logical volume at priority 10 and a 1 GB swap file at priority 5, both active at boot.

sudo lvcreate -n swaplv -L 2G datavg
sudo mkswap -L swap0 /dev/datavg/swaplv
sudo fallocate -l 1G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile
echo '/dev/datavg/swaplv none swap defaults,pri=10 0 0' | sudo tee -a /etc/fstab
echo '/swapfile none swap defaults,pri=5 0 0' | sudo tee -a /etc/fstab
sudo swapon -a
swapon --show

swapon -a activates everything listed in fstab, which tests the entries the way boot will:

NAME      TYPE       SIZE USED PRIO
/dev/dm-1 partition    2G   0B   10
/swapfile file      1024M   0B    5

The kernel uses the higher priority first, so the volume fills before the file. The chmod 600 is not decoration either. A swap file can hold pieces of any process memory, so mkswap and swapon both warn about one that other users can read, and a grader may check the mode.

Task 17: Export a directory over NFS and mount it at boot

Task: on nas01, export /srv/nfs/share read write and /srv/nfs/projects read only to the lab range. On node01, mount the share on /mnt/share at boot.

sudo apt-get install -y nfs-kernel-server
sudo mkdir -p /srv/nfs/share /srv/nfs/projects/alpha /srv/nfs/projects/beta
echo 'shared file' | sudo tee /srv/nfs/share/README
echo 'alpha notes' | sudo tee /srv/nfs/projects/alpha/notes.txt
sudo chown -R nobody:nogroup /srv/nfs/share
sudo vim /etc/exports

The two small files give the client something to read in this task and in Task 18. Write one line per export, with the client range and options in brackets and no space before them. A space there turns the options into a second export for every host, and with rw in it that share becomes world writable:

/srv/nfs/share     10.128.0.0/9(rw,sync,no_subtree_check)
/srv/nfs/projects  10.128.0.0/9(ro,sync,no_subtree_check)

Reload the export table and read the effective options:

sudo exportfs -ra
sudo exportfs -v

The output shows the defaults you did not type, including root_squash, which maps a remote root user to nobody:

/srv/nfs/share	10.128.0.0/9(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/srv/nfs/projects
		10.128.0.0/9(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)

The client side needs the NFS tools and one fstab line. _netdev tells systemd to wait for the network before mounting, so the boot does not stall on a share it cannot reach yet:

sudo apt-get install -y nfs-common autofs
sudo mkdir -p /mnt/share
echo 'nas01:/srv/nfs/share /mnt/share nfs4 defaults,_netdev 0 0' | sudo tee -a /etc/fstab
sudo systemctl daemon-reload; sudo mount /mnt/share
findmnt /mnt/share -o TARGET,SOURCE,FSTYPE

The share is mounted over NFSv4:

TARGET     SOURCE               FSTYPE
/mnt/share nas01:/srv/nfs/share nfs4

Before mounting, we tried showmount -e nas01 and it hung until our 15 second timeout killed it. That was the firewall from Task 11, which opens TCP 2049 only. NFSv4 needs nothing else, but showmount talks to rpcbind and mountd, which NFSv4 clients never use, so a failed showmount does not mean the export is broken. For a deeper NFS setup with SELinux and autofs on a Red Hat family system, see NFS Server and Client on Fedora.

Task 18: Automount project directories on demand

Task: on node01, any directory under /projects mounts the matching directory from nas01:/srv/nfs/projects read only when someone touches it, and unmounts after 60 idle seconds. autofs reads a master map that points at a map file:

echo '/projects  /etc/auto.projects  --timeout=60' | sudo tee /etc/auto.master.d/projects.autofs
echo '*  -ro,fstype=nfs4  nas01:/srv/nfs/projects/&' | sudo tee /etc/auto.projects
sudo systemctl restart autofs

The * key and the & in the location make it a wildcard map: whatever name you ask for is substituted into the server path. Test it by reading a file, not by listing the parent:

ls /projects
cat /projects/alpha/notes.txt
mount | grep /projects/alpha

ls /projects printed nothing, then the file read triggered the mount:

alpha notes
nas01:/srv/nfs/projects/alpha on /projects/alpha type nfs4 (ro,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,fatal_neterrors=none,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.128.0.62,local_lock=none,addr=10.128.15.192)

An empty /projects is correct behaviour. A wildcard map cannot know which keys exist until someone asks for one, so the directory looks empty until the first access. Plenty of people decide autofs is broken at this point and start editing a map that was already right, so read a path through it before you change anything.

Task 19: Find which disk is busy

Task: report the I/O scheduler on sdb and show which of the two data disks is doing the work during a large write. iostat comes from the sysstat package:

sudo apt-get install -y sysstat
cat /sys/block/sdb/queue/scheduler
(sudo dd if=/dev/zero of=/srv/appdata/ddtest bs=1M count=1500 oflag=direct status=none &) ; iostat -dxm sdb sdc 3 2 | tail -5

The bracketed scheduler is the active one, and the extended stats put all the writes on sdb:

[none] mq-deadline
Device            r/s     rMB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wMB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dMB/s   drqm/s  %drqm d_await dareq-sz     f/s f_await  aqu-sz  %util
sdb              0.00      0.00     0.00   0.00    0.00     0.00  505.67    126.18     2.67   0.52    4.35   255.52    0.00      0.00     0.00   0.00    0.00     0.00    0.33    0.00    2.20  93.67
sdc              0.00      0.00     0.00   0.00    0.00     0.00    0.33      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.33    0.00    0.00   0.00

sdb ran at about 126 MB/s and 94% utilisation while sdc sat idle, even though applv now spans both disks. A linear logical volume fills its first physical volume before it touches the second, so a test file on a mostly empty volume lands on sdb. Read %util together with w_await: high utilisation with a low wait time on a virtual disk means the disk is busy, not that it is failing. Remove the test file with sudo rm -f /srv/appdata/ddtest when you are done.

Part 4: Essential commands tasks

Essential Commands sounds like the easy domain, but its competencies are the ones you use when something is already wrong: version control, service limits, missing disk space and certificates.

Task 20: Clone, branch, merge and push with Git

Task: nas01 hosts an empty bare repository at /srv/git/ops.git, created with git init --bare -b main and owned by deploy, since the nas01 SSH alias from Task 10 logs in as deploy and every push writes as that user. On a fresh nas01 that setup is sudo mkdir -p /srv/git && sudo git init --bare -b main /srv/git/ops.git && sudo chown -R deploy:deploy /srv/git/ops.git. Clone it on node01, commit a file to main, do a change on a feature branch, merge it with a merge commit, and push.

git config --global user.name 'Kibet John'; git config --global user.email [email protected]
git clone nas01:/srv/git/ops.git ~/ops
git -C ~/ops branch --show-current

This is where our first attempt went wrong. The clone came out on master, not main:

warning: You appear to have cloned an empty repository.
master

Over SSH, Ubuntu’s sshd does not pass the GIT_PROTOCOL variable, so git falls back to the old protocol, which cannot report the unborn HEAD of an empty repository. The clone then uses your local default branch name, whatever the server was created with. Over protocol v2 (https, or SSH with that variable accepted) a current git would check out main. Our first run committed and pushed to main straight away and got error: src refspec main does not match any, because there was no local main to push. Rename the branch after the first commit, then push with upstream tracking:

cd ~/ops && echo 'vm.swappiness = 10' > sysctl.conf && git add sysctl.conf && git commit -q -m 'Add sysctl baseline'
git branch -m main && git push -u origin main

Then branch, commit, switch back and merge with --no-ff. That flag keeps a merge commit even though main has not moved, so the history shows the feature branch existed:

git switch -c feature/motd && echo 'Authorized use only' > motd && git add motd && git commit -q -m 'Add login banner'
git switch -q main && git merge --no-ff -q -m 'Merge feature/motd' feature/motd
git log --oneline --graph

The graph shows the branch and the merge:

*   2033217 Merge feature/motd
|\
| * 2cd2892 Add login banner
|/
* 725f743 Add sysctl baseline

Push main again and check the server side rather than trusting the push message. ssh nas01 'git -C /srv/git/ops.git log --oneline main' returned the same three commits. That is the proof a grader would look for, since the grader reads the bare repository and not your clone.

Task 21: Limit the memory, files and tasks of a service

Task: without editing the unit file, cap the heartbeat service from Task 2 at 64 MB of memory, 2048 open files and 20 tasks. A drop-in directory named after the unit keeps your change separate from the original, so a package update to the unit never overwrites it:

sudo mkdir -p /etc/systemd/system/heartbeat.service.d
sudo vim /etc/systemd/system/heartbeat.service.d/limits.conf

The drop-in only needs the section and the three settings:

[Service]
MemoryMax=64M
LimitNOFILE=2048
TasksMax=20

Reload, restart and compare the effective values before and after, then confirm the running process really got the file limit:

sudo systemctl daemon-reload
sudo systemctl restart heartbeat.service
systemctl show heartbeat.service -p MemoryMax -p LimitNOFILE -p TasksMax
grep 'open files' /proc/$(systemctl show -p MainPID --value heartbeat.service)/limits

The capture below also has the values from before the drop-in, for comparison:

systemctl show output before and after a drop-in sets MemoryMax, LimitNOFILE and TasksMax on a service

systemd reports MemoryMax in bytes, so 67108864 is the 64M you wrote. The /proc/<pid>/limits line matters more than systemctl show, because it is what the kernel enforces on the process. A daemon-reload without a restart would have changed the first output but not the second, since limits are applied when the process starts. systemctl cat heartbeat.service lists the unit followed by every drop-in, which is the fastest way to see what is in force.

Task 22: Find disk space that du cannot see

Task: /srv/appdata reports 3.1G used, but the files in it add up to almost nothing. Find the space and free it without restarting anything. We set this up by deleting a 3 GB log while a tail -f process still had it open, which is the same thing a logging daemon does when someone deletes its log by hand. Compare the two views, find the holder, and truncate the file through its descriptor:

df -h /srv/appdata
sudo du -sh /srv/appdata
sudo lsof +L1 /srv/appdata
sudo truncate -s 0 /proc/$(sudo lsof -t +L1 /srv/appdata)/fd/3
df -h /srv/appdata
df -i /srv/appdata

The fd number comes from the FD column of the lsof output, so read it there before you copy the truncate line:

df and du disagree until lsof +L1 finds a deleted file still held open by tail

df counts blocks the filesystem has allocated, and du counts files it can find by name. A deleted file that a process still holds has no name but keeps its blocks, so the two disagree. lsof +L1 lists open files with a link count below 1, which is exactly that case. Truncating through /proc/<pid>/fd/3 released the 3 GB without killing tail.

Restarting the process works too, but on a production box that is often not your call. In the lab, stop the leftover tail with sudo kill $(sudo lsof -t +L1 /srv/appdata) afterwards, or a later umount of the volume fails as busy. The df -i check at the end rules out the other classic cause, inode exhaustion, which makes a disk refuse new files while it still shows free space. If you ever see “No space left on device” with plenty of free gigabytes, run df -i before anything else.

Task 23: Create a certificate and serve HTTPS

Task: create a self signed RSA certificate for app.lab.example.com, valid for one year with the name and the IP 10.128.0.62 as subject alternative names. Serve the Task 14 pool over HTTPS with it. Modern clients ignore the common name, so the SAN extension is what makes the certificate usable:

sudo openssl req -x509 -newkey rsa:3072 -sha256 -days 365 -nodes -keyout /etc/ssl/private/app.key -out /etc/ssl/certs/app.crt -subj '/CN=app.lab.example.com/O=LFCS Lab' -addext 'subjectAltName=DNS:app.lab.example.com,IP:10.128.0.62'
sudo chmod 600 /etc/ssl/private/app.key
openssl x509 -in /etc/ssl/certs/app.crt -noout -subject -enddate -ext subjectAltName

The certificate carries both SAN entries and expires a year out:

subject=CN = app.lab.example.com, O = LFCS Lab
notAfter=Nov 23 02:24:17 2027 GMT
X509v3 Subject Alternative Name:
    DNS:app.lab.example.com, IP Address:10.128.0.62

Two more checks answer the questions you are most likely to get about certificates. openssl x509 -noout -checkend 2592000 exits 0 when the certificate is still valid 30 days from now, so it drops straight into a monitoring script. Comparing the public key hashes proves the key and the certificate belong together:

sudo openssl pkey -in /etc/ssl/private/app.key -pubout | sha256sum; openssl x509 -in /etc/ssl/certs/app.crt -noout -pubkey | sha256sum

Identical hashes mean a matching pair:

5cbbf1c5168fd479f61a9fbf199b1353ddbdae00a6ebd09e4647ff8f0e9f5898  -
5cbbf1c5168fd479f61a9fbf199b1353ddbdae00a6ebd09e4647ff8f0e9f5898  -

Add a TLS server block to the end of /etc/nginx/conf.d/app.conf. It reuses the same upstream, so both ports serve one pool:

server {
    listen 443 ssl;
    server_name app.lab.example.com;
    ssl_certificate     /etc/ssl/certs/app.crt;
    ssl_certificate_key /etc/ssl/private/app.key;

    location / {
        proxy_pass http://app_pool;
    }
}

Test, reload, and call it once without and once with the certificate as a trusted CA:

sudo nginx -t && sudo systemctl reload nginx
curl -s https://app.lab.example.com/ --resolve app.lab.example.com:443:127.0.0.1; echo "exit=$?"
curl -s --cacert /etc/ssl/certs/app.crt https://app.lab.example.com/ --resolve app.lab.example.com:443:127.0.0.1

Exit code 60 is curl refusing an untrusted certificate, and the second call succeeds through the pool:

exit=60
backend nas01

Resist the urge to “fix” the first call with curl -k. A self signed certificate is supposed to fail until a client trusts it, and the trusted call is the better proof, because it only succeeds when both the chain and the name match.

Task 24: Find a CPU hog, lower its priority and stop it

Task: a process is eating a full CPU. Identify it, drop it to nice 15, then terminate it. We started yes > /dev/null as kibet to play the culprit:

ps -eo pid,user,ni,%cpu,comm --sort=-%cpu | head -3
sudo renice -n 15 -p $(pgrep -x yes)
ps -o pid,ni,stat,comm -p $(pgrep -x yes)

The process tops the list, then shows the new nice value and the N flag in its state:

    PID USER      NI %CPU COMMAND
  11234 kibet      0 99.7 yes
  11176 kibet      0  2.5 systemd
11234 (process ID) old priority 0, new priority 15
    PID  NI STAT COMMAND
  11234  15 RN   yes

Stop it with pkill -x yes. The -x matches the exact process name, so it cannot hit a process that merely contains “yes”, and pgrep -x yes afterwards confirms nothing is left. Be careful with pkill -f on patterns that also appear in your own shell command, because it matches full command lines and can kill the shell running it.

Part 5: Users and groups tasks

Users and Groups is only 10% of the score, but these tasks depend on each other. The group from Task 25 owns the directory in Task 27, and the limits in Task 26 apply to the same group, so build them in order. If you skip ahead, the later checks fail for reasons that have nothing to do with the task you are on.

Task 25: Create users, a group and password ageing

Task: create group devops with GID 3000. Create anna with UID 2001 as a member of devops, an account expiry of 30 June 2027, passwords valid for 90 days and a 14 day warning. Add a system account svcbackup that cannot log in. Finally, lock and unlock the password for anna.

sudo groupadd -g 3000 devops
sudo useradd -m -u 2001 -G devops -s /bin/bash -c 'Anna Wanjiru' -e 2027-06-30 anna
sudo passwd anna
sudo chage -M 90 -W 14 anna
sudo useradd -r -s /usr/sbin/nologin -d /var/lib/svcbackup -m svcbackup
sudo chage -l anna

chage -l shows the account expiry from useradd and the ageing from chage together:

Last password change					: Nov 23, 2026
Password expires					: Feb 21, 2027
Password inactive					: never
Account expires						: Jun 30, 2027
Minimum number of days between password change		: 0
Maximum number of days between password change		: 90
Number of days of warning before password expires	: 14

Check the identities and the lock state next:

id anna; id svcbackup
sudo usermod -L anna && sudo passwd -S anna && sudo usermod -U anna && sudo passwd -S anna

The second field of passwd -S flips from L for locked to P for a usable password:

uid=2001(anna) gid=2001(anna) groups=2001(anna),3000(devops)
uid=995(svcbackup) gid=987(svcbackup) groups=987(svcbackup)
anna L 2026-11-23 0 90 14 -1
anna P 2026-11-23 0 90 14 -1

svcbackup got UID 995 from the system range because of -r. Note the difference between the two expiry dates: -e disables the whole account on a date, while chage -M only forces a password change. Mixing them up is an easy way to lose marks on a task that otherwise looks finished, because both show up in the same chage -l output.

Task 26: Set resource limits and environment profiles

Task: members of devops get a hard limit of 200 processes, and anna gets a soft limit of 4096 open files. Every login shell records timestamps in history, and anna has an ll alias that applies to nobody else. Each requirement has its own file and scope:

  • /etc/security/limits.d/devops.conf for the limits
  • /etc/profile.d/lfcs.sh for every login shell
  • /home/anna/.bashrc for anna only

Create the limits file first:

sudo vim /etc/security/limits.d/devops.conf

The @ prefix applies a line to a group, and a bare name applies it to one user:

@devops  hard  nproc   200
anna     soft  nofile  4096

Then add the profile script and the alias, and log in fresh as anna to prove all three:

echo 'export HISTTIMEFORMAT="%F %T "' | sudo tee /etc/profile.d/lfcs.sh
echo "alias ll='ls -alF --color=auto'" | sudo tee -a /home/anna/.bashrc
sudo su - anna -c 'ulimit -Hu; ulimit -Sn; echo "HISTTIMEFORMAT=$HISTTIMEFORMAT"'
sudo su - anna -c 'bash -ic "type ll" 2>/dev/null'

The limits come from PAM at login, and the variable and alias come from the shell start files:

200
4096
HISTTIMEFORMAT=%F %T
ll is aliased to `ls -alF --color=auto'

Always test with su -, and the dash is the important part. A plain su keeps your current environment and skips the login profile, so it would show your own values and convince you the files did nothing.

Task 27: Share a directory with ACLs

Task: /srv/projects belongs to group devops, with new files inheriting the group. svcbackup must be able to read everything in it, including future files, but never write. Our first setfacl failed with sudo: setfacl: command not found, because the acl package is not on the Ubuntu cloud image:

sudo apt-get install -y acl
sudo mkdir -p /srv/projects && sudo chgrp devops /srv/projects && sudo chmod 2770 /srv/projects
sudo setfacl -m u:svcbackup:rx /srv/projects
sudo setfacl -d -m g:devops:rwx -d -m u:svcbackup:rx /srv/projects
getfacl -p /srv/projects

The access entries control the directory itself, and the default: entries are templates for anything created inside it:

# file: /srv/projects
# owner: root
# group: devops
# flags: -s-
user::rwx
user:svcbackup:r-x
group::rwx
mask::rwx
other::---
default:user::rwx
default:user:svcbackup:r-x
default:group::rwx
default:group:devops:rwx
default:mask::rwx
default:other::---

A quick test as svcbackup confirmed the read and write boundary. sudo -u svcbackup ls /srv/projects listed plan.txt, and sudo -u svcbackup touch /srv/projects/x was refused. anna had created plan.txt with sudo -u anna touch /srv/projects/plan.txt during our first attempt, while setfacl was still missing. To reproduce that, create it before the two setfacl lines. Then compare the old file with a brand new one, and repair the old one:

sudo getfacl -p /srv/projects/plan.txt | grep -c svcbackup
sudo -u anna touch /srv/projects/report.txt
sudo getfacl -p /srv/projects/report.txt
sudo setfacl -R -m u:svcbackup:rX /srv/projects
sudo getfacl -p /srv/projects/plan.txt | grep svcbackup

The count of 0 on the first line and the inherited entries on report.txt tell the story:

getfacl showing default ACL entries inherited by a new file but missing on an older one

plan.txt was created before the default ACL existed, so it had no svcbackup entry at all. Default ACLs only shape new files. The new report.txt inherited the entries, and its mask cut svcbackup from r-x down to an effective r– because touch creates files without execute bits. The recursive setfacl -R -m u:svcbackup:rX repaired the old file, and the capital X grants execute only on directories, so files stay non executable.

Task 28: Resolve LDAP users and groups through SSSD

Task: nas01 runs OpenLDAP with base dc=lab,dc=example,dc=com and a user ldapuser1 (UID 5001) in group ldapusers (GID 5000). Make node01 resolve that user and create a home directory at first login. We set the server up with the slapd package from the Ubuntu archive and one ldapadd of an LDIF holding the People and Groups units, the group and the user. On nas01, port 389 must be open to the lab range first, so we changed the NFS rule in /etc/nftables.conf to tcp dport { 389, 2049 } accept, then ran nft -c and reloaded nftables.

sudo apt-get install -y sssd-ldap ldap-utils
ldapsearch -x -LLL -H ldap://nas01.lab.example.com -b ou=People,dc=lab,dc=example,dc=com uid
sudo vim /etc/sssd/sssd.conf

The ldapsearch returned uid: ldapuser1, which proves the network path before SSSD is involved. That ordering saves time, because a failure after this point can only be in the SSSD config. The config needs one domain section:

[sssd]
services = nss, pam
domains = lab

[domain/lab]
id_provider = ldap
auth_provider = ldap
ldap_uri = ldap://nas01.lab.example.com
ldap_search_base = dc=lab,dc=example,dc=com
cache_credentials = true

SSSD refuses to start if the file is readable by anyone but root, so set the mode before the restart. The Ubuntu package already lists sss in nsswitch.conf, and pam-auth-update turns on home directory creation:

sudo chmod 600 /etc/sssd/sssd.conf
sudo systemctl restart sssd
grep -E '^(passwd|group):' /etc/nsswitch.conf
sudo pam-auth-update --enable mkhomedir

The lookup order includes sss for both users and groups:

passwd:         files systemd sss
group:          files systemd sss

Resolve the user, then switch to it as root:

getent passwd ldapuser1
id ldapuser1
sudo su - ldapuser1 -c 'pwd; id -gn'

id printed uid=5001(ldapuser1) gid=5000(ldapusers) groups=5000(ldapusers), and the capture below shows the passwd line and the su session that creates the home directory:

getent and su resolving an LDAP user through SSSD with an automatically created home directory

The user exists only in LDAP, yet getent returns a full passwd line and the session lands in a home directory that pam_mkhomedir created on the spot. That proves identity only. Root needs no password for su, and SSSD will not send an LDAP password over an unencrypted channel, so the sssd-ldap manual rules out an ssh password login as ldapuser1 on this plain port 389 setup. Password logins need ldaps:// or StartTLS, with ldap_tls_cacert pointing at the CA that signed the server certificate. Newer SSSD releases also default ldap_id_use_start_tls to true, so on a newer distribution even the getent step can fail until TLS is in place.

Part 6: Reboot and check everything

You cannot reboot the base system during the LFCS exam, which makes a reboot in practice more valuable, not less. It is the only honest test of the persistence you built. We rebooted node01 once all 28 tasks were done and ran nothing but read only checks afterwards:

post-reboot check showing hostname, sysctl values, mounts, swap, static route, services and bond all persisted

Everything came back. That covers the hostname, both sysctl values, the LVM and NFS mounts, both swap areas at their priorities and the static route. All four services, the bond with dummy0 active and the container (restarted by its policy) came back too. systemctl list-timers now shows the next tmpclean run as 02:30 EAT rather than UTC, because OnCalendar follows the local time zone we changed in Task 9.

The one thing that did not survive was the network namespace from Task 11, since ip netns add lives in memory only. That was expected, and it is not part of any graded state. If a task ever asks you for a persistent namespace, you need a systemd unit or a script run at boot to recreate it.

What broke on the first attempt

Most of the useful lessons on this page came from errors, and each one appears above in the task where it happened. Here they are again by message, so you can search for the line on your own screen.

Error: “Insufficient free space: 1536 extents needed, but only 1023 available”

The volume group is out of extents, not the filesystem. Add a physical volume with vgextend, or ask for -l +100%FREE instead of a fixed size, then repeat lvextend -r. Check vgs first so you know which of the two you need.

Error: “Host key verification failed.” after adding an SSH config entry

known_hosts stores keys under the name ssh connects to, so a new HostName or Port in ~/.ssh/config means a lookup under a new name. ssh-keygen -F '[name]:port' shows what is stored. Add the key for the real name with ssh-keyscan, or connect once with StrictHostKeyChecking=accept-new on a network you trust.

Error: “error: src refspec main does not match any”

The branch you are pushing does not exist locally. After cloning an empty repository, git branch --show-current tells you which name you are really on, so rename it with git branch -m main and push with -u.

Error: “sudo: setfacl: command not found”

Minimal and cloud images often skip the acl package even though the filesystem supports ACLs. Install it with apt or dnf and carry on. The same check applies to iostat (sysstat), qemu-img (qemu-utils) and showmount (nfs-common).

Error: “sysctl: permission denied on key” with exit code 0

You ran sysctl -w without root. The value did not change, even though the command echoed the new value and returned success. Use sudo and read the key back with sysctl <key>.

Why do my chrony drop-ins have no effect?

chrony only reads the drop-in folders when chrony.conf names them with confdir and sourcedir lines. The chrony.conf on our cloud image had neither, so allow and server lines in those folders were ignored without any warning. Grep for the include lines before you write a drop-in.

Where to practice next

Time yourself on a second pass. The LFCS allows 2 hours for 17 to 20 tasks, roughly six minutes each, and a single snag like the SSH host key or the ignored chrony drop-in can eat that whole budget. Rebuild the lab from scratch, set a timer per part, and redo any task where you had to look at the solution.

For a different angle on the same skills, the RHCE practice tasks automate many of them with Ansible. If you plan to move into containers next, the CKA practice questions use the same hands-on format on a kubeadm cluster, followed by the CKAD and CKS sets. Our roundup of the best Linux certification books compares the study guides for LFCS, Linux+, LPIC-1 and RHCSA if you want theory alongside the lab.

Linux Foundation and LFCS are trademarks of The Linux Foundation. Linux is a registered trademark of Linus Torvalds. computingforgeeks.com is not affiliated with, endorsed by or sponsored by The Linux Foundation, and these tasks are our own, written from the published domain list and run on our lab.

Keep reading

Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) Ubuntu Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift Build a FHIR MCP Server for MedGemma 2 with Ollama AI Build a FHIR MCP Server for MedGemma 2 with Ollama Run MedGemma 2 Locally with Ollama and FHIR Tool Calling AI Run MedGemma 2 Locally with Ollama and FHIR Tool Calling Install PostgreSQL 17 on Ubuntu 24.04 / 26.04 LTS Databases Install PostgreSQL 17 on Ubuntu 24.04 / 26.04 LTS

Leave a Comment

Press ESC to close