Free practice test

Free CompTIA Linux+ (XK0-006) Practice Test

25 original practice questions with answers and explanations, including 3 performance-based style items. Work through each one, then open the answer to check your reasoning. No signup needed.

Written for exam objectives version 5.0 · Last reviewed

How the real XK0-006 exam is built

Maximum of 90 in 90 minutes; passing score 720 (on a scale of 100–900). Domains and weights: System Management (23%), Services and User Management (20%), Security (18%), Automation, Orchestration, and Scripting (17%), Troubleshooting (22%). Confirm current details on comptia.org.

  1. Question 1 of 25Multiple choiceDomain 1: System Management

    An administrator must add the kernel parameter "audit=1" to every boot entry on a server that uses GRUB2, and the change must survive future kernel updates. Which file should be edited before the GRUB configuration is regenerated?

    • A./boot/grub2/grub.cfg
    • B./etc/default/grub
    • C./etc/sysctl.conf
    • D./etc/fstab
    Show answer and explanation

    Correct answer: B

    Kernel command-line defaults live in the GRUB_CMDLINE_LINUX line of /etc/default/grub, and the boot configuration is then rebuilt with grub2-mkconfig (or update-grub on Debian and Ubuntu). On RHEL-family systems, grubby --update-kernel=ALL --args can apply the same change. /boot/grub2/grub.cfg is a generated file, so hand edits are overwritten the next time it is regenerated, for example after a kernel update. /etc/sysctl.conf sets runtime kernel tunables after boot, not boot parameters, and /etc/fstab defines filesystem mounts.

    Objective 1.1 · CompTIA Linux+ XK0-006 exam objectives

  2. Question 2 of 25Multiple choiceDomain 1: System Management

    An administrator needs to load a kernel module for a new storage controller. The module depends on two other modules that are not yet loaded. Which command loads the module and resolves its dependencies automatically?

    • A.insmod
    • B.lsmod
    • C.rmmod
    • D.modprobe
    Show answer and explanation

    Correct answer: D

    modprobe looks the module up by name under /lib/modules/$(uname -r) and uses the dependency data built by depmod to load any required modules first. insmod inserts a single module file by path and does not resolve dependencies, so it fails if they are missing. lsmod only lists loaded modules, and rmmod removes one.

    Objective 1.2 · CompTIA Linux+ XK0-006 exam objectives

  3. Question 3 of 25Performance-based: orderDomain 1: System Management

    A new partition, /dev/sdc1, must be turned into a 50 GB XFS filesystem on LVM and mounted at /data, which already exists. Put the steps in the correct order, from first to last.

    • lvcreate -n datalv -L 50G datavg
    • mkfs.xfs /dev/datavg/datalv
    • mount /dev/datavg/datalv /data
    • pvcreate /dev/sdc1
    • vgcreate datavg /dev/sdc1
    Show answer and explanation
    1. pvcreate /dev/sdc1
    2. vgcreate datavg /dev/sdc1
    3. lvcreate -n datalv -L 50G datavg
    4. mkfs.xfs /dev/datavg/datalv
    5. mount /dev/datavg/datalv /data

    LVM is built from the bottom up. The partition is first initialized as a physical volume, physical volumes are then grouped into a volume group, and a logical volume is carved out of that group. A filesystem can only be created on the logical volume once it exists, and it can only be mounted after it has a filesystem. To make the mount persistent, add an /etc/fstab entry afterward.

    Objective 1.3 · CompTIA Linux+ XK0-006 exam objectives

  4. Question 4 of 25Multiple choiceDomain 1: System Management

    On a RHEL server managed by NetworkManager, an administrator runs "ip addr add 192.0.2.10/24 dev ens192". The address works but is gone after a reboot. The connection profile is named ens192. Which action makes the address persistent?

    • A.nmcli connection modify ens192 ipv4.addresses 192.0.2.10/24 ipv4.method manual, then nmcli connection up ens192
    • B.Add the ip addr add command to the administrator’s ~/.bashrc
    • C.Add a line mapping the server’s hostname to 192.0.2.10 in /etc/hosts
    • D.Run sysctl -w net.ipv4.ip_forward=1
    Show answer and explanation

    Correct answer: A

    Changes made with the ip command only affect the running kernel. Storing the address in the NetworkManager connection profile with nmcli makes it persistent, and bringing the connection up applies it now. ~/.bashrc runs only when that user opens an interactive shell, so it is not a boot-time configuration. /etc/hosts only does name-to-address lookups and does not assign addresses. ip_forward turns on routing between interfaces.

    Objective 1.4 · CompTIA Linux+ XK0-006 exam objectives

  5. Question 5 of 25Performance-based: matchDomain 1: System Management

    Match each requirement to the bash operator that satisfies it. Each choice may be used once, more than once, or not at all.

    Choices (each may be used once, more than once, or not at all)

    • >
    • >>
    • 2>
    • |
    • <
    • &&
    • ||

    Match these

    • 1.Write a command’s standard output to a file, replacing anything already in it
    • 2.Add a command’s standard output to the end of an existing log file
    • 3.Send only a command’s error messages to a file
    • 4.Use the output of one command as the input of the next command
    • 5.Run a second command only if the first command exits successfully
    Show answer and explanation
    • 1. Write a command’s standard output to a file, replacing anything already in it → >
    • 2. Add a command’s standard output to the end of an existing log file → >>
    • 3. Send only a command’s error messages to a file → 2>
    • 4. Use the output of one command as the input of the next command → |
    • 5. Run a second command only if the first command exits successfully → &&

    > truncates the target file and writes stdout to it, >> appends stdout, and 2> redirects file descriptor 2 (stderr). A pipe connects one command’s stdout to the next command’s stdin. && runs the next command only when the previous one returns exit status 0. < feeds a file into a command’s stdin, and || runs the next command only when the previous one fails, so neither was needed here.

    Objective 1.5 · CompTIA Linux+ XK0-006 exam objectives

  6. Question 6 of 25Multiple choiceDomain 1: System Management

    Before a major upgrade, an administrator wants a single gzip-compressed archive of the /etc directory saved as /backup/etc-backup.tar.gz. Which command does this?

    • A.tar -xzf /backup/etc-backup.tar.gz /etc
    • B.tar -tzf /backup/etc-backup.tar.gz /etc
    • C.tar -czf /backup/etc-backup.tar.gz /etc
    • D.tar -cJf /backup/etc-backup.tar.gz /etc
    Show answer and explanation

    Correct answer: C

    With tar, -c creates an archive, -z compresses it with gzip, and -f names the archive file, which must come right after -f. -x extracts an archive and -t lists its contents, so neither creates a backup. -J compresses with xz, not gzip, which makes the .tar.gz name misleading.

    Objective 1.6 · CompTIA Linux+ XK0-006 exam objectives

  7. Question 7 of 25Multiple choiceDomain 2: Services and User Management

    User jdoe already belongs to the wheel and developers supplementary groups. An administrator must also add jdoe to the docker group without removing any existing memberships. Which command should be used?

    • A.usermod -G docker jdoe
    • B.usermod -g docker jdoe
    • C.usermod -aG docker jdoe
    • D.useradd -G docker jdoe
    Show answer and explanation

    Correct answer: C

    usermod -a -G appends the user to the listed supplementary group and keeps the existing ones. Without -a, -G replaces the whole supplementary list, so jdoe would lose wheel and developers. Lowercase -g changes the primary group instead. useradd creates new accounts and fails because jdoe already exists. jdoe must log in again for the new membership to take effect.

    Objective 2.2 · CompTIA Linux+ XK0-006 exam objectives

  8. Question 8 of 25Select 2Domain 2: Services and User Management

    An administrator wants a misbehaving process, PID 4321, to shut down cleanly so it can run its cleanup handlers. Which TWO commands send the SIGTERM signal to it?

    • A.kill -9 4321
    • B.kill 4321
    • C.kill -HUP 4321
    • D.kill -15 4321
    • E.kill -STOP 4321
    Show answer and explanation

    Correct answers: B, D

    SIGTERM is signal 15 and is what kill sends when no signal is given, so "kill 4321" and "kill -15 4321" are the same. A process can catch SIGTERM and exit cleanly. -9 sends SIGKILL, which ends the process immediately and cannot be caught, so cleanup does not run. -HUP (signal 1) is often used to make a daemon reload its configuration, and -STOP pauses the process without ending it.

    Objective 2.3 · CompTIA Linux+ XK0-006 exam objectives

  9. Question 9 of 25Multiple choiceDomain 2: Services and User Management

    During an audit on a RHEL system, an administrator needs to find out which installed package provided the file /usr/bin/ssh. Which command answers this directly?

    • A.rpm -qf /usr/bin/ssh
    • B.rpm -ql /usr/bin/ssh
    • C.rpm -Va
    • D.rpm -e /usr/bin/ssh
    Show answer and explanation

    Correct answer: A

    rpm -qf ("query file") searches the RPM database and returns the installed package that owns the given path, such as openssh-clients. -ql takes a package name, not a file path, and lists that package’s files. rpm -Va checks every installed package’s files for changes, and rpm -e erases (uninstalls) a package.

    Objective 2.4 · CompTIA Linux+ XK0-006 exam objectives

  10. Question 10 of 25Multiple choiceDomain 2: Services and User Management

    An administrator edits /etc/systemd/system/app.service to change its ExecStart line. After "systemctl restart app", the old command still runs, and systemctl warns that the unit file changed on disk. Which command should be run before restarting the service?

    • A.systemctl reload app
    • B.systemctl mask app
    • C.systemctl isolate multi-user.target
    • D.systemctl daemon-reload
    Show answer and explanation

    Correct answer: D

    systemd caches unit definitions in memory. daemon-reload re-reads every unit file from disk, so the next restart uses the new ExecStart. "systemctl reload app" asks the running service to reload its own application configuration and does not re-read the unit file. mask blocks the unit from being started at all, and isolate switches the whole system to another target.

    Objective 2.5 · CompTIA Linux+ XK0-006 exam objectives

  11. Question 11 of 25Multiple choiceDomain 2: Services and User Management

    A PostgreSQL container is started with podman, and its image stores the database files in /var/lib/postgresql/data. Every time the container is removed and recreated from a newer image, all the databases are lost. Which addition to the podman run command keeps the database files across container rebuilds?

    • A.-p 5432:5432
    • B.-v pgdata:/var/lib/postgresql/data
    • C.--rm
    • D.-e POSTGRES_PASSWORD=Str0ngPass
    Show answer and explanation

    Correct answer: B

    A container’s writable layer is deleted along with the container. Mounting a named volume at the database’s data directory stores the files outside the container, so a new container can reuse them. -p publishes a port, --rm deletes the container automatically when it exits, and -e only sets an environment variable. None of these keeps data.

    Objective 2.6 · CompTIA Linux+ XK0-006 exam objectives

  12. Question 12 of 25Multiple choiceDomain 3: Security

    A user generates an Ed25519 key pair on a workstation and wants to log in to a server as "deploy" without a password. On the server, the public key must be added to which file?

    • A./home/deploy/.ssh/authorized_keys
    • B./home/deploy/.ssh/known_hosts
    • C./home/deploy/.ssh/id_ed25519
    • D./etc/ssh/ssh_host_ed25519_key
    Show answer and explanation

    Correct answer: A

    sshd checks the target account’s ~/.ssh/authorized_keys file for a public key that matches the private key the client proves it holds. ssh-copy-id appends the key there. known_hosts is a client-side file that records the host keys of servers the user has connected to. id_ed25519 is the conventional name for a user’s private key, which stays on the workstation. ssh_host_ed25519_key is the server’s own host private key.

    Objective 3.1 · NIST IR 7966 Security of Interactive and Automated Access Management Using SSH

  13. Question 13 of 25Multiple choiceDomain 3: Security

    A web server uses firewalld. HTTPS must be allowed in the public zone now and must still be allowed after a reboot. Which approach meets both requirements?

    • A.firewall-cmd --zone=public --add-service=https
    • B.firewall-cmd --permanent --zone=public --add-service=https, then firewall-cmd --reload
    • C.iptables -A INPUT -p tcp --dport 443 -j ACCEPT
    • D.firewall-cmd --permanent --zone=public --add-port=443/udp, then firewall-cmd --reload
    Show answer and explanation

    Correct answer: B

    --permanent writes the rule to the saved configuration, and --reload loads that configuration into the running firewall, so the change applies now and after a reboot. Without --permanent, the change is runtime-only and is lost on reload or reboot. A raw iptables rule bypasses firewalld and is not saved. The firewalld https service is 443/tcp, so opening 443/udp does not allow standard HTTPS.

    Objective 3.2 · CompTIA Linux+ XK0-006 exam objectives

  14. Question 14 of 25Select 2Domain 3: Security

    A public-facing server’s logs show constant password-guessing attempts against the root account over SSH. All administrators already log in with SSH keys under their own accounts and use sudo. Which TWO /etc/ssh/sshd_config settings most directly reduce this risk?

    • A.PermitRootLogin no
    • B.X11Forwarding yes
    • C.PasswordAuthentication no
    • D.PermitEmptyPasswords yes
    • E.MaxAuthTries 50
    Show answer and explanation

    Correct answers: A, C

    Blocking direct root logins removes the most targeted account, and turning off password authentication makes password guessing useless because only key-based logins are accepted (KbdInteractiveAuthentication should also be off so PAM cannot prompt for a password). Validate the file with sshd -t and then reload sshd. X11 forwarding adds attack surface, empty passwords weaken authentication, and raising MaxAuthTries allows more guesses per connection.

    Objective 3.3 · CompTIA Linux+ XK0-006 exam objectives

  15. Question 15 of 25Multiple choiceDomain 3: Security

    A laptop running Linux stores customer data on a dedicated partition, /dev/sdb1. Policy requires that the whole partition be encrypted at rest so the data cannot be read if the drive is removed. Which command starts setting this up?

    • A.gpg --symmetric /dev/sdb1
    • B.sha256sum /dev/sdb1
    • C.ssh-keygen -t ed25519
    • D.cryptsetup luksFormat /dev/sdb1
    Show answer and explanation

    Correct answer: D

    cryptsetup luksFormat writes a LUKS header and sets up block-level encryption for the whole partition. The volume is then opened with cryptsetup open, and a filesystem is created on the /dev/mapper device. gpg encrypts individual files, not a mounted block device used for live storage. sha256sum only computes a hash for integrity checks, and ssh-keygen creates SSH authentication keys.

    Objective 3.5 · NIST SP 800-111 Guide to Storage Encryption Technologies for End User Devices

  16. Question 16 of 25Multiple choiceDomain 4: Automation, Orchestration, and Scripting

    An administrator runs the same Ansible playbook against a server twice. The first run makes several changes. The second run reports zero changes because the server is already in the desired state. Which property of the automation does this show?

    • A.Immutability
    • B.Imperative execution
    • C.Idempotency
    • D.Ephemerality
    Show answer and explanation

    Correct answer: C

    An idempotent operation produces the same end state no matter how many times it runs, so tasks that are already satisfied report "ok" instead of "changed". Immutable infrastructure replaces systems rather than changing them in place. Imperative execution describes step-by-step commands rather than a desired state. Ephemeral resources are short-lived and disposable.

    Objective 4.1 · CompTIA Linux+ XK0-006 exam objectives

  17. Question 17 of 25Multiple choiceDomain 4: Automation, Orchestration, and Scripting

    A bash deployment script must continue only if /etc/app/app.conf exists and is a regular file. It must not continue if that path is a directory. Which test should the script use?

    • A.if [ -f /etc/app/app.conf ]; then
    • B.if [ -d /etc/app/app.conf ]; then
    • C.if [ -e /etc/app/app.conf ]; then
    • D.if [ -z /etc/app/app.conf ]; then
    Show answer and explanation

    Correct answer: A

    -f is true only when the path exists and is a regular file. -d is true for directories, which is the case the script must reject. -e is true for any existing path, including a directory, so it is too broad. -z tests whether a string is empty, and a literal path string is never empty.

    Objective 4.2 · CompTIA Linux+ XK0-006 exam objectives

  18. Question 18 of 25Multiple choiceDomain 4: Automation, Orchestration, and Scripting

    An administrator is writing a Python automation tool that needs specific library versions. Those versions conflict with the versions used by system tools that rely on the OS Python. Which approach keeps the tool’s dependencies isolated?

    • A.sudo pip install -r requirements.txt
    • B.python3 -m venv .venv, activate it, then pip install -r requirements.txt
    • C.pip freeze > requirements.txt
    • D.python3 -m http.server
    Show answer and explanation

    Correct answer: B

    A virtual environment created with python3 -m venv has its own interpreter path and site-packages directory, so packages installed while it is active do not affect the system Python. Running pip as root installs into the system-wide location and can break OS tools that depend on it. pip freeze only records what is already installed, and http.server starts a simple web server.

    Objective 4.3 · CompTIA Linux+ XK0-006 exam objectives

  19. Question 19 of 25Multiple choiceDomain 4: Automation, Orchestration, and Scripting

    A teammate pushed fixes to the main branch on the shared remote. An administrator who has main checked out locally wants to download those commits and integrate them into the local branch with a single command. Which command does this?

    • A.git fetch origin
    • B.git push origin main
    • C.git clone origin
    • D.git pull origin main
    Show answer and explanation

    Correct answer: D

    git pull runs git fetch and then merges (or rebases, depending on configuration) the fetched commits into the current branch. git fetch on its own only updates remote-tracking branches such as origin/main and leaves the local branch unchanged. git push uploads local commits, and git clone creates a new copy of a repository.

    Objective 4.4 · CompTIA Linux+ XK0-006 exam objectives

  20. Question 20 of 25Multiple choiceDomain 5: Troubleshooting

    Users reported errors from the nginx service during the last hour. On a systemd-based server, which command shows only that service’s journal entries for that time period?

    • A.journalctl -k
    • B.journalctl -b -1
    • C.journalctl -u nginx --since "1 hour ago"
    • D.systemctl list-units --failed
    Show answer and explanation

    Correct answer: C

    -u filters the journal to one unit, and --since limits output to entries after the given time. journalctl -k shows only kernel messages, and -b -1 shows the whole previous boot. systemctl list-units --failed lists units in a failed state but shows no log entries.

    Objective 5.1 · CompTIA Linux+ XK0-006 exam objectives

  21. Question 21 of 25Multiple choiceDomain 5: Troubleshooting

    An application writes millions of small session files to /var. New files can no longer be created and fail with "No space left on device", yet df -h shows /var at only 41% used. What is the most likely cause?

    • A.The filesystem has run out of inodes; confirm with df -i
    • B.The disk has developed bad sectors; confirm with badblocks
    • C.The application user has exceeded a disk quota
    • D.The filesystem was remounted read-only after an error
    Show answer and explanation

    Correct answer: A

    Every file uses an inode. A filesystem with many tiny files can use up all of its inodes while plenty of block space remains, and the kernel then reports "No space left on device". df -i shows inode usage. A quota violation returns "Disk quota exceeded", and a read-only remount returns "Read-only file system". Bad sectors cause I/O errors, not this message alongside low block usage.

    Objective 5.2 · CompTIA Linux+ XK0-006 exam objectives

  22. Question 22 of 25Performance-based: matchDomain 5: Troubleshooting

    Match each troubleshooting task to the tool best suited to it. Each choice may be used once, more than once, or not at all.

    Choices (each may be used once, more than once, or not at all)

    • ss
    • dig
    • ip route
    • tcpdump
    • ethtool
    • mtr
    • iperf3

    Match these

    • 1.List listening TCP sockets and the processes that own them
    • 2.Query a specific DNS server for a host’s A record and see the full response
    • 3.Display the kernel routing table to confirm the default gateway
    • 4.Capture packets on an interface to see whether SYNs arrive from a client
    • 5.Check a NIC’s negotiated link speed and duplex
    Show answer and explanation
    • 1. List listening TCP sockets and the processes that own them → ss
    • 2. Query a specific DNS server for a host’s A record and see the full response → dig
    • 3. Display the kernel routing table to confirm the default gateway → ip route
    • 4. Capture packets on an interface to see whether SYNs arrive from a client → tcpdump
    • 5. Check a NIC’s negotiated link speed and duplex → ethtool

    ss -tlnp lists listening TCP sockets with owning processes. dig @server name A queries a chosen resolver and shows the answer, authority and flags. ip route shows the routing table, including the default route. tcpdump captures traffic on an interface. ethtool reports link speed, duplex and driver settings. mtr combines traceroute and ping to test the path, and iperf3 measures throughput between two hosts, so neither was needed here.

    Objective 5.3 · CompTIA Linux+ XK0-006 exam objectives

  23. Question 23 of 25Multiple choiceDomain 5: Troubleshooting

    On a RHEL server with SELinux in enforcing mode, an administrator moves web content from /home/webdev/site to /var/www/html with mv. Apache now returns 403 Forbidden for those files. Standard permissions are correct, and the audit log shows AVC denials for httpd. Which command is the best fix?

    • A.setenforce 0
    • B.chmod -R 777 /var/www/html
    • C.systemctl restart httpd
    • D.restorecon -Rv /var/www/html
    Show answer and explanation

    Correct answer: D

    mv keeps the files’ original SELinux context (user_home_t), and httpd is not allowed to read that type. restorecon resets the files to the default context defined for /var/www/html (httpd_sys_content_t), which fixes the denial. setenforce 0 turns off SELinux enforcement for the whole system instead of fixing the label. chmod 777 changes discretionary permissions, which were already correct, and weakens security. Restarting httpd does not change file labels.

    Objective 5.4 · CompTIA Linux+ XK0-006 exam objectives

  24. Question 24 of 25Multiple choiceDomain 5: Troubleshooting

    A 4-core database server feels sluggish. top shows a load average of about 12, user CPU (us) at 8%, and I/O wait (wa) at 65%. Which bottleneck is most likely, and how should it be investigated next?

    • A.A CPU-bound process; add more cores
    • B.Storage I/O; examine device utilization and latency with iostat -x
    • C.Network bandwidth saturation; examine interfaces with iperf3
    • D.An exhausted file descriptor limit; raise ulimit -n
    Show answer and explanation

    Correct answer: B

    A high wa value means the CPUs are idle while waiting for disk I/O to complete. On Linux, tasks blocked on I/O also count toward load average, which explains a high load with low user CPU. iostat -x shows per-device utilization and wait times to identify the slow device. A CPU-bound workload would show high us or sy values. Network saturation and file descriptor limits do not show up as I/O wait.

    Objective 5.5 · CompTIA Linux+ XK0-006 exam objectives

  25. Question 25 of 25Multiple choiceDomain 5: Troubleshooting

    An administrator has just added a new entry to /etc/fstab for a data filesystem. A typo in fstab previously caused this server to boot into emergency mode. Which command should be run before rebooting to confirm the new entry works?

    • A.umount -a
    • B.lsblk -f
    • C.mount -a
    • D.blkid
    Show answer and explanation

    Correct answer: C

    mount -a tries to mount every fstab entry that is not already mounted and not marked noauto, so a wrong UUID, mount point or option shows up as an error now rather than at boot. On systemd systems, run systemctl daemon-reload after editing fstab so the generated mount units match the file. findmnt --verify can also check the file. umount -a unmounts filesystems, and lsblk -f and blkid only display device and UUID information. They help when writing the entry but do not test it.

    Objective 5.2 · CompTIA Linux+ XK0-006 exam objectives

XK0-006 study guides

More free practice tests

CompCertQuiz is an independent practice-exam site and is not affiliated with, endorsed by, or sponsored by CompTIA. These questions are original material written for exam preparation and are not real exam questions. CompTIA and its certification names are trademarks of CompTIA, Inc.