CompTIA Linux+ (XK0-006) Practice Test
Frequently asked questions
How many CompTIA Linux+ (XK0-006) practice questions are here?+
A full bank of original CompTIA Linux+ (XK0-006) practice questions across the official content areas, weighted like the real exam, with explanations. Free, no signup.
What is the CompTIA Linux+ (XK0-006) exam like?+
About 90 questions, 90 minutes, and you need 720 / 900% to pass. Practice by topic here, then take the full timed mock exam to gauge readiness.
Are these the real exam questions?+
No. Every question is 100% original, written from public primary sources with explanations. We never copy real exam questions or paid prep material.
Can I study in Chinese or Spanish?+
PrepPass practice is in English, 中文 and Español. The official exam is in English — switch the question language to English any time to rehearse the exact terminology you'll see on test day.
Sample practice questions
A few real questions from this free bank, with full explanations. Use the practice tool above for the whole set.
- 1. System Management
Which directory in the Filesystem Hierarchy Standard is intended to hold variable data such as logs, spool files, and caches?
- a./etc
- b./var
- c./opt
- d./usr
Answer: b
Explanation: /var stores variable data that changes during normal operation, including /var/log, /var/spool, and /var/cache. /etc holds system configuration, /usr holds read-only user programs and libraries, and /opt holds optional add-on software packages.
- 2. System Management
Which systemctl command shows whether a service is set to start automatically at boot?
- a.systemctl is-enabled sshd
- b.systemctl status sshd --now
- c.systemctl is-active sshd
- d.systemctl mask sshd
Answer: a
Explanation: 'systemctl is-enabled' reports whether a unit is enabled to start at boot (enabled, disabled, static, masked, etc.). 'is-active' reports current runtime state rather than boot behavior, and 'mask' prevents a unit from being started at all.
- 3. System Management
In an /etc/fstab entry, which field value causes a filesystem to be checked by fsck first (before other filesystems) at boot?
- a.The dump field set to 1
- b.The pass (fsck order) field set to 1
- c.The mount options field set to defaults
- d.The pass field set to 0
Answer: b
Explanation: The sixth field in fstab is the fsck pass order: 1 is reserved for the root filesystem and is checked first, 2 for other filesystems, and 0 disables the check. The fifth (dump) field controls the legacy dump utility, not fsck ordering.
- 4. Troubleshooting
A process is consuming excessive CPU. Which command lets you interactively view and sort running processes by CPU usage in real time?
- a.top
- b.free
- c.uptime
- d.vmstat
Answer: a
Explanation: 'top' provides a live, interactive view of processes and can sort by CPU or memory usage. 'free' shows memory, 'uptime' shows load averages, and 'vmstat' prints periodic system statistics but is not an interactive process browser.
- 5. Troubleshooting
Users cannot resolve hostnames but can reach servers by IP. Which command directly tests DNS resolution?
- a.ip route
- b.dig www.example.com
- c.ss -s
- d.traceroute 8.8.8.8
Answer: b
Explanation: 'dig' queries DNS servers and returns resolution details, making it the direct tool for diagnosing name-resolution problems. 'ip route' inspects the routing table, 'ss -s' shows socket statistics, and 'traceroute' maps the network path by IP.
- 6. Services & User Management
Which command creates a new user with a home directory and sets bash as the login shell in one step?
- a.usermod -aG bash alice
- b.useradd -m -s /bin/bash alice
- c.passwd -m alice
- d.groupadd -s /bin/bash alice
Answer: b
Explanation: 'useradd -m -s /bin/bash alice' creates the account, makes the home directory (-m), and sets the login shell (-s). 'usermod' modifies an existing user, 'passwd' manages passwords, and 'groupadd' creates groups.
- 7. Services & User Management
What is the recommended way to grant a user limited sudo privileges safely?
- a.Add a file in /etc/sudoers.d/ edited with visudo
- b.Manually edit /etc/passwd to add root
- c.chmod 4777 /bin/su
- d.Add the user to /etc/shadow
Answer: a
Explanation: Placing a drop-in file in /etc/sudoers.d/ and editing it with visudo validates syntax before saving, preventing lockouts and keeping rules modular. Editing /etc/passwd or /etc/shadow does not grant sudo, and setting 4777 on /bin/su is a serious security hole.
- 8. Security
Which special permission bit, when set on a directory, ensures that only a file's owner (or root) can delete or rename files within it?
- a.SUID
- b.Sticky bit
- c.SGID
- d.Read-only bit
Answer: b
Explanation: The sticky bit (as on /tmp, shown as 't') restricts deletion so only the file owner, directory owner, or root can remove or rename entries. SUID and SGID affect execution identity and group inheritance, not deletion restrictions.
- 9. Security
In firewalld, which command permanently allows inbound HTTPS traffic in the default zone?
- a.firewall-cmd --permanent --add-service=https
- b.iptables -A INPUT -j DROP
- c.firewall-cmd --panic-on
- d.nft flush ruleset
Answer: a
Explanation: 'firewall-cmd --permanent --add-service=https' adds the https service to the zone's persistent configuration (apply with --reload). '--panic-on' blocks all traffic, 'iptables -A INPUT -j DROP' would drop packets, and 'nft flush ruleset' erases nftables rules.
- 10. Automation, Orchestration & Scripting
In a bash script, which variable holds the exit status of the most recently executed command?
- a.$#
- b.$?
- c.$!
- d.$0
Answer: b
Explanation: '$?' contains the exit status of the last command, where 0 means success and non-zero indicates an error. '$#' is the argument count, '$!' is the PID of the last background job, and '$0' is the script name.