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 (v7) 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.

Free CompTIA Linux+ XK0-005 (v7) Practice Test
- 20 Questions
- Unlimited
- System ManagementSecurityScripting, Containers, and AutomationTroubleshooting
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?
mpstat
vmstat
free
valgrind
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 is a memory leak and why is it problematic?
How does `valgrind` detect memory leaks in a process?
What is the difference between `valgrind` and other tools like `free` or `vmstat`?
An administrator has just completed the installation of a new kernel on a Linux system. After installing the kernel and related modules, they wish to update the GRUB2 bootloader configuration to ensure that the system will boot using this new kernel. Which of the following commands should the administrator run to correctly generate a new configuration and ensure the new kernel is bootable?
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install
mkinitrd /boot/initrd.img
grub2-update
Answer Description
The command 'grub2-mkconfig -o /boot/grub2/grub.cfg' generates a new GRUB2 configuration file and writes it to the default location for GRUB2's configuration. The '-o' option is used to specify the output file and is critical for actual application of changes. Other options shown might seem plausible, but they do not perform the task of updating the configuration.
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 GRUB2 and why is it important in Linux?
What does the 'grub2-mkconfig' command do?
What is the difference between 'grub2-mkconfig' and 'grub2-install'?
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?
firewall-cmd --permanent --zone=public --add-source=192.168.100.256/24
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="80" accept'
firewall-cmd --permanent --zone=public --add-service=http --source=192.168.100.0/24
firewall-cmd --permanent --new-zone=192.168.100.0/24
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 a rich rule in firewalld?
Why does the subnet 192.168.100.256/24 in one option make it invalid?
What does the `--permanent` flag do in firewall-cmd?
An administrator needs to extend the storage capacity of a Linux server. They have added a new physical disk and created a physical volume (PV) on it. Now, the administrator wants to check the existing volume groups (VGs) to decide into which volume group the new physical volume should be extended. Which command should be used to display the current volume groups and their associated information?
fdisk -l
lvdisplay
vgs
pvscan
Answer Description
The correct answer is 'vgs', as it stands for 'volume groups' and is used to display information about the volume groups managed by LVM. It would give an overview of the volume groups available on the system, including details like VG name, the total size, available free space, and the number of physical volumes (PVs) it contains, helping the administrator in making a decision where to extend the storage.
The answer 'lvdisplay' is incorrect because it shows information about logical volumes, not volume groups. 'pvscan' only scans all disks for physical volumes, it doesn't provide detailed information about volume groups. 'fdisk -l' displays partition and disk information, which does not directly relate to LVM's volume group configuration.
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 LVM and why is it used?
What is the difference between physical volumes, volume groups, and logical volumes in LVM?
What information does the 'vgs' command provide?
A Linux system administrator is managing a web server and discovers that CGI scripts in /var/www/cgi-bin are being blocked by SELinux. An audit of /var/log/audit/audit.log confirms the denials. The administrator needs to enable CGI script execution permanently, ensuring the change persists across reboots and is the standard method for this adjustment. Which command should the administrator use?
audit2allow -a -M local_httpd_cgi && semodule -i local_httpd_cgi.pp
setsebool -P httpd_enable_cgi on
setenforce 0
chcon -R -t httpd_sys_script_exec_t /var/www/cgi-bin
Answer Description
The most appropriate command is setsebool -P httpd_enable_cgi on. The setsebool command is used to modify SELinux booleans, which act as runtime switches for policy rules. The httpd_enable_cgi boolean specifically controls whether the Apache HTTP Server can execute CGI scripts. Using the -P flag makes the change persistent across reboots. The command setenforce 0 is incorrect because it would place the entire system in a less-secure permissive mode. The chcon command is also incorrect because its changes do not persist after a filesystem relabel. While audit2allow could generate a custom policy module, it is an unnecessarily complex solution when a pre-defined boolean already exists for the required task.
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 do you view and change SELinux booleans?
Why are SELinux booleans useful for system administrators?
What is the difference between a boolean and a policy in SELinux?
A system administrator is writing a shell script that reads usernames from a file named users.txt and needs to verify whether each account exists on the local system. Which command is the most suitable to place inside the loop to test if a specified user account is present?
pwd
id
whoami
hostname
Answer Description
The id command outputs user and group identity details for the supplied username. When the named user exists, id returns the relevant information and an exit status of 0; if the user does not exist, it produces an error and a non-zero exit status, allowing the script to branch accordingly.
pwd only prints the current working directory, whoami shows the effective user running the script (and accepts no username argument), and hostname displays the machine's host name-none of which can check another user's existence.
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 `id` command check if a user exists?
What alternatives to `id` can be used to check if a user exists?
Why can't `pwd`, `whoami`, or `hostname` verify a user account's existence?
A system administrator suspects that a newly installed network card is not being recognized by the Linux kernel. Which command should be used to verify if the card is detected by the system at the hardware level?
lsusb
lspci
lsmod
dmesg | grep -i network
Answer Description
The lspci command lists all PCI devices on the system, including network cards, regardless of whether the kernel has appropriate drivers for them. This makes it the correct tool to check if the hardware is recognized at the PCI level. lsusb is incorrect because it lists USB devices, not PCI devices. dmesg | grep -i network could show kernel messages about network cards, but it would not necessarily list all PCI devices if, for example, no driver attempted to load. lsmod is used to display the kernel modules currently loaded, which is useful for driver information but not for listing hardware that may not have a loaded driver.
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 'lspci' command?
How does 'lspci' differ from 'lsusb'?
Why can't 'lsmod' or 'dmesg | grep -i network' fully replace 'lspci'?
In an effort to secure communication for an internal-facing web service, a system administrator has been tasked with implementing an encrypted connection protocol. External validation of the server's identity by outside entities is not a requirement due to the service being exclusively accessed within the organization. What is the most appropriate action for the administrator to undertake?
Create and configure a certificate signed by the server's private key.
Rely on secure shell protocols for encrypted web traffic, circumventing the need for certificates.
Obtain and install a certificate from a recognized certificate authority.
Operate the web service without encryption since it is internally accessed and does not need protection.
Answer Description
The correct action is to generate a self-signed certificate because it allows the administrator to implement encryption for the web service without involving an external certificate authority (CA). This method is suitable for environments where trust is established by other means, such as within an organization where all clients accessing the service are controlled and can be configured to trust the self-signed certificate. The use of a self-signed certificate enables encrypted connections and ensures data privacy on the internal network.
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 self-signed certificate?
Why is a self-signed certificate suitable for internal services?
How does a certificate signed by a certificate authority differ from a self-signed certificate?
A script named process_users.sh expects entries from standard input. Which command sends the contents of users.csv into the script’s input so it processes each line?
./process_users.sh >> users.csv
./process_users.sh < users.csv
./process_users.sh users.csv
./process_users.sh << users.csv
Answer Description
The < operator redirects a file to a program’s standard input. In this case, ./process_users.sh < users.csv feeds the file into the script correctly. Passing the filename as an argument does not send it to the input stream, appending with >> affects output rather than input, and using << without a proper delimiter invokes a here-document, not a file redirect.
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 '<' operator do in Linux commands?
What is the difference between '<' and '>>' operators in Linux?
What is a here-document and how does '<<' work in Linux?
A system administrator is troubleshooting an application that is reported to be leaking resources. Upon running ps aux, the administrator observes several child processes of the application are marked with a 'Z' in the STAT column. Although these processes have completed their tasks, they remain in the process table. What is the state of these processes?
Stopped
Running
Sleeping
Zombie
Answer Description
A process marked with a 'Z' state flag is a 'zombie' or 'defunct' process. This state indicates that the process has completed execution, but its parent process has not yet read its exit status using the wait() system call. As a result, the process entry remains in the process table until it is properly 'reaped' by its parent. The other options are incorrect process states for this scenario: 'Running' is for processes currently executing, 'Sleeping' is for processes waiting for a resource or event, and 'Stopped' is for processes that have been paused by a signal.
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 happens if a zombie process is not reaped?
How can you identify zombie processes on a Linux system?
How can zombie processes be resolved if they persist?
Which command will permanently mount a filesystem at boot by adding an entry to a specific configuration file?
Execute
systemctl enable mountUse
fstab --add-entryUse
mount --permanentEdit
/etc/fstab
Answer Description
To permanently mount a filesystem at boot in Linux, an entry must be added to the /etc/fstab file. The mount command only mounts filesystems temporarily until the next reboot.
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 `/etc/fstab` and why is it important?
What happens if there is an error in `/etc/fstab`?
What is the difference between mounting using the `mount` command and using `/etc/fstab`?
An organization requires a data storage solution using multiple disks. The solution must ensure continuous data availability even if two disks fail concurrently. Which configuration should be utilized to fulfill this requirement?
A striped set with dual distributed parity
A striped set of mirrored pairs
A striped set without parity or redundancy
A striped set using single distributed parity
Answer Description
The correct configuration for this scenario is a striped set with dual parity (RAID 6), which is specifically designed to handle up to two simultaneous disk failures without data loss. A striped set with single distributed parity (RAID 5) does not meet the requirement as it can only sustain the loss of a single disk. A striped set without redundancy (RAID 0) offers no fault tolerance at all. A striped set of mirrored pairs (RAID 10) can potentially survive two disk failures, but it does not guarantee it, as the failure of both disks in the same mirrored pair would result in data loss.
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.
Why is RAID 6 preferred in scenarios with a need for dual disk failure tolerance?
What is the main difference between RAID 5 and RAID 6?
How does RAID 10 differ from RAID 6 in handling disk failures?
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?
Default bridge
Bridge
Host
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 bridge network?
How does the default bridge network differ from a user-defined bridge network?
When should you use the overlay network driver instead of the bridge network?
A development team wants to automate their workflow. Their goal is to have every git push to the main branch automatically trigger a process that builds the application, runs a full suite of integration tests, and then deploys the application to a staging server for review. Which of the following approaches BEST satisfies all requirements of this scenario?
Setting up a Jenkins pipeline
Configuring a
post-receiveGit hook to run deployment scriptsUsing a cron job to periodically pull and deploy changes
Automating the workflow using a set of independent shell scripts
Answer Description
The correct answer is 'Setting up a Jenkins pipeline'. A full CI/CD (Continuous Integration/Continuous Deployment) pipeline is required to meet all the scenario's requirements: building, testing, and deploying automatically after a code push. Jenkins is a widely-used automation server specifically designed to orchestrate these multi-stage pipelines.
The other options are less suitable:
- Configuring a
post-receiveGit hook can trigger a script, but it lacks the robust workflow management, logging, and integration features of a dedicated CI/CD tool needed for a multi-stage process. - A cron job runs on a schedule (e.g., every hour), not in response to a
git push, so it would not provide immediate feedback after a commit. - While individual shell scripts would be used to perform tasks within the pipeline, they do not provide the overarching orchestration framework to manage the entire workflow from trigger to deployment.
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 Jenkins pipeline and how does it work?
How does a Jenkins pipeline differ from a Git hook?
What are the advantages of using Jenkins pipelines over cron jobs or shell scripts?
A developer is working on a feature branch called new-feature. Another team member has just updated the remote main branch with critical security fixes. The developer needs to update their new-feature branch with these changes from the remote main branch to ensure their code is compatible. Which single Git command will fetch the remote changes and merge them into the developer's current new-feature branch?
git merge maingit pull origin maingit push origin maingit fetch origin main
Answer Description
The correct command is git pull origin main. This command performs two actions in one step: it runs git fetch to download the new commits from the main branch of the origin remote, and then it runs git merge to integrate those downloaded commits into the current local branch (new-feature).
git fetch origin mainis incorrect because it only downloads the updates from the remotemainbranch into the local remote-tracking branch (origin/main) but does not merge them into the current working branch.git merge mainis incorrect because it would attempt to merge the localmainbranch into the current branch. To merge the remote changes, the developer would first need tofetchthem and then explicitly merge the remote-tracking branch (e.g.,git merge origin/main).git push origin mainis incorrect, asgit pushis used to upload local commits to a remote repository, not to retrieve them.
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 remote repository in Git?
What is the difference between `git fetch` and `git pull`?
What happens during a merge conflict when using `git pull`?
An administrator needs to download the latest version of an Ubuntu image for container deployment. Which of the following commands will perform this operation?
pull ubuntu
docker pull ubuntu
docker push ubuntu
docker rmi ubuntu
Answer Description
The command docker pull ubuntu retrieves the latest version of the Ubuntu image from the default Docker hub registry. docker pull ubuntu is the correct command because it specifies only the image name, which defaults to pulling the 'latest' tag if no other version is specified. pull ubuntu is incorrect because it is missing the docker command. docker push ubuntu is incorrect because it is using push which is for uploading images, not downloading them. docker rmi ubuntu is incorrect because rmi is used to remove images, not to pull them.
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 Docker and how does it work?
What is the difference between `docker pull` and `docker push`?
What is the purpose of the `docker rmi` command?
An administrator must allow external collaborators to reach an internal HTTP host on port 80 by connecting to a bastion server. The bastion should accept connections on port 8080 and forward them to the internal host. Which SSH option enables this setup on the bastion server?
-D 8080
-L 8080:internal.host:80
-R 8080:internal.host:80
-N
Answer Description
The correct option instructs the bastion to open a socket on port 8080 and relay incoming traffic to the internal host’s port 80. The option that begins with “-L” creates a listener on the client side instead of the server. The “-D” flag sets up a dynamic SOCKS proxy rather than a fixed tunnel. The “-N” flag prevents execution of remote commands but does not establish any port mappings.
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 -R option in SSH?
What is the difference between the -R and -L options in SSH?
What is the role of a bastion server in this setup?
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.110 with a mask indicating its subnet 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?
The subnet does not provide an adequate number of host addresses for the network's needs
The gateway's address falls outside the server's subnet range
The server is assigned the network address of the subnet
The server is utilizing the address typically reserved for broadcasting within its subnet
Answer Description
Given the server's subnet allows for 126 devices, the subnet mask is inferred to be 255.255.255.128, which corresponds to a /25 CIDR notation. This configuration creates a subnet with a valid host IP range of 192.168.1.1 to 192.168.1.126. The server's address of 192.168.1.110 falls within this range. However, the gateway's address of 192.168.1.129 is outside this range and belongs to the next subnet (192.168.1.128/25). Because the server and its configured gateway are not on the same subnet, the server cannot route traffic to other network segments.
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 subnet mask, and how does it determine a device's subnet range?
What is a network gateway, and why must it be within the same subnet as the server?
What is CIDR notation, and how does it affect IP range calculations?
A Linux administrator is deploying an application on Kubernetes and needs to ensure that two containers (a web server and a caching service) share the same network and storage resources. Which of the following is the BEST option to achieve this requirement?
Create a new Kubernetes service to facilitate communication between two standalone pods
Use a DaemonSet to ensure that both containers run on each node in the cluster
Deploy both containers within a single pod
Launch separate pods for each container and use a service to link them
Answer Description
The correct answer is 'Deploy both containers within a single pod'. In Kubernetes, a Pod represents one or more containers that should be run together. Containers within the same pod share the same IP address, network, and storage resources, which means they can communicate with each other using 'localhost' and can access shared volumes. This is the exact scenario described, making it the ideal solution. The other options do not correctly represent how containers are co-located to share resources in the Kubernetes context. Creating separate pods for each container would not allow them to share network and storage resources directly. Configuring a service or deploying a DaemonSet would not target the issue at hand, which is the shared network and storage for closely related 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 Pod in Kubernetes?
How do containers in the same Pod communicate?
What is a Kubernetes volume and how does it work with Pods?
An administrator examines the line below from /etc/shadow for user alice: alice:$6$Xh3...:18570:0:99999:7::: What does the “7” represent in this record?
Number of days users receive notices before their credential’s validity ends
Minimal interval in days users must wait between credential updates
Duration in days after expiry until the account is disabled
Maximum span in days a credential remains valid before a change is required
Answer Description
The fifth numeric field in an /etc/shadow entry specifies the warning period in days before a credential expires. In this example, alice receives alerts starting seven days prior to password expiry. Other numeric fields control minimum days between changes (field 4), maximum days of validity (field 5), and inactive span after expiration (field 7), so those options correspond to different positions and are incorrect.
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 /etc/shadow file?
How does the 'warning period' in /etc/shadow work?
What are the other numeric fields in the /etc/shadow file used for?
Smashing!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.