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 system administrator needs to write a shell script that will output 'Large file detected' if a specified file size exceeds 1024 kilobytes. Which of the following shell script code blocks is the BEST to accomplish this?
- You selected this option
if [ $(stat -c%s "file.txt") -gt 1048576 ]; then echo 'Large file detected'; fi
- You selected this option
if [ $(stat -c%s "file.txt") / 1024 -gt 1024 ]; then echo 'Large file detected'; fi
- You selected this option
if [ $(stat -c%s "file.txt") -gt 1024 ]; then echo 'Large file detected'; fi
- You selected this option
if [[ $(stat -c%s "file.txt") -gt 1024 ]]; then echo 'Large file detected'; fi
Answer Description
The correct code block uses the -gt
operator to check if the file size is greater than 1024 kilobytes. Remember that stat -c%s filename
retrieves the file size in bytes, so you must divide by 1024 to convert bytes to kilobytes. The if
statement then evaluates this condition and prints 'Large file detected' if the condition is true. Other comparisons or the lack of size conversion can result in incorrect behavior or syntax errors.
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 `stat -c%s` command do?
What does the `-gt` operator signify in shell scripting?
Why do we divide file size by 1024 when checking in kilobytes?
What command is used to reconfigure the time zone on a Linux system?
- You selected this option
timezone
- You selected this option
date --set-timezone
- You selected this option
tzconfig
- You selected this option
timedatectl set-timezone
Answer Description
The correct answer is timedatectl set-timezone
. This command is used to set the time zone of the system to the specified value. It's part of the timedatectl
utility, which lets you view and change the current date, time, and timezone settings. The reason the other options are incorrect is that tzconfig
is deprecated, date
is used for setting the system's date and time but not the timezone, and timezone
is not a valid command for setting the system time zone.
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 timedatectl command?
What is the significance of setting the correct time zone on a Linux system?
What is NTP and how does it relate to time zone settings?
When a container is set to use the host networking mode, it will share the networking namespace with the host machine allowing the container to listen on the host's IP address.
- You selected this option
False
- You selected this option
True
Answer Description
Using the host networking mode means that the container shares the host's networking namespace. This allows the container to bind ports directly to the host's IP address. It's crucial for certain applications that require direct visibility from external networks without network address translation (NAT). Other answers might seem correct, but they do not accurately describe the behavior of containers in host network mode.
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 it mean to share the networking namespace?
What are the advantages of using host networking mode?
When should I avoid using host networking mode?
Your server has a web application that should be accessible from the internet, but users report they are unable to connect. You have confirmed that the web server is running and that network connectivity is established. What should you check next to ensure that the firewall is not blocking the web application's traffic?
- You selected this option
Check the listening ports to ensure the server is listening on the correct interface.
- You selected this option
Verify that the firewall rules allow traffic on ports 80 (HTTP) and 443 (HTTPS).
- You selected this option
Use a network scanner to detect open ports on the server.
- You selected this option
Restart the web server service to ensure it is not a service issue.
Answer Description
When users report that they cannot connect to a web-facing application despite the service running and network connectivity being established, the next step is to check the firewall rules to ensure that traffic on the port used by the web application is not being blocked. In the case of a typical web application, you would check for rules that allow traffic on ports 80 and 443 for HTTP and HTTPS, respectively. If these rules are not present or are misconfigured, the firewall would prevent external users from connecting to the application. Checking the status of a service or the ports being listened on, while potentially useful in other scenarios, would not address a firewall configuration issue.
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 firewall rules, and why are they important for a web application?
What is the difference between HTTP and HTTPS, and how do their port numbers relate to security?
What tools can be used to check firewall rules on a Linux server?
A system administrator notices that an important server is experiencing intermittent problems with data integrity, and suspects filesystem corruption on one of its disks. After running fsck
on the unmounted filesystem and fixing several errors, the administrator needs to ensure that the filesystem will be checked and repaired if necessary during the next system boot. Which of the following commands should the administrator use to schedule a filesystem check on boot?
- You selected this option
e2fsck -p /dev/sda1
- You selected this option
tune2fs -c 1 /dev/sda1
- You selected this option
tune2fs -C 0 /dev/sda1
- You selected this option
tune2fs -i 0 /dev/sda1
Answer Description
The correct answer is tune2fs -c 1 /dev/sda1
because the command sets the maximum mount count (-c
) to 1
for the filesystem on /dev/sda1
, ensuring that fsck
will be run the next time the filesystem is mounted. This is typically during the boot process. The option -C 0
sets the current mount count to 0
, which is incorrect in this context because it does not schedule a check on the next boot. The -i
flag is used for setting the interval between checks based on time, not on the number of mounts. The e2fsck -p /dev/sda1
executes a filesystem check, but does not schedule it for the next boot.
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 'tune2fs' command do?
What is the significance of the maximum mount count in file systems?
Can you explain what 'fsck' and 'e2fsck' do in this context?
A system administrator is configuring a systemd timer unit to start a backup service exactly 10 minutes after the system has finished booting. Which line should be included in the [Timer] section of the timer unit file?
- You selected this option
OnActiveSec=10min
- You selected this option
StartupSec=10min
- You selected this option
OnUnitInactiveSec=10min
- You selected this option
OnCalendar=*:0/10
- You selected this option
OnUnitActiveSec=10min
- You selected this option
OnBootSec=10min
Answer Description
The 'OnBootSec=10min' directive is the correct answer. It specifies the timer should wait for 10 minutes after the system has booted before activating the associated unit. The directive is part of the timer specification in systemd and is used to delay the start of a service relative to system boot time. Other directives like 'OnUnitActiveSec' and 'OnUnitInactiveSec' are related to the activation times based on when the unit was last activated or became inactive and are not related to the boot process, making them incorrect in this context.
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 systemd and why is it important in Linux?
Can you explain the purpose of the Timer Unit in systemd?
What do the other directives (like OnUnitActiveSec and OnCalendar) do in systemd timer units?
Which command would you use to create a new container from an existing image and start it immediately?
- You selected this option
docker create
- You selected this option
docker build
- You selected this option
docker commit
- You selected this option
docker run
Answer Description
The command docker run
is used to create a new container instance from a specified image and start the container immediately. If the image is not available locally, it will be pulled from the container registry. docker create
only creates the container without starting it, which requires a separate docker start
command to run the container. docker build
is used to create an image from a Dockerfile, not to start a container. docker commit
creates a new image from a container's changes.
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 you mean by 'container' in Docker?
What is an image in Docker and how is it different from a container?
What is the purpose of the 'docker pull' command in relation to containers?
Your company requires remote system administrators to authenticate using a method more secure than passwords alone when accessing critical Linux servers. Which of the following options provides an additional layer of security that requires something the user has, in addition to something the user knows?
- You selected this option
Implementing a strict password strength and rotation policy
- You selected this option
Using a one-time password (OTP) token in conjunction with their user password
- You selected this option
Employing biometric authentication such as fingerprint or facial recognition
- You selected this option
Requiring administrators to connect using SSH keys
Answer Description
Using a one-time password (OTP) token alongside the regular password constitutes two-factor authentication (2FA), which is a subset of MFA. The OTP token is a physical device or software application that generates a time-limited code, adding an additional security layer beyond the password, which is 'something the user knows'. The token ensures 'something the user has', thereby satisfying MFA requirements. Biometric authentication, while it also provides an additional security layer, is categorized as 'something the user is', and it is generally not used in conjunction with a password as the sole two factors in remote system administration. Password strength policies improve the security of the password itself but do not add another factor. SSH keys are a secure method of authentication but are considered a single factor: 'something the user has'.
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 two-factor authentication (2FA)?
How do one-time password (OTP) tokens work?
What is multi-factor authentication (MFA) and how does it relate to 2FA?
When configuring a Docker container's network, which option allows you to create a dedicated subnet where containers can be attached, providing isolation from other containers on the same host?
- You selected this option
MACVLAN network
- You selected this option
User-defined bridge network
- You selected this option
Host mode networking
- You selected this option
Default bridge network
- You selected this option
None (network disabled)
- You selected this option
Overlay network
Answer Description
A user-defined bridge
network is correct because it enables users to create isolated networking environments. Containers attached to a user-defined bridge network can communicate via their internal IPs, and this network is isolated from other containers unless explicitly connected. The default bridge
is less secure since all containers are able to communicate by default. A MACVLAN
network allows containers to have their own MAC address providing the appearance of physical devices which is different from the network isolation described. An Overlay network
is used for communication between containers on different Docker daemons, which was not the scenario described. Host mode
directly attaches the container to the host's network, with no isolation. None
disables all networking for a container, however, it doesn't allow communication within a subnet.
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 user-defined bridge network in Docker?
How does a default bridge network differ from a user-defined bridge network?
What are the advantages of using an overlay network in Docker?
A system administrator has noticed that over time, a Linux server's available memory decreases, even when the workload on the server remains consistent. The 'top' command shows a particular process gradually increasing its memory usage without releasing it back to the system. Which of the following tools should the administrator use to further investigate this suspected memory leak in the problematic process?
- You selected this option
vmstat
- You selected this option
valgrind
- You selected this option
free
- You selected this option
mpstat
Answer Description
The valgrind
tool is used to detect memory leaks and memory management problems in programs. When a process is suspected of having a memory leak because it progressively consumes more memory without freeing it, valgrind
can be employed to analyze the process and identify where memory is not being appropriately released.
free
is a command that displays the amount of free and used memory in the system but does not detect memory leaks in processes.
vmstat
reports information about processes, memory, paging, block IO, traps, disks, and cpu activity, but does not specifically analyze memory leaks in individual processes.
mpstat
is used to monitor CPU utilization but does not analyze memory leaks in a process.
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 some common causes of memory leaks in programs?
How does Valgrind detect memory leaks?
What are some alternatives to Valgrind for detecting memory leaks?
The command xargs
can be used to apply a single command to each line of input it receives.
- You selected this option
True
- You selected this option
False
Answer Description
The xargs
command is typically used to take output from a command that generates a list of items, one per line, and then applies another command to each item. This turns the multi-line input into arguments for the given command, effectively allowing that command to be run for each input item. For example, cat list.txt | xargs rm
would attempt to run the rm
command on each line listed in list.txt
. Other answers are incorrect because they misinterpret the functionality of xargs
or describe capabilities it does not possess.
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 `xargs` command in Linux?
How does `xargs` handle spaces or special characters in input?
Can `xargs` be used with any command?
A team member has made several updates to files in a local Git repository. To prepare for the next commit, the team member wants to stage a specific file called update.txt
that has been modified along with various other files. Which command should the team member use to stage only the changes in update.txt
?
- You selected this option
git add update.txt
- You selected this option
git commit update.txt
- You selected this option
git add .
- You selected this option
git push update.txt
Answer Description
The correct answer is git add update.txt
because it stages the specific changes made to update.txt
, making it ready for the next commit. The git add .
command would stage all changes in the current directory and subdirectories, which is not desired in this scenario if the intention is to only stage update.txt
. Using git commit update.txt
without the add
command would not work because commit
attempts to create a new commit from currently staged changes, and it does not accept a file path as an argument. git push update.txt
is incorrect because push
is used for updating remote refs along with associated objects, not for staging changes.
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 command 'git add' do in Git?
What is the difference between staging and committing in Git?
What happens if I use 'git add .' instead of 'git add update.txt'?
What command would you use to display all the currently running container instances in the system?
- You selected this option
docker list
- You selected this option
docker running
- You selected this option
docker inspect
- You selected this option
docker ps
Answer Description
The docker ps
command is used to list all running containers. The option -a
or --all
can be added to show all containers, not just those that are running. The commands docker list
and docker running
are not valid Docker commands. While docker inspect
provides detailed information about one or more containers, it does not list all running containers.
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 container and how does it work?
What are the different states a Docker container can be in?
How can I filter the output of the docker ps command?
An administrator is writing a shell script where the output of a command needs to be both displayed on the screen and written to a file for logging purposes. Which command and operator should the administrator use to achieve this?
- You selected this option
Using the
tee
command with the|
operator - You selected this option
Redirecting output using the
>
operator - You selected this option
Piping the output to another command with the
|
operator - You selected this option
Appending the output to a file using the
>>
operator
Answer Description
The 'tee' command is the right choice for this task because it reads from standard input and writes to both standard output (allowing the user to see the output on the screen) and one or more files, essentially duplicating the output stream. The operator >
is used to redirect output to a file but does not display it on the screen. The operator |
is used to pipe the output of one command to another but on its own does not write to a file. The operator >>
is used to append output to a file but again, it does not display the output on the screen.
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.
How does the 'tee' command work in detail?
What is the difference between the '>' and '>>' operators?
What are piping and its common use cases?
A system administrator needs to verify the SSL certificate information of a web server at the domain 'example.com' running on the default HTTPS port. Which command should be used to retrieve and display the certificate details?
- You selected this option
openssl s_client -verify example.com
- You selected this option
openssl s_server -connect example.com:443
- You selected this option
openssl s_client -connect example.com:443 -cert
- You selected this option
openssl s_client -host example.com -port 443
- You selected this option
openssl s_client -connect example.com:443 -showcerts
- You selected this option
openssl s_client -tls1_2 -connect example.com:443
Answer Description
The command openssl s_client -connect example.com:443 -showcerts
establishes a connection to the specified domain on the default HTTPS port and retrieves the full certificate chain as provided by the server. This information is valuable when verifying the authenticity and trustworthiness of the SSL certificates in use.
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 SSL stand for and why is it important?
What are the key components of an SSL certificate?
What is the difference between the SSL and TLS protocols?
Neat!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.