Home  /  Blog

8 CompTIA Linux+ Questions Most Candidates Get Wrong

Security certifications·6 min read·PractiseExam

Here are 8 multiple-choice questions designed to mirror the difficulty, style, and domain coverage of the CompTIA Linux+ (XK0-005) exam. The questions cover system administration, security, scripting, and troubleshooting.


These questions are designed to test not just rote memorization, but your ability to apply Linux concepts in practical, scenario-based situations, just like the real exam. Pay close attention to the specific wording, as the "best" answer is often the one that is most efficient or secure, not just technically possible. We recommend pairing this with 10 CompTIA SecurityX Questions Most Candidates Get Wrong.

Question 1

A systems administrator needs to locate all files over 100 MB in size within the /var directory tree. Which command would accomplish this task most efficiently?

A. find /var -size +100M

B. ls -laR /var | grep 100M

C. du -ah /var | sort -nr | head -20

D. locate /var -size 100M

Answer: A

Explanation: The find command is designed for this exact purpose, using the -size +100M test to locate files larger than 100 MB. While du can list sizes, it doesn't filter by size directly and would require additional parsing; ls doesn't filter by size; locate searches by name, not size.


Question 2

A user reports that they cannot run sudo commands, but they are listed in the sudo group. Which file directly controls the permissions and privileges for users in the sudo group?

A. /etc/group

B. /etc/passwd

C. /etc/sudoers

D. /etc/sudoers.d

Answer: C

Explanation: The /etc/sudoers file is the primary configuration file for sudo privileges, typically containing a line like %sudo ALL=(ALL:ALL) ALL to grant the group its rights. While /etc/group defines the group membership, and /etc/sudoers.d can contain drop-in files, the core policy that grants the sudo group its power is defined in /etc/sudoers itself. Modifying group membership alone won't grant privileges if the policy isn't there.

While sudo policy is a key part of system security, a free CompTIA Linux+ readiness check can reveal which other topics need more review.


Question 3

A developer needs to deploy a new application that requires a specific older version of Python (3.8) on a system that currently has Python 3.11 as the default. Which tool is designed to manage multiple versions of software like this without breaking the system-wide installation?

A. apt

B. dnf

C. update-alternatives

D. make install For a deeper dive, check out 10 SC-900 Questions Most Candidates Get Wrong.

Answer: C

Explanation: The update-alternatives command is specifically designed to manage symbolic links for different versions of the same software, allowing the administrator to switch between them. Package managers like apt or dnf install a single version by default, and make install compiles from source but doesn't manage multiple versions in a coordinated way.


Question 4

During system boot, a message indicates a systemd service failed to start. Which command would you use to see the last 50 lines of logs specifically for that unit, named httpd.service?

A. tail -50 /var/log/messages

B. journalctl -u httpd.service -n 50

C. systemctl status httpd.service | tail -50

D. dmesg | grep httpd

Answer: B

Explanation: journalctl is the primary tool for querying the systemd journal, and the -u flag filters by the specific unit, with -n 50 limiting the output to the last 50 lines. While systemctl status shows some logs, it doesn't show 50 by default; /var/log/messages is a general log file; dmesg is for kernel messages.


Question 5

A security audit requires that all users must change their passwords every 90 days. Which command would set this policy for the user jsmith?

A. passwd -x 90 jsmith

B. chage -M 90 jsmith

C. usermod -e 90 jsmith

D. chattr +i 90 jsmith

Answer: B

Explanation: The chage command is specifically for managing password aging, and the -M option sets the maximum number of days a password is valid. The passwd command's -x flag is for setting the maximum age, but it's more common and correct to use chage for this; usermod -e sets an account expiry date, not a password policy; chattr sets file attributes.


Question 6

A shell script needs to check if a specific directory, /opt/app/data, exists. If it does not, the script should create it. Which code snippet correctly implements this logic?

A. if [ -d /opt/app/data ]; then mkdir /opt/app/data; fi

B. if [ ! -e /opt/app/data ]; then mkdir /opt/app/data; fi This topic pairs well with 8 CISM Questions Most Candidates Get Wrong.

C. if [ -f /opt/app/data ]; then mkdir -p /opt/app/data; fi

D. if [ ! -d /opt/app/data ]; then mkdir -p /opt/app/data; fi

Answer: D

Explanation: The -d test checks if a file exists and is a directory. The ! negates the test, so the if statement executes the mkdir command only when the directory does not exist. Option B uses -e which only checks for existence (file or dir), which would work but is less precise; option A has the logic reversed; option C tests for a regular file (-f), which is incorrect.


Question 7

An administrator needs to transfer a large directory tree, including all permissions and ownership, from a legacy server to a new server over an encrypted connection. Which command is the most appropriate?

A. scp -r /data user@newserver:/data

B. rsync -avz /data user@newserver:/data

C. cp -rp /data /mnt/backup

D. sftp -r /data user@newserver:/data

Answer: B

Explanation: rsync is the best choice for this task because it is designed for efficient, incremental file transfers, and the -a (archive) flag preserves permissions, ownership, and timestamps. It uses SSH for encryption, just like scp and sftp. While scp can copy recursively, it doesn't have the same level of integrity checking and efficiency for large data sets; cp is local only; sftp is interactive and not as well-suited for a one-shot, recursive copy of a huge tree.


Question 8

When a user types a command, the shell searches for the executable file. Which environment variable defines the order and set of directories the shell searches?

A. SHELL

B. HOME

C. PATH

D. BASH_ENV

Answer: C

Explanation: The PATH environment variable is a colon-separated list of directories. When a command is typed without a full path, the shell searches these directories in the order they are listed to find the executable. The other variables define the user's default shell, home directory, and startup file, respectively, and are not used for command lookup.


These questions represent the analytical depth required for the Linux+ exam. Remember to focus on the why behind each command and concept, not just the what. Understanding the underlying system architecture and the purpose of each tool is key to passing on the first attempt.

As you prepare for the exam, a free CompTIA Linux+ study plan gives you a schedule that fits your available time.

Refine your approach with CompTIA Linux+ exam questions — they show not just what to know, but how questions are asked.

CompTIACompTIA Linux+practice-qSecurity & Governance