CompTIA Linux+ Practice Test (XK0-005)
Use the form below to configure your CompTIA Linux+ Practice Test (XK0-005). The practice test can be configured to only include certain exam objectives and domains. You can choose between 5-100 questions and set a time limit.

CompTIA Linux+ XK0-005 Information
CompTIA Linux+ (XK0-005) Exam
The CompTIA Linux+ (XK0-005) certification is designed for IT professionals who work with Linux systems. It validates skills in system administration, security, scripting, and troubleshooting. This certification is vendor-neutral, covering multiple distributions such as Ubuntu, CentOS, and Red Hat.
Exam Overview
The XK0-005 exam consists of a maximum of 90 questions, including multiple-choice and performance-based questions. Candidates have 90 minutes to complete the test. The exam costs $358 USD. A passing score is 720 on a scale of 100 to 900. The certification is valid for three years and can be renewed through CompTIA’s continuing education program.
Exam Content
The XK0-005 exam focuses on five main domains: system management, security, scripting and automation, troubleshooting, and Linux fundamentals. System management includes package management, system monitoring, and user administration. Security covers permissions, authentication, and encryption. Scripting and automation focus on Bash scripting and task automation. Troubleshooting tests problem-solving skills for system failures and performance issues. Linux fundamentals include file system hierarchy, networking, and command-line operations.
Who Should Take This Exam?
The CompTIA Linux+ certification is ideal for system administrators, Linux support technicians, and DevOps professionals. It is recommended for individuals with at least one year of Linux experience. This certification is beneficial for IT professionals working with servers, cloud infrastructure, and cybersecurity.
How to Prepare
Candidates should review the official CompTIA Linux+ Exam Objectives and study materials provided by CompTIA. Hands-on experience with Linux systems is essential. Practice exams can help assess readiness and identify weak areas. Using Linux in a lab or virtual environment can provide practical experience with commands, system configuration, and troubleshooting.
Summary
The CompTIA Linux+ (XK0-005) certification is a valuable credential for IT professionals working with Linux systems. It validates essential skills in system administration, security, and automation. This certification is ideal for those managing Linux-based environments in IT infrastructure, cybersecurity, and cloud computing.
Scroll down to see your responses and detailed results
Free CompTIA Linux+ XK0-005 Practice Test
Press start when you are ready, or press Change to modify any settings for the practice test.
- Questions: 15
- Time: Unlimited
- Included Topics:System ManagementSecurityScripting, Containers, and AutomationTroubleshooting
A systems administrator needs to investigate an issue in a Docker container that is failing to start correctly. The administrator wishes to view the output logs to diagnose the problem. Which command should the administrator run to display the last 50 lines of logs from the container named 'web-app'?
- You selected this option
docker inspect --format='{{.LogPath}}' web-app
- You selected this option
docker logs -f web-app | tail -50
- You selected this option
docker logs --tail 50 web-app
- You selected this option
docker container logs web-app --last 50
Answer Description
The correct answer is docker logs --tail 50 web-app
. The --tail
option with the docker logs
command allows the user to view the specified number of most recent lines from the container's logs, making it an appropriate choice for checking recent activity or errors that could lead to understanding the issue with the container.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the 'docker logs' command?
What does the '--tail' option do in the 'docker logs' command?
How does 'docker logs' differ from 'docker inspect'?
What command is used in a shell script to perform actions based on whether a particular condition is met or not?
- You selected this option
if
- You selected this option
while
- You selected this option
case
- You selected this option
for
Answer Description
The if
command is used to execute conditional statements in a shell script, allowing the script to branch and perform different actions based on whether specified conditions are true or not. The while
command is used for loops that continue as long as the condition is true. for
is also a looping command but iterates over a list of values. case
is used for matching a variable against a series of patterns, not specifically for a conditional statement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What syntax do I use with the `if` command in a shell script?
Can you clarify what types of conditions can be used with the `if` command?
How does the `else` statement work in conjunction with `if`?
In the scenario where a Linux system has multiple services running, which of the following actions is the BEST practice to secure the corresponding service accounts?
- You selected this option
Changing the home directory permissions of service accounts to 700.
- You selected this option
Setting a strong, unique password for each service account.
- You selected this option
Configuring PAM modules to limit the access times for service accounts.
- You selected this option
Changing the default shell of the service accounts to
/bin/nologin
.
Answer Description
Setting a strong, unique password for service accounts is essential as it ensures that each service has its distinct access credentials, which can prevent unauthorized access if one service is compromised. Locking service accounts with shell access adds an additional layer of security. Disabling login capabilities entirely for service accounts is the most secure practice because it mitigates the risk of these accounts being used to gain unauthorized system access. While changing the default shell to /bin/false
or nologin
reduces the functionality of the account for interactive use, it does not prevent the account from executing its service-related tasks. The reason this is the best practice is that it does not rely on password strength or the potential for a password to be compromised, as it altogether disables the ability for the service account to be used for direct logins. Service accounts should not be used for interactive logins, and their purpose is to run the corresponding service. Changing the home directory permissions and using PAM modules are also good security practices, but they do not restrict login capabilities as effectively as setting the shell to nologin
.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are service accounts in Linux?
What does changing the shell to `/bin/nologin` do?
Why is it important to set strong, unique passwords for service accounts?
A system administrator is deploying a multi-container application on a single Docker host. The application includes a web server container that needs to communicate with a database container. Both containers should be isolated from other network traffic on the Docker host. Which Docker network driver should the administrator use to fulfill these requirements?
- You selected this option
Default bridge
- You selected this option
Host
- You selected this option
Bridge
- You selected this option
Overlay
Answer Description
The correct answer is 'Bridge' because the bridge network driver provides a private network internal to the host machine, allowing containers connected to the same bridge network to communicate with each other while isolating them from other containers not connected to the bridge. The default bridge network does not provide isolation between containers, which is why it is necessary to create a user-defined bridge network for this scenario. The 'Overlay' network driver is used for networking between multiple Docker hosts, which is not the requirement here. The 'Host' mode removes network isolation and uses the host's networking directly, which does not meet the requirement for network isolation. 'Host' mode also would not use NAT because the containers would share the network with the host. Therefore, the 'Host' network driver is not suitable for this scenario.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a Docker network driver?
How do I create a user-defined bridge network in Docker?
What is the difference between the default bridge and a user-defined bridge in Docker?
What is the primary function of the groupmod
command in a Linux environment?
- You selected this option
To modify a group's name or GID (Group ID)
- You selected this option
To create a new user account on the system
- You selected this option
To add or remove a user from a group
- You selected this option
To modify file permissions for a group of files
Answer Description
The groupmod
command is used to modify a group's details, such as its name or Group ID (GID). Knowledge of this command is crucial for system administrators when they need to manage group information and its related security implications. For example, changing a group's name might be necessary when organizational roles change or to correct errors in naming conventions. The incorrect options provided are related to user and file management, not directly to groups, which may lead to confusion, but understanding groupmod
pertains specifically to group modifications.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a GID and why is it important in Linux?
How does the `groupmod` command affect user permissions?
What are some common use cases for the `groupmod` command?
A system administrator is tasked with restricting access to a web server running on the default HTTP port to only the IP range 192.168.100.0/24. The server is currently using firewalld
for its firewall management. Which of the following commands should the administrator use to accomplish this task?
- You selected this option
firewall-cmd --permanent --zone=public --add-service=http --source=192.168.100.0/24
- You selected this option
firewall-cmd --permanent --zone=public --add-source=192.168.100.256/24
- You selected this option
firewall-cmd --permanent --new-zone=192.168.100.0/24
- You selected this option
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="80" accept'
Answer Description
The correct answer, firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="80" accept'
, creates a persistent (--permanent
) rule for the public zone in firewalld
that uses a rich-rule to enable access on TCP port 80 for the source IP range of 192.168.100.0/24. This ensures that only devices with an IP from this range can access the HTTP service. The other options are incorrect for the following reasons: The first incorrect option attempts to add a service by name, which is not how IP-based restrictions are set. The second incorrect option adds an entire zone instead of the specific rule needed for the IP range. The last incorrect option contains an invalid subnet mask for the given IP range.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is 'firewalld' and how does it work?
What are rich rules in 'firewalld'?
What does the subnet notation '192.168.100.0/24' mean?
A Linux server cannot establish connections to devices located on another segment of the network. Upon inspection, you discover that the server has been assigned an address of 192.168.1.126 with a mask indicating it can host up to 126 devices. A noted detail is that the segment's gateway resides at 192.168.1.129. What is the BEST explanation for this connectivity issue?
- You selected this option
The server is assigned the special address of its subnet that denotes the beginning of the IP range
- You selected this option
The server is utilizing the address typically reserved for broadcasting within its subnet
- You selected this option
The subnet does not provide an adequate number of host addresses for the network's needs
- You selected this option
The gateway's address falls outside the server's subnet range
Answer Description
Given the server's assignment allowing for 126 devices, the subnet mask is inferred to be 255.255.255.128, which points to a /25 CIDR notation. This division places the server within the range of 192.168.1.0 to 192.168.1.127. The gateway's address of 192.168.1.129 falls outside of this range, meaning they are not on the same subnet; hence, the server cannot communicate through this gateway to other segments. The server is not assigned a special address such as a network or broadcast address, and the network's host capacity appears correctly configured for its subnet, dismissing the other provided options.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does subnet mask mean in this context?
What does it mean for a gateway to be 'outside' the subnet?
What is CIDR notation and how is it used here?
As a system administrator, you have received a file named 'logins.txt' containing a list of usernames. However, the usernames are separated by commas and you need them to be separated by newlines to process them in a script. Using the 'tr' command, how would you translate the commas into newline characters in a shell script?
- You selected this option
tr ',' '\n' < logins.txt
- You selected this option
tr -s ',' '\n' logins.txt
- You selected this option
tr -d ',' '\n' logins.txt
- You selected this option
tr '\n' ',' < logins.txt
Answer Description
The command 'tr ',' '\n' < logins.txt' is used for replacing all commas in the file 'logins.txt' with newline characters. This is the correct use of the 'tr' command where the first argument is the set of characters to be replaced (commas) and the second argument is the set of characters to replace with (newline characters). The '<' operator is used to pass the contents of 'logins.txt' to the 'tr' command.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the 'tr' command do?
What does the '<' operator do in the command?
Why would newline characters be used instead of commas for usernames?
A systems administrator notices a high number of collisions on a Linux-based server's Ethernet interface which is connected to an office's local area network (LAN). The collisions are resulting in noticeable performance degradation. While investigating the cause, what should the administrator check first in order to resolve the issue?
- You selected this option
Update the network interface card drivers
- You selected this option
Switch port duplex settings
- You selected this option
Increase the server's RAM
- You selected this option
Router's access control lists
Answer Description
Collisions occur in networks using a shared medium like Ethernet when two devices attempt to transmit at the same time. They are common in older networks with hubs or in misconfigured networks. The correct answer is 'Switch port duplex settings' because duplex mismatches are a primary cause of network collisions. If one side of the connection is set to full duplex and the other to half duplex, it can lead to a collision domain where each side of the connection expects different behavior regarding data transmission.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are duplex settings and why are they important?
What are network collisions and how do they affect performance?
How can I check and configure duplex settings on a Linux server?
Which lvchange option is used to prevent allocation of physical extents to a logical volume?
- You selected this option
-r or --resizefs
- You selected this option
-l +100%FREE
- You selected this option
-an or --activate no
- You selected this option
-a n or --alloc none
Answer Description
The lvchange option '-a n' or '--alloc none' is used to change the allocation policy for a logical volume to 'none', preventing further extents from being allocated to the volume. This option would be used in advanced scenarios such as maintenance or to prevent changes to a volume while taking a snapshot. The other listed options do not relate to the allocation policy and serve different purposes within the lvchange command.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are physical extents in the context of logical volumes?
What does the `-a n` option in LV change and when might it be used?
What are snapshots in LVM, and how do they relate to the lvchange command?
An administrator is diagnosing an issue where a filesystem on their Linux server appears to be mounted read-only, preventing users from writing data. Which mount option should have been specified during the mounting process to allow both read and write operations on the filesystem?
- You selected this option
ro
- You selected this option
rw
- You selected this option
sync
- You selected this option
user
Answer Description
The 'rw' option is used to mount a filesystem with both read and write permissions. If a filesystem is unintentionally mounted as read-only, ensuring that the 'rw' option is set during the mount process will resolve the issue, allowing users to perform write operations once more. Other options, such as 'ro', 'sync', and 'user', have specific uses: 'ro' mounts the filesystem as read-only, 'sync' ensures that input/output operations are done synchronously, and 'user' allows an ordinary user to mount the filesystem without requiring superuser privileges. However, these do not address the problem described.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the 'rw' mount option specifically do?
What happens if the filesystem is mounted with 'ro' instead of 'rw'?
Can you explain the difference between 'sync' and 'async' options in the context of filesystem mounting?
A user reports that they are unable to write to a file named 'report.txt' located in their home directory. However, they have confirmed that they can read the file. Which of the following is the BEST action to take in order to grant the user write access to the file?
- You selected this option
Edit the /etc/fstab file to alter mounting options for the user's home directory
- You selected this option
Restart the file service to refresh user permissions
- You selected this option
Change the file permissions to allow write access for the user
- You selected this option
Change the ownership of the file using the chown command
Answer Description
The correct answer is 'Change the file permissions to allow write access for the user'. Since the user already has read access and only needs write access, modifying the file permissions using the chmod
command is the most straightforward approach. The other options do not directly address the specific issue at hand. Changing the file ownership with chown
is unnecessary and potentially risky if the user already owns the file. Editing the /etc/fstab
file would typically configure file system mount options, not individual file permissions. Restarting the file service is unrelated to file permissions, and would not remedy the user's inability to write to the file.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are file permissions in Linux?
What is the `chmod` command and how is it used?
What is the difference between file ownership and permissions?
The command 'at' can be used to schedule a job for a specific time without the requirement for that to recur at regular intervals.
- You selected this option
The statement is inaccurate
- You selected this option
The statement is accurate
Answer Description
The 'at' command is indeed used for one-time task scheduling on Linux systems. It does not provide a way to schedule recurring jobs; that functionality is handled by 'cron'. Therefore, 'at' is suitable for tasks that need to be run once at a certain point in time in the future.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the difference between 'at' and 'cron' commands?
How do you use the 'at' command to schedule a task?
What types of tasks can be scheduled with the 'at' command?
What is typically the primary consequence of unchecked memory leaks over time on a Linux system?
- You selected this option
Increased CPU utilization
- You selected this option
Network bandwidth limitations
- You selected this option
Memory exhaustion
- You selected this option
Increase in disk capacity
Answer Description
Memory leaks occur when a program mismanages memory allocations, by not releasing memory that is no longer needed, causing a progressive loss of available memory. Over time, this can lead to memory exhaustion, where no additional memory is available for use, potentially causing system slowdowns or crashes. While leaks may increase CPU or disk usage indirectly due to increased swapping or garbage collection, memory exhaustion is a direct consequence.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are memory leaks and how do they occur?
How can memory exhaustion affect system performance?
What are some ways to prevent memory leaks in Linux applications?
A user reports that they cannot write to a file named 'report.txt' which should be writable by members of the group 'staff'. As a sysadmin, you check the permissions with ls -l report.txt
and the output shows -rw-r--r-- 1 root staff 1048576 Jan 01 12:34 report.txt
. What is the most likely reason for the user being unable to write to the file?
- You selected this option
The file is too large to be written to by group members
- You selected this option
The file is owned by the 'root' user, so only root can modify it
- You selected this option
The group 'staff' does not exist on the system
- You selected this option
The file only has write permissions for the owner
Answer Description
The correct answer is The file only has write permissions for the owner. The permission string -rw-r--r--
indicates that the owner of the file (in this case, 'root') has read and write permissions, the group 'staff' members and others have only read permissions. Therefore, although the user is in the correct group, they won't be able to write to the file unless the write permission is added for the group.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What do the permission symbols 'r', 'w', and 'x' mean in file permissions?
How can I change file permissions to allow group members to write to a file?
What is the significance of file ownership in Linux?
Neat!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.