How To

CompTIA Linux+ Practice Questions: XK0-006 Tasks with Answers

These CompTIA Linux+ practice questions train the hands-on half of XK0-006. Each of the 20 tasks is something you type on a real server, with the answer commands and the output we got back. Multiple-choice drills tell you whether you recognise a command, but a task tells you whether you can use it when a service is down and the clock is running.

Original content from computingforgeeks.com - post 192134

The questions follow the five XK0-006 domains, and each answer keeps the real error you hit when you get it wrong, because that error is usually what a performance-based item shows you first. We checked every answer in November 2026 on Rocky Linux 10 and Ubuntu 26.04.

What is on the CompTIA Linux+ XK0-006 exam?

XK0-006 is the current Linux+ version, launched on July 15, 2025, and it mixes multiple-choice items with performance-based tasks that drop you into a simulated terminal. CompTIA publishes the format on its Linux+ certification page, and the domain weights tell you where to spend your lab time:

ItemXK0-006 detail
QuestionsUp to 90, multiple choice and performance-based
Time90 minutes
Passing score720 on a 100 to 900 scale
Recommended experience12 months of hands-on experience with Linux servers, plus CompTIA A+, Network+ or Server+ or comparable knowledge
1. System Management23%
2. Services and User Management20%
3. Security18%
4. Automation, Orchestration, and Scripting17%
5. Troubleshooting22%

Troubleshooting carries 22% on its own, and most of the other domains end in a “why does this not work” moment too. That is why every answer below keeps the failure output next to the fix, so you learn to read the symptom and not just memorise the command. If you still need a study guide to read alongside these tasks, our roundup of the best CompTIA Linux+ books for XK0-006 compares the current editions and says which ones cover the new automation domain properly.

How should you work through these questions?

Read the task, hide the answer, and try it on your own VM before you look, because recognising an answer is a much weaker skill than producing one. You need two throwaway machines, one from the RHEL family and one Ubuntu server, since XK0-006 is vendor-neutral and expects you to know both package worlds. Give the RHEL-family VM a spare 10 GB disk for the storage question. Before you start, check that your lab matches ours:

  • A Rocky Linux or AlmaLinux VM boots with SELinux in Enforcing mode, and getenforce prints Enforcing.
  • An Ubuntu server VM is reachable over SSH with a sudo user.
  • The spare disk shows up as an empty device in lsblk (ours was /dev/sdb).
  • You can open a second SSH session, so an SSH or firewall mistake never locks you out.

Questions without a distro label ran on Rocky Linux. When Ubuntu answers differently, the question says so, and a comparison table near the end collects every difference we hit. If your Rocky VM is brand new, our list of things to do after installing Rocky Linux gets it to a sane baseline first, so leftover defaults do not muddy your results.

Which System Management tasks should you practice?

System Management is the biggest domain at 23%, and it is mostly storage, kernel modules, packages and services. These five tasks cover the moves that come up most in real admin work. You are ready for this domain when each of these is true on your lab VM:

  • A module you load with modprobe is still loaded after a reboot.
  • Your new logical volume mounts from /etc/fstab by UUID.
  • systemctl list-timers shows the next run of a timer you wrote yourself.

Each question below gives the task first, then the reasoning, then the commands and what came back.

Question 1: Load a kernel module now and at every boot

Task. A container host needs the br_netfilter module. Confirm it is not loaded, load it, and make sure it comes back after a reboot. Answer. lsmod shows what is loaded and modprobe loads the module together with its dependencies. Neither survives a reboot on its own, so a one-line file in /etc/modules-load.d/ handles the persistent part.

lsmod | grep -w br_netfilter
sudo modprobe br_netfilter
lsmod | grep -w br_netfilter
echo br_netfilter | sudo tee /etc/modules-load.d/br_netfilter.conf

The first lsmod returned nothing (exit status 1). After modprobe, the module appeared with bridge pulled in as a dependency:

br_netfilter           36864  0
bridge                417792  1 br_netfilter

The 1 br_netfilter on the bridge line is the detail multiple-choice versions of this question lean on. It says bridge is in use by one module, so modprobe -r bridge would refuse until br_netfilter goes first. insmod takes a single .ko file and does not resolve dependencies, which is why modprobe is the right tool here.

Question 2: Create a logical volume, mount it by UUID, then grow it

Task. On the empty disk /dev/sdb, build volume group vgdata with a 2 GiB XFS logical volume lvweb, mount it persistently on /srv/web, and then add 1 GiB without unmounting. Answer. Build the stack from the bottom (physical volume, volume group, logical volume) and format it. Write the fstab entry by UUID, because device names like /dev/sdb can change between boots while the filesystem UUID cannot.

sudo pvcreate /dev/sdb
sudo vgcreate vgdata /dev/sdb
sudo lvcreate -n lvweb -L 2G vgdata
sudo mkfs.xfs /dev/vgdata/lvweb
sudo mkdir -p /srv/web
echo "UUID=$(sudo blkid -s UUID -o value /dev/vgdata/lvweb) /srv/web xfs defaults 0 0" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo mount -a
findmnt /srv/web

The tee echoed the line it appended, and findmnt confirmed the mount:

UUID=0756563a-29fb-438c-afec-4a3147708021 /srv/web xfs defaults 0 0
TARGET   SOURCE                   FSTYPE OPTIONS
/srv/web /dev/mapper/vgdata-lvweb xfs    rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota

Mounting with mount -a instead of a manual mount is the point of the exercise, because it proves the fstab line works before a reboot depends on it. For the grow step, lvextend -r resizes the logical volume and the filesystem in one command. XFS can grow but cannot be shrunk in practice, so a question that asks you to shrink an XFS volume online has no answer except backup, recreate and restore.

sudo lvextend -r -L +1G /dev/vgdata/lvweb
sudo lvs vgdata
df -h /srv/web

The output shows xfs_growfs running for you, and df reports the new 3.0G size on the live mount:

lvextend -r growing an XFS logical volume from 2 GiB to 3 GiB on Rocky Linux 10

Forget the -r and the logical volume grows while df still shows 2.0G. That mismatch turns up in real tickets as often as in practice tests, and you repair it with sudo xfs_growfs /srv/web afterwards, because XFS only grows while it is mounted. Our guide to extending a root filesystem with LVM walks the same moves on the root volume.

Question 3: Find which process listens on a port

Task. Show every listening TCP socket with its owning process, then narrow the list to port 22. Answer. ss -tlnp lists TCP (t) listeners (l) with numeric ports (n) and processes (p). Run it with sudo, because without root the process column stays empty for sockets you do not own, and add a filter expression to narrow it:

sudo ss -tlnp 'sport = :22'

On our Rocky VM, sshd was listening on both IPv4 and IPv6:

State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*    users:(("sshd",pid=2507,fd=7))
LISTEN 0      128             [::]:22           [::]:*    users:(("sshd",pid=2507,fd=8))

Two lines with the same PID mean one daemon bound to two address families, not two copies of sshd. netstat is the older answer and still turns up in distractors. It comes from the separate net-tools package and is not part of a minimal install. Treat ss as the default and learn netstat options only well enough to recognise them.

Question 4: Which package owns a file, and which package provides a missing command?

Task. Find the package that installed ss on both distros, then find the RHEL-family package that provides semanage. Answer. RHEL-family systems answer “who owns this file” with rpm -qf and “who would provide it” with dnf provides. The second one searches repository metadata, so it also finds commands you have not installed yet.

rpm -qf /usr/sbin/ss
dnf provides '*bin/semanage'

After the repository metadata loads, dnf names the package (we trimmed the metadata lines):

iproute-6.17.0-2.el10.x86_64
policycoreutils-python-utils-3.11-1.el10.noarch : SELinux policy core python utilities
Repo        : appstream
Matched from:
Other       : *bin/semanage

Ubuntu answers the ownership question with dpkg -S, and the path is different too:

dpkg -S /usr/bin/ss

The reply uses the Debian package name:

iproute2: /usr/bin/ss

The package is iproute on Rocky and iproute2 on Ubuntu, and the binary sits in /usr/sbin on one and /usr/bin on the other. That is why we searched for *bin/semanage instead of a full path, since a glob matches either location. The APT cheat sheet has the Ubuntu side of package queries in one table.

Question 5: Replace a cron job with a systemd timer

Task. Run /usr/local/bin/disk-report.sh every 15 minutes with a systemd timer, and make missed runs fire after the server was off. Answer. A timer needs two units with the same base name, a .service that does the work and a .timer that schedules it. Both point at a script, so create that first, or the service fails with 203/EXEC (Question 18 shows that failure):

sudo vim /usr/local/bin/disk-report.sh

The script appends a timestamp and the root filesystem usage line to a log:

#!/bin/bash
date "+%F %T" >> /var/log/disk-report.log
df -h / | tail -1 >> /var/log/disk-report.log

Make it executable, then create the service unit:

sudo chmod 755 /usr/local/bin/disk-report.sh
sudo vim /etc/systemd/system/disk-report.service

A oneshot service fits a script that runs and exits:

[Unit]
Description=Append root filesystem usage to a log

[Service]
Type=oneshot
ExecStart=/usr/local/bin/disk-report.sh

Then create the timer in a file with the same base name:

sudo vim /etc/systemd/system/disk-report.timer

OnCalendar=*:0/15 means every 15 minutes from the top of the hour, and Persistent=true catches up on runs missed while the machine was down:

[Unit]
Description=Run disk-report every 15 minutes

[Timer]
OnCalendar=*:0/15
Persistent=true

[Install]
WantedBy=timers.target

Enable the timer, not the service, because the service has no [Install] section and only ever runs when the timer starts it. Then list the timer, run the job once by hand, and test the calendar expression:

sudo systemctl daemon-reload
sudo systemctl enable --now disk-report.timer
systemctl list-timers disk-report.timer --no-pager
sudo systemctl start disk-report.service
systemd-analyze calendar '*:0/15'

The timer shows its next run, the manual start wrote the first log line, and systemd-analyze confirms the normalized schedule:

systemctl list-timers showing a systemd timer that runs every 15 minutes

systemd-analyze calendar is the step most people skip, and it is the quickest way to prove an OnCalendar line means what you think. Here the normalized form *-*-* *:00/15:00 and the next elapse at 18:30 both match the intent, so the timer is right before it ever fires. Our systemd timers guide covers monotonic timers and randomized delays if you want more practice.

Can you handle the Services and User Management tasks?

This 20% domain is accounts, groups, permissions, privilege and containers. The questions look simple until a default you did not know about changes the result, so test every answer as the user it affects. You’ve covered it when these all hold:

  • chage -l shows the expiry date and forced password change you set.
  • A read-only user gets Permission denied when writing to the shared directory.
  • sudo -l -U dev1 lists exactly one allowed command.

The four tasks below build on each other, so run them in order on the same VM.

Question 6: Create a user who must change the password and expires on a date

Task. Create dev1 with a home directory and bash, force a password change at first login, and expire the account on June 30, 2027. Answer. chage -d 0 sets the last change date to the epoch, so the password counts as expired and must be changed at the next login, while chage -E sets the account expiry. Use your own throwaway password in place of ours:

sudo useradd -m -s /bin/bash -c "Dev One" dev1
echo "dev1:Lab-Pass-2026" | sudo chpasswd
sudo chage -E 2027-06-30 -d 0 dev1
sudo chage -l dev1

The chage -l report confirms both settings:

Last password change					: password must be changed
Password expires					: password must be changed
Password inactive					: password must be changed
Account expires						: Jun 30, 2027
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

Keep the -s /bin/bash even though it looks redundant, because the default shell depends on the distro. Rocky gave a plain useradd -m account bash, but Ubuntu gave it /bin/sh, since its /etc/default/useradd sets SHELL=/bin/sh. Ubuntu’s friendlier adduser wrapper does pick bash, so the same “create a user” task gives two different results there depending on which command you reach for. The Linux user management cheat sheet lists the rest of the account flags in one place.

Question 7: Build a shared group directory with a read-only auditor

Task. Create /srv/projects for group devteam. New files must belong to the group and stay group-writable, other users get nothing, and user auditor can list and read but not write. Answer. Mode 2770 sets the setgid bit so new files inherit the group. A named ACL entry gives the auditor read access without adding them to the group, and a default ACL keeps new files group-writable whatever the creator’s umask says.

sudo groupadd devteam
sudo usermod -aG devteam dev1
sudo useradd -m auditor
sudo mkdir /srv/projects
sudo chgrp devteam /srv/projects
sudo chmod 2770 /srv/projects
sudo setfacl -m u:auditor:rx /srv/projects
sudo setfacl -d -m g:devteam:rwx /srv/projects

Then test it the way a grader would, as each user in turn:

getfacl /srv/projects
sudo -u dev1 touch /srv/projects/plan.txt
sudo ls -l /srv/projects
sudo -u auditor ls /srv/projects
sudo -u auditor touch /srv/projects/notes.txt

The flags: -s- line is the setgid bit, the new file belongs to devteam, and the auditor’s write attempt fails:

getfacl output for a setgid shared directory with a read-only auditor ACL

The + after -rw-rw---- tells you the file carries an ACL, which plain ls -l otherwise hides. It is worth checking that sign whenever permissions look right but access still behaves oddly, because an ACL entry or the mask can override what the mode bits suggest. On Ubuntu, install the acl package first if setfacl is missing.

Question 8: visudo says “expected a fully-qualified path name”

Task. Let members of devteam restart nginx as root and nothing else, without editing /etc/sudoers itself. Answer. Put the rule in /etc/sudoers.d/ and check it with visudo -cf before relying on it. We wrote the common wrong version to a scratch file first, so you can see what the check catches:

echo "%devteam ALL=(root) systemctl restart nginx" | sudo tee /tmp/devteam-bad
sudo visudo -cf /tmp/devteam-bad

The rule has no absolute path for the command, so visudo rejected it. Open the real fragment with visudo so the same check runs when you save:

sudo visudo -f /etc/sudoers.d/devteam

Add this single line with the full path to systemctl:

%devteam ALL=(root) /usr/bin/systemctl restart nginx

Lock the permissions, re-check the file and ask sudo what dev1 may run:

sudo chmod 440 /etc/sudoers.d/devteam
sudo visudo -cf /etc/sudoers.d/devteam
sudo -l -U dev1

Both halves of the answer are in this capture, the error with its column marker and then parsed OK with the single permitted command:

visudo -cf rejecting a sudoers rule without a fully-qualified path

The marker under column 21 points at the bare systemctl, which tells you exactly what to fix. Never write a sudoers fragment with a plain editor and walk away, because a syntax error in an included file can still lock you out. Current sudo skips the bad line by default, but older releases, or a policy with error_recovery turned off, refuse to run at all. On a cloud VM without a root password, that means a rescue boot to undo one typo.

Question 9: Run a rootless container and publish a port

Task. As a normal user, run nginx in a container on host port 8080, confirm it answers, then remove it. Answer. Podman runs rootless when a normal user calls it, so no sudo is needed after the install. Unprivileged users cannot bind ports below 1024 by default, so the task maps container port 80 to host port 8080:

sudo dnf -y install podman
podman run -d --name web -p 8080:80 docker.io/library/nginx:alpine
podman ps
curl -sI http://localhost:8080 | head -2
podman stop web
podman rm web

The container came up with the port mapping, and nginx answered on 8080:

CONTAINER ID  IMAGE                           COMMAND               CREATED                 STATUS                 PORTS                 NAMES
6dbd70aaabc9  docker.io/library/nginx:alpine  nginx -g daemon o...  Less than a second ago  Up Less than a second  0.0.0.0:8080->80/tcp  web
HTTP/1.1 200 OK
Server: nginx/1.31.9

We used the fully qualified image name on purpose, so the pull goes straight to Docker Hub instead of depending on the registry and short-name settings under /etc/containers/. The same commands work with docker in place of podman on a host running Docker, which is worth remembering because questions use the two interchangeably. The Podman cheat sheet covers pods and Quadlet units for the follow-up questions.

How do the Security questions play out on a live system?

Security is 18%, and on a RHEL-family box it nearly always starts with SELinux. These four tasks are the ones we would expect a performance-based item to drop you into, and each has a way to lock yourself out if you rush it. You’re ready when you can tick these off:

  • You can name the wrong SELinux label from a single AVC line.
  • Your firewall rules survive firewall-cmd --reload and a reboot.
  • sshd -T shows permitrootlogin no while your key login still works.

Keep that second SSH session open for the whole section.

Question 10: Apache returns 403 Forbidden for a file you just moved in

Task. Apache serves /srv/web. A colleague wrote promo.html in their home directory and moved it into place, and now it returns 403 while index.html works. Find the cause and fix it without disabling SELinux. To set the scene, install Apache and the SELinux tools, then add a page to the logical volume from Question 2:

sudo dnf -y install httpd policycoreutils-python-utils
echo "Linux+ lab page" | sudo tee /srv/web/index.html
sudo vim /etc/httpd/conf.d/srvweb.conf

Point a virtual host at the directory:

<VirtualHost *:80>
    DocumentRoot /srv/web
    <Directory /srv/web>
        Require all granted
    </Directory>
</VirtualHost>

Start Apache and request the page. Ours returned 403 straight away, before any colleague touched it, because a new filesystem carries the label unlabeled_t, which httpd may not read:

sudo systemctl enable --now httpd
curl -s -o /dev/null -w "%{http_code}\n" http://localhost/
ls -Z /srv/web/index.html

restorecon alone changes nothing here, because no file-context rule covers /srv/web yet. Add the rule first, so every relabel from now on knows the right type:

sudo semanage fcontext -a -t httpd_sys_content_t '/srv/web(/.*)?'
sudo restorecon -Rv /srv/web
curl -s http://localhost/

restorecon relabeled the directory and index.html from unlabeled_t to httpd_sys_content_t, and the 403 turned into the page, as curl printed Linux+ lab page. Now reproduce the colleague’s mistake and solve the actual task. Answer. mv keeps a file’s SELinux label, so the moved file still carries user_home_t and the httpd_t domain may not read it. Check the label, read the AVC denial, and restore the default context:

echo "Spring promo" > ~/promo.html
sudo mv ~/promo.html /srv/web/
ls -Z /srv/web/
sudo ausearch --input-logs -m avc -c httpd -ts recent -i | grep denied | tail -1
sudo restorecon -v /srv/web/promo.html
curl -s http://localhost/promo.html

The denial names the source domain, the target label and the blocked permission:

SELinux AVC denial for httpd reading a user_home_t file, fixed with restorecon

Read the AVC line left to right: denied { read } is the blocked action, scontext is httpd, and tcontext shows the leftover user_home_t label. That is everything the question asks for, and a plain restorecon repairs it this time because the file-context rule you added earlier already names the right type. One more trap caught us. ausearch without --input-logs returned <no matches> when run from a script, because without a terminal it reads stdin instead of the audit log. Our SELinux troubleshooting guide goes deeper into booleans and custom ports.

Question 11: Open HTTP and port 8080 with firewalld and ufw

Task. Allow the http service and TCP 8080 permanently on Rocky, then allow SSH and TCP 8080 on Ubuntu and turn the firewall on. Answer. In firewalld, rules added with --permanent go to the saved configuration only, so you reload to apply them. Without --permanent they apply now but vanish at the next restart:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

Our --list-all opened with a surprise:

trusted (default, active)
  target: ACCEPT
  ingress-priority: 0
  egress-priority: 0
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: http
  ports: 8080/tcp

The cloud image we used sets the default zone to trusted, whose ACCEPT target lets everything in, so the rules we added changed nothing. A standard install defaults to public. Run sudo firewall-cmd --get-default-zone before adding rules, and when a question hands you an odd default, put --zone=public on every command. Our firewalld guide for Rocky Linux explains zones in detail.

On Ubuntu, allow SSH before you enable ufw, because the default policy denies incoming traffic and the enable step could otherwise cut off your own session:

sudo ufw allow OpenSSH
sudo ufw allow 8080/tcp
sudo ufw --force enable
sudo ufw status verbose

The verbose status shows the default deny for incoming traffic and both rules for IPv4 and IPv6:

ufw status verbose on Ubuntu 26.04 with OpenSSH and 8080/tcp allowed

The OpenSSH name is an application profile, which is why it appears in parentheses next to 22/tcp. --force only skips the confirmation prompt, so drop it when you type the command by hand and read the warning instead. Our ufw command reference has more rule examples.

Question 12: Disable root SSH login and password authentication

Task. Block root logins and password logins over SSH using a drop-in file, prove the effective setting, and apply it without dropping your session. Confirm key login works for your user first, because password logins stop working after this change. Answer. Both distros read /etc/ssh/sshd_config.d/*.conf, and sshd keeps the first value it reads for each keyword. A low number like 10- therefore wins over later files such as the 60-cloudimg-settings.conf that sets PasswordAuthentication on Ubuntu’s cloud image.

sudo vim /etc/ssh/sshd_config.d/10-hardening.conf

Two lines are enough:

PermitRootLogin no
PasswordAuthentication no

Test the syntax, print the effective values, then reload. The unit is sshd on Rocky and ssh on Ubuntu:

sudo sshd -t
sudo sshd -T | grep -Ei '^(permitrootlogin|passwordauthentication) '
sudo systemctl reload sshd    # on Ubuntu: sudo systemctl reload ssh

Silence from sshd -t means the syntax is fine, and sshd -T printed the merged result on both VMs:

permitrootlogin no
passwordauthentication no

sshd -T is the proof a grader wants, since it shows what the daemon will actually enforce after every include is merged. Use reload rather than restart, and keep your second session open until a fresh login works. On Rocky, even ls /etc/ssh/sshd_config.d/ needs sudo; ours failed with Permission denied as a normal user.

Question 13: Audit every write to /etc/passwd

Task. Record writes and attribute changes on /etc/passwd with the key passwd_changes, keep the rule across reboots, and find the event created by a new user. Answer. auditctl -w adds a watch for this boot only, which is fine for testing it. Add the watch, create a user to trigger it, and search by key:

sudo auditctl -w /etc/passwd -p wa -k passwd_changes
sudo useradd tempuser
sudo ausearch --input-logs -k passwd_changes -c useradd -ts recent -i | grep -m1 type=SYSCALL

The event names the program, the real user behind sudo and the key:

type=SYSCALL msg=audit(11/19/2026 18:27:42.132:1256) : arch=x86_64 syscall=openat success=yes exit=5 a0=AT_FDCWD a1=0x559058331040 a2=O_RDWR|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC a3=0x0 items=1 ppid=9260 pid=9262 auid=harrison uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=15 comm=useradd exe=/usr/sbin/useradd subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=passwd_changes

The auid=harrison field answers “who did it”, since uid only says root. auditctl also printed “Old style watch rules are slower” when we added the watch. That is a warning, not a failure, and the rule still loads. To keep the watch after a reboot, put it in a rules file:

sudo vim /etc/audit/rules.d/passwd.rules

The file holds the same watch in the same syntax:

-w /etc/passwd -p wa -k passwd_changes

Load the rules directory and list what the kernel now enforces:

sudo augenrules --load
sudo auditctl -l

After the status lines from augenrules, the list shows the persistent rule:

-w /etc/passwd -p wa -k passwd_changes

A rule that exists only in auditctl passes a quick check and disappears at the next boot, and that is the reason the task asks for both. On Ubuntu, install the auditd package with apt first if auditctl is missing, because it is not part of every server image.

What do the Automation and Scripting tasks look like?

At 17%, this domain covers shell scripts, Git and configuration management. You’re more likely to read and fix a short script than write a long one, so these tasks stay small. You’ve got the basics when:

  • bash -n passes on your script before you ever run it.
  • git log --oneline --graph shows the branch you merged.
  • A second run of your playbook ends with changed=0.

The Git task reuses the timer file from Question 5, so keep that VM around.

Question 14: Write a script that lists human accounts above a UID

Task. Write /usr/local/bin/user-report.sh that prints name, UID, home and shell for accounts at or above a UID given as the first argument (default 1000), skipping nobody. Answer. Split getent passwd on colons with IFS, compare numbers inside (( )), and default the argument with ${1:-1000}. Open the file:

sudo vim /usr/local/bin/user-report.sh

The uid < 65534 test is what drops nobody:

#!/bin/bash
# List local accounts at or above a UID (default 1000) with home and shell
min_uid=${1:-1000}
while IFS=: read -r name _ uid _ _ home shell; do
  if (( uid >= min_uid && uid < 65534 )); then
    printf "%-10s %-6s %-18s %s\n" "$name" "$uid" "$home" "${shell##*/}"
  fi
done < <(getent passwd)

Make it executable, syntax-check it with bash -n, and run it with an argument:

sudo chmod 755 /usr/local/bin/user-report.sh
bash -n /usr/local/bin/user-report.sh
user-report.sh 1002

Every account we created on the VM shows up, with the shell trimmed to its basename. dev2 and tempuser2 came from side tests, and your UIDs will differ:

harrison   1002   /home/harrison     bash
dev1       1003   /home/dev1         bash
dev2       1004   /home/dev2         bash
auditor    1005   /home/auditor      bash
tempuser   1006   /home/tempuser     bash
tempuser2  1007   /home/tempuser2    bash

Reading getent instead of /etc/passwd means the script also sees accounts that come from LDAP or SSSD. The process substitution at the end keeps the loop in the current shell, so a counter you add later still holds its value after done. A pipe into while would run the loop in a subshell and silently lose it.

Question 15: Change a config on a branch and merge it

Task. Keep the timer file from Question 5 in a Git repo, change its schedule to hourly on a branch called hourly, and merge it into main. Answer. Commit the baseline, switch to a new branch, commit the change, then switch back and merge. Set user.name and user.email first on a fresh machine, or the first commit stops with an identity error:

sudo dnf -y install git
git config --global user.name "Harrison" && git config --global user.email "[email protected]"
mkdir -p ~/infra && cd ~/infra
git init -q -b main
cp /etc/systemd/system/disk-report.timer .
git add . && git commit -q -m "Add disk-report timer"
git switch -c hourly
sed -i "s|\*:0/15|hourly|" disk-report.timer
git commit -q -am "Run disk-report hourly"
git switch main
git merge hourly
git log --oneline --graph --all

Because main had not moved, Git did a fast-forward and the history stays a straight line:

Updating def5581..47b0d66
Fast-forward
 disk-report.timer | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
* 47b0d66 Run disk-report hourly
* def5581 Add disk-report timer

A fast-forward leaves no record that a branch ever existed, which some teams want and others forbid. If a question asks for a merge commit even when a fast-forward is possible, the answer is git merge --no-ff hourly. Expect the reverse question too: git merge --ff-only refuses to merge at all unless a fast-forward is possible.

Question 16: Write an Ansible playbook that installs and starts a service

Task. On localhost, make sure chrony is installed and chronyd is running and enabled, using fully qualified module names. Answer. One play with become: true and two tasks does it. Create the playbook:

sudo dnf -y install ansible-core
mkdir -p ~/ansible && vim ~/ansible/site.yml

Each task names its module in full, such as ansible.builtin.dnf:

- name: Baseline for Linux+ lab
  hosts: localhost
  connection: local
  become: true
  tasks:
    - name: Install chrony
      ansible.builtin.dnf:
        name: chrony
        state: present
    - name: Start and enable chronyd
      ansible.builtin.service:
        name: chronyd
        state: started
        enabled: true

The trailing comma in -i localhost, tells Ansible the inventory is a list of hosts, not a file name. Our lab user had passwordless sudo, so if your sudo asks for a password, add -K and Ansible prompts for it instead of stopping with “Missing sudo password”:

cd ~/ansible && ansible-playbook -i localhost, site.yml

chrony was already on our image, so both tasks report ok and nothing changed:

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Install chrony] **********************************************************
ok: [localhost]

TASK [Start and enable chronyd] ************************************************
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

A task that finds the system already in the wanted state reports ok instead of changed. That is idempotence, and it is why a second run of any well-written playbook ends with changed=0. If yours keeps reporting changed on every run, a task is probably using command or shell where a real module exists. The first Ansible playbook tutorial builds from here to inventories and roles.

Can you troubleshoot these four failures?

Troubleshooting is 22% of XK0-006 and the domain where hands-on practice pays off most, because the symptom rarely names the cause. We broke each system below on purpose, captured the symptom, and fixed it. You’re in good shape when:

  • findmnt --verify reports 0 errors after you edit /etc/fstab.
  • You can name the cause of a failed unit from its journal lines.
  • You can explain a gap between df and du without rebooting.

Each fix below starts from the evidence, not a guess.

Question 17: mount: can’t find UUID after an fstab edit

Task. Someone added a backup disk to /etc/fstab with a wrong UUID. Catch the problem before the next reboot drops the server into emergency mode, then fix it. Answer. findmnt --verify checks every fstab line without mounting anything, and mount -a shows the same error the boot would hit. The first two commands below plant the bad entry, and the last two remove it and verify again.

echo "UUID=11111111-2222-3333-4444-555555555555 /mnt/backup xfs defaults 0 0" | sudo tee -a /etc/fstab
sudo mkdir -p /mnt/backup
sudo findmnt --verify
sudo mount -a
sudo sed -i "\|/mnt/backup|d" /etc/fstab
sudo findmnt --verify

The [E] line names the unreachable source, and it is gone after the bad line is removed:

findmnt --verify catching a bad UUID in /etc/fstab before reboot

The remaining [W] warning is a reminder to run sudo systemctl daemon-reload after any fstab edit, since systemd builds mount units from that file. For a disk that may legitimately be absent, add the nofail option, so the boot continues without it instead of stopping at emergency mode.

Question 18: A service fails with status=203/EXEC

Task. report-api.service fails right after start. Find why from the journal and get it running. Answer. Exit status 203 means systemd could not execute the ExecStart binary at all, so the program never ran and its own logs will be empty. To reproduce it, create a unit whose ExecStart points at a binary that does not exist:

sudo vim /etc/systemd/system/report-api.service

This is the broken unit we used:

[Unit]
Description=Report API

[Service]
ExecStart=/usr/local/bin/report-api

[Install]
WantedBy=multi-user.target

Reload, start it, and read the journal for the unit, which says which path systemd tried:

sudo systemctl daemon-reload
sudo systemctl start report-api

The start command returns silently, so check the status and the journal next:

systemctl status report-api --no-pager -n 0
journalctl -u report-api -b --no-pager | tail -4

“Unable to locate executable” settles it, because the path in the unit does not exist. The screenshot below covers the failure and the fix:

systemd unit failing with status 203/EXEC and the journalctl lines that explain it

For the fix we pointed ExecStart at a command that exists, a small Python web server, then reloaded and restarted the unit. systemctl is-active printed active:

sudo sed -i "s|^ExecStart=.*|ExecStart=/usr/bin/python3 -m http.server 9090 --directory /srv/web|" /etc/systemd/system/report-api.service
sudo systemctl daemon-reload && sudo systemctl restart report-api
systemctl is-active report-api

Stop the unit with sudo systemctl stop report-api when you finish, so the practice web server does not keep listening on port 9090.

Learn the common codes as a set: 203/EXEC is a missing or non-executable binary, 217/USER is a User= that doesn’t exist, and 200/CHDIR is a bad WorkingDirectory=. All three fail before your program starts, which is why the unit’s journal holds the explanation rather than the application log. Our guide to filtering logs with journalctl has the other filters worth knowing.

Question 19: Find a CPU hog and lower its priority

Task. Load is climbing. Find the process eating CPU, lower its priority without killing it, confirm the change, then stop it. Answer. Sort ps by CPU, raise the nice value with renice, then check the NI column. We started yes in the background as the hog:

nohup yes > /dev/null 2>&1 &
uptime
ps -eo pid,user,ni,%cpu,%mem,comm --sort=-%cpu | head -4
sudo renice -n 15 -p $(pgrep -x yes)
ps -o pid,ni,%cpu,comm -p $(pgrep -x yes)
pkill -x yes

renice reports the old and new priority, and ps shows NI at 15:

 18:28:05 up 5 min,  1 user,  load average: 1.31, 0.80, 0.38
9853 (process ID) old priority 0, new priority 15
    PID  NI %CPU COMMAND
   9853  15  110 yes

A higher nice value means a lower priority. You can raise the nice value of your own processes without sudo. Lowering it again, or changing another user’s process, needs root. %CPU stayed high because nothing else was competing for the core, and niceness only changes who wins when processes contend. Don’t read a renice that “did nothing” as a failure, then.

Question 20: df says the disk is full but du can’t find the files

Task. Root filesystem usage jumped by 1 GB, yet du shows nothing large. Find where the space went and free it. Answer. A deleted file that a process still holds open keeps its blocks until that process closes it, and lsof +L1 lists open files with a link count below one. We simulated it with a 1 GB file and a tail holding it:

fallocate -l 1G /var/tmp/app.log
setsid -f tail -f /var/tmp/app.log > /dev/null 2>&1
rm /var/tmp/app.log
df -h /
sudo du -xsh /var/tmp
sudo lsof +L1 | grep -E "COMMAND|app.log"
pkill -xf "tail -f /var/tmp/app.log"

df went from 3.6G to 4.6G used while du saw only 210M in /var/tmp, and lsof pointed at the culprit:

lsof +L1 finding a deleted 1 GiB file still held open by a process

One result surprised us: right after pkill, df still said 4.6G. pkill returns before the process has fully exited, and XFS most likely finished freeing the inode in the background, because a few seconds later the same command reported 3.6G again, so give it a moment before you decide the fix failed. In production, restarting the service that holds the file is the usual fix. When a restart is not allowed, truncating the file through /proc/<pid>/fd/<n> frees the space instead.

Where do Rocky Linux and Ubuntu give different answers?

XK0-006 is vendor-neutral, so a question can assume either family. These are the differences we ran into while running the same tasks on both VMs:

TaskRocky LinuxUbuntu
Who owns a filerpm -qf (iproute)dpkg -S (iproute2)
useradd -m default shell/bin/bash/bin/sh
Host firewallfirewalldufw
SSH unit namesshdssh
Path of ss/usr/sbin/ss/usr/bin/ss
Extra packages for these tasksNone beyond httpd, podman, git and ansible-coreWe installed acl, auditd and lvm2

The shell default is the one that catches people, because nothing errors. The account works, but the user lands in a shell without bash history or completion and files a ticket a week later. The RHCSA practice questions go deeper on the Red Hat side if you plan to take EX200 next.

What should you drill in the final week?

Rebuild the lab from scratch and redo the tasks without looking, because a practice question only counts once you can do it cold. Work through this list in order:

  1. You can build an LVM volume, mount it by UUID and grow it with lvextend -r in under five minutes.
  2. Your systemd timer survives a reboot and systemctl list-timers shows the next run.
  3. A shared directory keeps group ownership on new files, and the read-only user gets Permission denied on write.
  4. Every sudoers fragment you write passes visudo -cf before you log out.
  5. You can read an AVC denial and say which label is wrong without running setenforce 0.
  6. You check the default firewalld zone before adding rules, and you allow SSH before enabling ufw.
  7. findmnt --verify runs clean after every fstab change.
  8. You can name the cause behind 203/EXEC from the journal in one command.

If any item takes you more than one try, repeat that question on a fresh VM the next day. The tasks that feel slow in your lab are the ones that will eat your time on the timed performance-based items, so they deserve the extra run.

Keep reading

How to Upgrade Fedora 44 to Fedora 45 (GUI, CLI and Rollback) Fedora How to Upgrade Fedora 44 to Fedora 45 (GUI, CLI and Rollback) Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs Security Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs 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) MedGemma 2 vs Gemma 4 vs MedGemma 1.5: Local Benchmark AI MedGemma 2 vs Gemma 4 vs MedGemma 1.5: Local Benchmark Build a FHIR MCP Server for MedGemma 2 with Ollama AI Build a FHIR MCP Server for MedGemma 2 with Ollama Add and Use ISO Library Storage Repository in Xen XCP-ng Virtualization Add and Use ISO Library Storage Repository in Xen XCP-ng

Leave a Comment

Press ESC to close