Free CompTIA Linux+ Practice Test 2026 — XK0-005 Exam Questions

Master the CompTIA Linux+ XK0-005 exam with 500+ free practice questions covering all 5 official Linux+ domains. Each question includes a detailed explanation written by certified Linux administrators — no signup required.

CompTIA Linux+ XK0-005 Exam Overview

Practice by CompTIA Linux+ Domain

Domain 1: System Management (32%)

Free Linux+ practice questions on systemd, filesystems, LVM, kernel modules, networking with ip/nmcli, storage, RAID, and the Linux boot process. Practice this domain →

Domain 2: Security (21%)

Free Linux+ practice questions on file permissions, ACLs, SELinux, AppArmor, firewalld, iptables, SSH hardening, PAM, sudo, LUKS, and GPG encryption. Practice this domain →

Domain 3: Scripting, Containers, and Automation (19%)

Free Linux+ practice questions on Bash scripting, Git, Podman/Docker containers, Ansible, CI/CD pipelines, and Kubernetes basics. Practice this domain →

Domain 4: Services and User Management (16%)

Free Linux+ practice questions on user/group management, systemctl, journalctl, dnf/apt/rpm, cron, systemd timers, NFS, SMB, and Linux logging. Practice this domain →

Domain 5: Troubleshooting (12%)

Free Linux+ practice questions on dmesg, journalctl, top, htop, iostat, ss, tcpdump, boot recovery, and disk/memory/auth troubleshooting. Practice this domain →

8 Free CompTIA Linux+ Sample Questions with Answers

Each question below includes 4 answer options, the correct answer, and a detailed explanation. These are real questions from the FlashGenius CompTIA Linux+ XK0-005 question bank.

Sample Question 1 — Automation, Orchestration, and Scripting

Which command in Ansible is used to execute a playbook on a set of hosts?

  1. A. ansible-playbook (Correct answer)
  2. B. ansible-run
  3. C. ansible-execute
  4. D. ansible-deploy

Correct answer: A

Explanation: The correct command to execute a playbook in Ansible is 'ansible-playbook'. This command runs the playbook on the specified hosts. The other options are incorrect because 'ansible-run', 'ansible-execute', and 'ansible-deploy' are not valid Ansible commands.

Sample Question 2 — Automation, Orchestration, and Scripting

In a hybrid cloud infrastructure using Kubernetes, which YAML key is used to specify the number of replicas for a deployment?

  1. A. replicaCount
  2. B. instances
  3. C. replicas (Correct answer)
  4. D. count

Correct answer: C

Explanation: In Kubernetes, the 'replicas' key is used within a deployment YAML to specify the number of pod replicas that should be running. 'replicaCount', 'instances', and 'count' are not valid keys for this purpose in Kubernetes deployment configurations.

Sample Question 3 — Security

Which command is used to modify the SELinux mode to 'permissive' on a RHEL-based system?

  1. A. setenforce 0 (Correct answer)
  2. B. selinux-configure permissive
  3. C. selinux-mode permissive
  4. D. setenforce permissive

Correct answer: A

Explanation: The correct command to set SELinux to 'permissive' mode is 'setenforce 0'. This command temporarily changes the SELinux mode until the next reboot. Option B is incorrect because there is no such command as 'selinux-configure'. Option C is incorrect because 'selinux-mode' is not a valid command. Option D is incorrect because 'setenforce' requires a numeric value, not a string.

Sample Question 4 — Security

You need to configure a firewall on a CentOS server to allow incoming SSH connections. Which command should you use?

  1. A. firewall-cmd --add-service=ssh --permanent (Correct answer)
  2. B. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
  3. C. ufw allow ssh
  4. D. systemctl enable ssh

Correct answer: A

Explanation: On CentOS, 'firewall-cmd --add-service=ssh --permanent' is used to allow SSH connections through the firewall. Option B uses iptables, which is not the recommended method on CentOS systems using firewalld. Option C uses 'ufw', which is not the default firewall on CentOS. Option D enables the SSH service but does not configure the firewall.

Sample Question 5 — Services and User Management

Which command would you use to change the default runlevel on a CentOS 7 system?

  1. A. systemctl set-default multi-user.target (Correct answer)
  2. B. systemctl isolate graphical.target
  3. C. systemctl enable multi-user.target
  4. D. systemctl start multi-user.target

Correct answer: A

Explanation: The command 'systemctl set-default multi-user.target' is used to change the default runlevel on a systemd-based system like CentOS 7. 'systemctl isolate' would change the current runlevel but not set the default. 'systemctl enable' is used for enabling services, and 'systemctl start' is used to start services, not change runlevels.

Sample Question 6 — Services and User Management

On a RHEL server, you need to create a new user that should not have a home directory. Which command would achieve this?

  1. A. useradd -M newuser (Correct answer)
  2. B. useradd -m newuser
  3. C. useradd --home /dev/null newuser
  4. D. useradd -N newuser

Correct answer: A

Explanation: The 'useradd -M' command creates a new user without creating a home directory. The '-m' option creates a home directory, '--home /dev/null' would set the home directory to /dev/null, which is not a typical or recommended location, and '-N' is not a valid option for this purpose.

Sample Question 7 — System Management

Which command would you use to list all currently loaded kernel modules in a Linux system?

  1. A. lsmod (Correct answer)
  2. B. modprobe
  3. C. insmod
  4. D. rmmod

Correct answer: A

Explanation: The 'lsmod' command is used to list all currently loaded kernel modules. 'modprobe' is used to add or remove modules from the kernel, 'insmod' is used to insert a module into the Linux kernel, and 'rmmod' is used to remove a module from the Linux kernel.

Sample Question 8 — System Management

In a hybrid cloud environment, which tool would you primarily use to automate the deployment of containers?

  1. A. Ansible
  2. B. Docker
  3. C. Kubernetes (Correct answer)
  4. D. Terraform

Correct answer: C

Explanation: Kubernetes is a platform designed for automating the deployment, scaling, and operation of application containers across clusters of hosts. Ansible and Terraform are used for automation and infrastructure as code but are not specifically for container orchestration. Docker is used for building and running containers but not for orchestrating them across a cluster.

Quick 10-Question Linux+ Practice Test

Take a free 10-question CompTIA Linux+ quick-start practice test covering all 5 XK0-005 domains. Get instant scoring with detailed explanations — perfect for a quick readiness check.

Why Choose FlashGenius for CompTIA Linux+?

Start your free CompTIA Linux+ practice test now | CompTIA Linux+ Cheat Sheet | All Sample Tests