CompTIA XK0-005 Practice Test

Prepare smarter and boost your chances of success with our CompTIA XK0-005 Practice test. This test helps you assess your knowledge, pinpoint strengths, and target areas for improvement. Surveys and user data from multiple platforms show that individuals who use XK0-005 practice exam are 40–50% more likely to pass on their first attempt.

Start practicing today and take the fast track to becoming CompTIA XK0-005 certified.

14760 already prepared
Updated On : 3-Nov-2025
476 Questions
4.8/5.0

Page 14 out of 48 Pages

Think You're Ready?

Your Final Exam Before the Final Exam.
Dare to Take It?

User1 is a member of the accounting group. Members of this group need to be able to execute but not make changes to a script maintained by User2. The script should not be accessible to other users or groups. Which of the following will give proper access to the script?

A.

chown user2:accounting script.sh
chmod 750 script.sh

B.

chown user1:accounting script.sh
chmod 777 script.sh

C.

chown accounting:user1 script.sh
chmod 057 script.sh

D.

chown user2:accounting script.sh
chmod u+x script.sh

C.   

chown accounting:user1 script.sh
chmod 057 script.sh



Summary:
User2 maintains a script that the accounting group needs to run without modifying it. The script must be inaccessible to all other users (others). The solution requires two steps: first, setting the correct ownership so the group has inherent rights, and second, applying the precise permissions to allow the owner (User2) full control, the group to read and execute, and others to have no access.

Correct Option:

A. chown user2:accounting script.sh chmod 750 script.sh:
This is the correct sequence of commands.

chown user2:accounting script.sh sets the owner to user2 and the group to accounting.

chmod 750 script.sh sets the permissions numerically: 7 (rwx) for the owner (user2), 5 (r-x) for the group (accounting), and 0 (---) for others. This allows the group to read and execute the script but not write to (modify) it, and blocks all access for everyone else.

Incorrect Options:

B. chown user1:accounting script.sh chmod 777 script.sh:
This is incorrect for multiple reasons. First, it changes ownership to user1, taking it away from the maintainer, user2. Second, chmod 777 gives read, write, and execute permissions to everyone (owner, group, and others), which violates the security requirement that the script should not be accessible to other users or groups.

C. chown accounting:user1 script.sh chmod 057 script.sh:
This command has a syntactically incorrect chown (the format is user:group). Furthermore, the chmod 057 permission is illogical. It gives no permissions to the owner (0), read and execute to the group (5), and read, write, and execute to others (7). This is the opposite of the desired security model.

D. chown user2:accounting script.sh chmod u+x script.sh:
While the chown command is correct, the chmod command is insufficient. chmod u+x only adds the execute permission for the owner (user2). It does not explicitly grant the accounting group the ability to read and execute the script, nor does it explicitly remove permissions for "others."

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario directly tests Objective 3.2: "Given a scenario, manage storage, files, and directories in a Linux environment," which includes managing file and directory permissions as well as ownership. Understanding numeric (octal) permission modes like 750 is a key skill for this objective.

A systems administrator needs to reconfigure a Linux server to allow persistent IPv4 packet forwarding. Which of the following commands is the correct way to accomplish this task?

A.

echo 1 > /proc/sys/net/ipv4/ipv_forward

B.

sysctl -w net.ipv4.ip_forward=1

C.

firewall-cmd --enable ipv4_forwarding

D.

systemctl start ipv4_forwarding

B.   

sysctl -w net.ipv4.ip_forward=1



Summary:
The task requires enabling IPv4 packet forwarding and making the change persistent across reboots. Packet forwarding is a kernel parameter controlled by the net.ipv4.ip_forward setting. The correct command must change this runtime parameter and ensure the change is written to the system's configuration so it survives a restart.

Correct Option:

B. sysctl -w net.ipv4.ip_forward=1:
This is the correct command. The sysctl command is used to modify kernel parameters at runtime. The -w flag writes the value. More importantly, to make it persistent, the administrator must also add net.ipv4.ip_forward = 1 to the /etc/sysctl.conf file or a file in /etc/sysctl.d/. The sysctl command itself is the standard tool for this task, and using it is the first step in the persistent configuration process.

Incorrect Options:

A. echo 1 > /proc/sys/net/ipv4/ip_forward:
This command will enable packet forwarding immediately by writing directly to the virtual file in /proc/sys/. However, this change is only temporary and will be lost after a system reboot. It does not accomplish the "persistent" requirement.

C. firewall-cmd --enable ipv4_forwarding:
This is not a valid firewall-cmd command. firewall-cmd is used to configure firewalld zones and rules, not to set core kernel networking parameters like IP forwarding. The correct flag for masquerading or forwarding in firewalld is different (--add-masquerade).

D. systemctl start ipv4_forwarding:
There is no systemd service called ipv4_forwarding. IP forwarding is a kernel parameter, not a service that can be started or stopped.

Reference:
Linux man-pages project (sysctl): The official documentation explains how to use sysctl to configure kernel parameters.

A Linux administrator modified the SSH configuration file. Which of the following commands should be used to apply the configuration changes?

A.

systemctl stop sshd

B.

systemctl mask sshd

C.

systemctl reload sshd

D.

systemctl start sshd

C.   

systemctl reload sshd



Summary:
After modifying a service's configuration file (in this case, for the SSH daemon, sshd), the service needs to be made aware of the new settings. The goal is to apply the changes without causing a full service interruption that would drop existing user connections. The correct command will gracefully instruct the service to reload its configuration file while maintaining its current running state and active sessions.

Correct Option:

C. systemctl reload sshd:
This is the correct command. The reload instruction sends a specific signal (SIGHUP) to the sshd process. This signal tells the SSH daemon to reread its configuration file (sshd_config) and apply the new settings without shutting down. Crucially, it maintains existing connections, only applying the new configuration to subsequent connection attempts.

Incorrect Options:

A. systemctl stop sshd:
This command would completely stop the SSH service. This would terminate all active SSH connections and prevent any new ones from being established until the service is started again. It is overly disruptive for a simple configuration change.

B. systemctl mask sshd:
This command does not apply configuration changes; it prevents the service from being started, manually or automatically. A masked service cannot be started until it is unmasked. This is a administrative lock, not a method for applying configs.

D. systemctl start sshd:
This command is used to start a service that is currently stopped. If the service is already running (as it would be after a configuration edit), this command would typically fail or have no effect. It does not force a reload of the configuration.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 3.1: "Given a scenario, use the appropriate system and service management commands to accomplish administrative tasks," which includes managing and troubleshooting systemd services. Knowing the difference between restart, reload, and stop/start is critical for applying configuration changes with minimal service impact.

A cloud engineer needs to check the link status of a network interface named eth1 in a Linux server. Which of the following commands can help to achieve the goal?

A.

ifconfig hw eth1

B.

netstat -r eth1

C.

ss -ti eth1

D.

ip link show eth1

D.   

ip link show eth1



Summary:
The engineer needs to verify the operational state of a specific network interface (eth1), specifically whether it has a physical/link-layer connection (carrier detection) and if the interface is administratively "UP". This requires a command that displays low-level network device information, including the link state flags.

Correct Option:

D. ip link show eth1:
This is the modern and correct command for this task. It displays the state of the network interface eth1. The output will show flags like UP (administratively enabled) and LOWER_UP (which indicates a physical link is detected), providing a clear view of the link status.

Incorrect Options:

A. ifconfig hw eth1:
The ifconfig command is considered deprecated. The hw option is used to set the hardware address (MAC address), not to display the link status. The standard ifconfig eth1 command shows some status information but the ip link command is more reliable and detailed for link state.

B. netstat -r eth1:
The netstat -r command displays the kernel routing table. It does not take an interface name as a filter in this way and does not show physical link status information.

C. ss -ti eth1:
The ss command is used to dump socket statistics. The -t flag is for TCP sockets, and -i shows internal TCP information. It is used for analyzing network connections, not for checking the physical or administrative state of a network interface.

Reference:
Linux man-pages project (ip-link): The official documentation for the ip link command, which is used to manage network devices.

A systems administrator is checking the system logs. The administrator wants to look at the last 20 lines of a log. Which of the following will execute the command?

A. tail -v 20

B. tail -n 20

C. tail -c 20

D. tail -l 20

B.   tail -n 20

Summary:
The administrator needs to view the most recent entries at the end of a log file. The tail command is specifically designed for this purpose, showing the last part of files by default. The correct command must use the appropriate option to specify the number of lines to display from the end of the file.

Correct Option:

B. tail -n 20:
This is the standard and correct command. The -n flag (number) instructs tail to output the last specified number of lines. Therefore, tail -n 20 [logfile] will display the last 20 lines of the given log file, which is exactly what the administrator wants to do.

Incorrect Options:

A. tail -v 20:
The -v (verbose) flag is used to always output headers giving file names. It is not used to specify the number of lines and is irrelevant to the task of limiting output to 20 lines.

C. tail -c 20:
The -c flag (bytes) outputs the last specified number of bytes from the file, not lines. This would show a fragmented, partial line and is not the intended way to view the last 20 log entries.

D. tail -l 20:
There is no -l (lowercase L) flag in the standard tail command. This is an invalid option and will result in an error.

Reference:
Linux man-pages project (tail): The official documentation explains the -n option for outputting the last N lines.

A Linux administrator is adding a new configuration file to a Git repository. Which of the following describes the correct order of Git commands to accomplish the task successfully?

A.

pull -> push -> add -> checkout

B.

pull -> add -> commit -> push

C.

checkout -> push -> add -> pull

D.

pull -> add -> push -> commit

B.   

pull -> add -> commit -> push



Summary:
The task is to add a new configuration file to a Git repository, which is a standard version control operation. The correct sequence must ensure the local repository is up-to-date, stage the new file, permanently save the change locally, and then upload that change to the remote repository for collaboration.

Correct Option:

B. pull -> add -> commit -> push:
This is the standard and correct sequence for contributing a change.

pull: First, integrate the latest changes from the remote repository to avoid conflicts.

add: Stage the new configuration file, telling Git to start tracking it.

commit: Permanently save the staged file to the local repository's history with a descriptive message.

push: Upload the local commit(s) to the remote repository to share the change with others.

Incorrect Options:

A. pull -> push -> add -> checkout:
This sequence is illogical. You cannot push before you have staged (add) and saved (commit) your changes. checkout is used for switching branches, not for adding new files.

C. checkout -> push -> add -> pull:
This order is incorrect. It attempts to push with no committed changes and stages the file (add) only after trying to push. The pull command is also performed too late, after other actions have already been attempted.

D. pull -> add -> push -> commit:
This sequence is invalid. The push command only sends committed changes to the remote server. You cannot push changes that have only been staged (add) but not yet committed.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This question aligns with Objective 1.2: "Given a scenario, perform version control using Git," which requires candidates to know the basic Git workflow and the function of common commands like pull, add, commit, and push. The official Git website, git-scm.com, is the canonical reference for this process.

A systems administrator installed a new software program on a Linux server. When the systems administrator tries to run the program, the following message appears on the screen.

Which of the following commands will allow the systems administrator to check whether the system supports virtualization?

A.

dmidecode -s system-version

B.

lscpu

C.

sysctl -a

D.

cat /sys/device/system/cpu/possible

B.   

lscpu



Summary:
The error message indicates the program cannot run because virtualization (KVM) is not available. This is typically due to the CPU lacking hardware virtualization support (Intel VT-x or AMD-V) or it being disabled in the BIOS. The administrator needs a command to check the CPU's features and capabilities to determine if virtualization is supported and enabled at the hardware level.

Correct Option:

B. lscpu:
This is the best command for this task. lscpu displays detailed information about the CPU architecture and its features. The administrator should look for Virtualization in the output (e.g., VT-x for Intel or AMD-V for AMD), which confirms hardware support. It also shows if hypervisor support is present.

Incorrect Options:

A. dmidecode -s system-version:
This command queries the DMI (SMBIOS) table to display only the system version string (e.g., the server model). It does not provide information about CPU features like virtualization support.

C. sysctl -a:
This command displays all kernel parameters. While it shows a vast amount of system information, it is not the most direct way to check for CPU hardware virtualization flags. The output is also very verbose and difficult to parse for this specific information.

D. cat /sys/device/system/cpu/possible:
This file shows the range of possible CPUs on the system (e.g., "0-3" for 4 cores). It does not provide any information about the features or capabilities of those CPUs, such as virtualization support.

Reference:
Linux man-pages project (lscpu): The official documentation describes lscpu as a command that displays information about the CPU architecture, including flags and virtualization features.

A Linux administrator wants to set the SUID of a file named dev_team.text with 744 access rights. Which of the following commands will achieve this goal?

A.

chmod 4744 dev_team.txt

B.

chmod 744 --setuid dev_team.txt

C.

chmod -c 744 dev_team.txt

D.

chmod -v 4744 --suid dev_team.txt

A.   

chmod 4744 dev_team.txt



Summary:
The administrator needs to set two distinct permissions on a file: the standard "744" access rights (owner: rwx, group: r--, others: r--) and the special SUID (Set User ID) bit. In the numeric (octal) mode used by chmod, special permissions (SUID, SGID, Sticky Bit) are represented by an extra digit prepended to the standard three-digit permission code. The SUID bit is represented by the number 4.

Correct Option:

A. chmod 4744 dev_team.txt:
This is the correct command. The four-digit octal mode 4744 breaks down as follows:

The first digit (4) sets the SUID bit.

The next three digits (744) set the standard permissions: 7 (rwx) for the owner, 4 (r--) for the group, and 4 (r--) for others.

This command achieves both requirements in a single, standard operation.

Incorrect Options:

B. chmod 744 --setuid dev_team.txt:
The chmod command does not have a --setuid option. Special permissions like SUID are set using the numeric prefix or the u+s symbolic notation, not with a long-format flag.

C. chmod -c 744 dev_team.txt:
The -c flag only provides a verbose output if a change is made. The permission mode 744 does not include the SUID bit (it would be 4744), so this command would only set the standard 744 permissions, not the SUID.

D. chmod -v 4744 --suid dev_team.txt:
Similar to option B, --suid is not a valid option for the chmod command. The -v flag is for verbose output, but the --suid flag is redundant and incorrect because the SUID is already specified by the leading 4 in the 4744 octal mode.

Reference:
Linux man-pages project (chmod): The official documentation explains the numeric mode, including the optional leading digit for setting special bits.

Which of the following is a function of a bootloader?

A.

It initializes all the devices that are required to load the OS.

B.

It mounts the root filesystem that is required to load the OS.

C.

It helps to load the different kernels to initiate the OS startup process.

D.

It triggers the start of all the system services.

C.   

It helps to load the different kernels to initiate the OS startup process.



Summary:
A bootloader is a small program that resides in the Master Boot Record (MBR) or EFI system partition. Its primary job is to bridge the gap between the computer's firmware (BIOS/UEFI) and the full operating system. After the firmware completes its hardware checks, it hands control to the bootloader, which is responsible for the next critical step in the startup process.

Correct Option:

C. It helps to load the different kernels to initiate the OS startup process:
This is the core, defining function of a bootloader. The bootloader's main task is to locate the operating system's kernel on the storage device, load it into memory, and then transfer control to it. Advanced bootloaders like GRUB can also present a menu to let users choose between different kernels or operating systems.

Incorrect Options:

A. It initializes all the devices that are required to load the OS:
This is the function of the computer's firmware (BIOS/UEFI). The firmware performs the Power-On Self-Test (POST) and initializes critical hardware before the bootloader even starts.

B. It mounts the root filesystem that is required to load the OS:
The bootloader itself does not mount the root filesystem. It loads the kernel and an initial RAM disk (initramfs), which contains the necessary drivers and tools to mount the root filesystem later in the boot process.

D. It triggers the start of all the system services:
This is the job of the init system (like systemd or SysVinit), which is the first process started by the kernel (PID 1). The bootloader's role is complete once the kernel is loaded and executing.

Reference:
GNU GRUB Manual: The documentation for GRUB, the most common Linux bootloader, describes its purpose as loading an operating system kernel.

A systems administrator requires that all files that are created by the user named web have read-only permissions by the owner. Which of the following commands will satisfy this requirement?

A.

chown web:web /home/web

B.

chmod -R 400 /home/web

C.

echo "umask 377" >> /home/web/.bashrc

D.

setfacl read /home/web

C.   

echo "umask 377" >> /home/web/.bashrc



Summary:
The requirement is to ensure that any new file created by the user web automatically has read-only permissions for the owner. This is not about changing existing files, but about setting a default permission for future files. The umask (user file creation mask) is the kernel variable that controls the default permissions for newly created files and directories by subtracting its value from the base permissions.

Correct Option:

C. echo "umask 377" >> /home/web/.bashrc:
This is the correct solution. The umask value is subtracted from the base permissions (typically 666 for files). A umask of 377 (octal) means:

Files: 666 - 377 = 400 (r-------- or read-only for owner)

By adding this command to /home/web/.bashrc, it sets this umask for every login shell the web user starts, ensuring all new files they create will have the required read-only permission for the owner.

Incorrect Options:

A. chown web:web /home/web:
This command changes the ownership of the /home/web directory to the user and group web. It does not affect the permissions of files within the directory, either existing or new.

B. chmod -R 400 /home/web:
This command recursively sets all existing files and directories in /home/web to read-only for the owner. However, it does not affect new files created afterward. Furthermore, applying 400 to directories would break them, as directories require the execute bit (x) to be accessible.

D. setfacl read /home/web:
This command is syntactically incorrect and does not make sense. setfacl is for setting Access Control Lists, but the syntax used is invalid. Even a correct ACL command would likely manage access for other users, not the default permissions for the owning user.

Reference:
Bash Reference Manual (Bash Builtins): The official documentation describes umask as a builtin command that sets the file creation mask.

Page 14 out of 48 Pages
XK0-005 Practice Test Previous