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
When reviewing file security configurations, a Linux administrator needs to determine if any files in a directory are set with the 'immutable' attribute to prevent alterations. Which command should the administrator use and what flag should they be looking for in the output?
Use the
lsattr -l
command and look for a detailed list of attributesUse the
chattr
command to check for the 'i' attributeUse the
lsattr
command and look for files with the 'i' flagUse the
lsattr -a
command and search for files with the 'a' flag
Answer Description
The lsattr
command is used to list the attributes of files. When looking for immutable files, the administrator should scan for the 'i' attribute in the command output. This attribute indicates that a file cannot be modified, deleted, or renamed, no links can be created to it, and no data can be written to the file. The chattr
command is used for changing attributes, not listing them. The -a
option for lsattr
lists all files, but the 'a' attribute flag denotes 'append-only'. The lsattr
command does not have a -l
option for detailed output.
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 'i' attribute signify in Linux file permissions?
How does the `lsattr` command differ from `chattr`?
Can the immutable attribute ('i') be overridden by the root user?
A freshly installed Linux server under systemd always presents a graphical login prompt, but the operations team requires a console login on each startup. Which command best configures the system so future boots provide the console login?
systemctl set-default multi-user.target
ln -s /lib/systemd/system/getty.target /etc/systemd/system/default.target
systemctl isolate multi-user.target
Edit /etc/inittab to specify runlevel 3
Answer Description
The systemctl set-default multi-user.target
command updates the default target, adjusting the /etc/systemd/system/default.target
symlink to point to multi-user.target
, which provides a text-based login. Using systemctl isolate
only switches targets for the current session and doesn’t persist across reboots. Creating a symlink to getty.target
instead of the default target is incorrect since default.target
controls the boot target. Editing /etc/inittab
has no effect under systemd.
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 `multi-user.target` and `graphical.target`?
How does `systemctl set-default` differ from `systemctl isolate`?
Why does editing `/etc/inittab` no longer work under systemd?
After receiving alerts of potential hardware issues, a system administrator needs to check the status of the software RAID arrays on a Linux server. Which is the BEST command to use in order to display the current status of all active RAID arrays managed by mdadm?
mdadm --detail
lsblk
fdisk -l
cat /proc/mdstat
Answer Description
The cat /proc/mdstat
command is the correct option because it provides the current status of all active software RAID arrays, including information on individual disks and their state within each array. The mdadm --detail
command also gives detailed information, but it needs to be followed by a specific device name (e.g., mdadm --detail /dev/md0
), and therefore it is not as comprehensive for displaying all active arrays at once. The fdisk -l
command lists all partition tables, which is not specific to active RAID arrays. The lsblk
command lists block devices, which includes RAID arrays, but does not provide detailed RAID status.
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 /proc/mdstat file in Linux?
How does `cat /proc/mdstat` compare to `mdadm --detail` for RAID monitoring?
What is the difference between `lsblk` and `cat /proc/mdstat` for RAID information?
A system administrator notices that a production server is experiencing significant slowdowns. Upon further investigation using the top
command, it's observed that the I/O wait percentage is consistently above 30%. Considering that the server's disk activity is not excessively high, what could be a probable cause for the high I/O wait?
A misconfigured network firewall is limiting incoming connections.
The hard drive is failing, causing read/write operations to take longer than usual.
The I/O scheduler is configured for a single-threaded process, leading to a bottleneck.
Insufficient memory available for buffer/cache leading to frequent disk access.
Answer Description
Having insufficient memory available for buffer/cache can lead to high I/O wait times because the system has to commit to disk I/O more frequently than if it had enough memory to cache operations. This leads to higher wait times as processes are queued while the I/O bottleneck is resolved. Optimizing memory usage or adding more memory can help reduce I/O wait times. A failing hard drive or misconfigured I/O scheduler may also cause increased I/O wait, but these options are less likely if disk activity is not high and the hardware was previously functioning correctly.
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 'I/O wait' and how is it measured?
What is the purpose of buffer/cache memory in Linux?
How can a system administrator reduce high I/O wait on a Linux server?
A system administrator wants to define a PATH update and set a default umask for every user when they log in with a Bourne-compatible shell. Which file should be modified to implement these changes across all existing accounts?
/etc/bash.bashrc
/etc/environment
/etc/profile
~/.bash_profile
Answer Description
The chosen file is sourced by all Bourne-compatible (sh, bash, ksh) login shells. It applies system-wide environment settings before any user-specific scripts. The other files are either not processed at login by those shells, apply only to interactive or non-login sessions, or reside in a user’s skeleton directory and affect only new accounts.
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 /etc/profile in Linux?
What is the difference between /etc/profile and ~/.bash_profile?
What is the function of 'umask' and why is it set in /etc/profile?
A system administrator wants to perform a directory synchronization from a local folder to a remote backup server. The requirement is to ensure that only the differences since the last sync are transferred to minimize network usage. The sync needs to be recursive to include all subdirectories and also preserve file permissions. Which command accomplishes this goal most efficiently?
rsync --dry-run /local/directory user@remote:/backup/directory
rsync -a /local/directory user@remote:/backup/directory
rsync --update /local/directory user@remote:/backup/directory
rsync --in-place /local/directory user@remote:/backup/directory
Answer Description
The correct answer is rsync -a /local/directory user@remote:/backup/directory
because the -a
(archive) flag is used to preserve permissions, timestamps, ownership, and to ensure recursive copying — while also optimizing by transferring only the differences from the last sync. The --dry-run
flag would only simulate the transfer without actually copying files, --update
will skip files newer on the receiver without considering other changes, and --in-place
could potentially reduce transfer efficiency as it updates destination files in place - useful for large, single files but not necessarily for directory syncs with minimal 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 -a flag in rsync do?
How does rsync optimize network usage during directory synchronization?
When should you use --dry-run in rsync?
A Linux administrator needs to configure passwordless SSH access for a new developer to a production web server. After the developer generates a new SSH key pair on their workstation, which of the following represents the most secure and efficient method to deploy the public key?
Copy the contents of the private key into the
~/.ssh/authorized_keys
file on the server.Use
scp
to copy the public key to the server, then append its contents to the~/.ssh/authorized_keys
file.Edit the
/etc/ssh/sshd_config
file on the server and add the public key's contents.Run
ssh-copy-id user@server
from the developer's workstation.
Answer Description
The ssh-copy-id user@server
command is the standard, most secure, and efficient method for deploying a public key. This utility automatically handles creating the ~/.ssh
directory and the authorized_keys
file on the remote server if they do not exist, appends the key, and, most importantly, sets the correct restrictive file permissions (e.g., 700 for the directory, 600 for the file). While using scp
to copy the key followed by appending it is a functional manual method, it is more error-prone as it does not automatically enforce correct permissions, which can lead to security vulnerabilities or authentication failures. Transferring the private key is a severe security violation. Editing /etc/ssh/sshd_config
is incorrect for adding a user's public key.
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 ssh-copy-id command, and why is it preferred?
Why should the private key never be transferred to the server?
What happens if permissions on the authorized_keys file are incorrect?
Alice is working on a Linux server and has navigated through several directories. She wants to confirm the absolute path of the directory she is currently working in before deploying a new application. Which command should she use to display her current directory path?
pwd
cd
ls -d .
echo $PWD
Answer Description
The correct answer is pwd
, which stands for 'print working directory'. This command is used to output the full pathname of the current working directory, providing users with their exact location in the filesystem hierarchy. This information is especially important when performing operations that are sensitive to the current directory context, such as deploying applications, running scripts, or managing files. While echo $PWD
often produces the same output, it reads from the $PWD environment variable, which may not always be accurate and is not the primary command for this task. The cd
command is used to change directories, not display the current one. The ls -d .
command lists the current directory entry itself as '.', not its full path.
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 the 'pwd' command and 'echo $PWD'?
Why is it important to know the absolute path when working on a Linux server?
What are some examples of tasks that require confirming the current directory using 'pwd'?
A Linux administrator must forward all syslog messages via UDP to a remote log server at IP address 192.168.150.50. Which line should be added to /etc/rsyslog.conf (legacy syntax) to meet this requirement?
. >192.168.150.50
. @192.168.150.50
. #192.168.150.50
. @@192.168.150.50
Answer Description
Using a single at-sign (@) before the destination tells rsyslog to send the selected messages over UDP. The selector . matches every facility and every priority, so the line . @192.168.150.50 forwards all logs to that host on the default UDP port 514. A double at-sign (@@) would switch the transport to TCP, while > is shell redirection and # begins a comment, so those lines would not achieve the stated goal.
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 using '@' and '@@' in rsyslog.conf?
What role does the *.* selector play in rsyslog?
What is UDP port 514, and why is it the default for syslog?
A new junior system administrator has been tasked with reviewing user accounts on a vital Linux server. While inspecting the /etc/passwd file, they noticed an account entry that does not have a corresponding /home directory. Which of the following are potential explanations for this situation?
The account's default shell is set to
/usr/sbin/nologin
, which implies that no home directory was created when the account was added.The account is intended for a system service or process and is not designed for regular user login activities.
The user associated with the account has been assigned to an incorrect group, which is why the home directory is missing.
The account has an expired password and, therefore, the home directory was removed automatically.
Answer Description
In the /etc/passwd file, it is common for system accounts to not have a corresponding /home directory because these accounts are not meant for regular user logins and do not require personal storage space. They're typically used for running specific services or tasks. Standard user accounts should normally be configured with a home directory. The presence of nologin
as the shell is an additional confirmation that the account is not intended for interactive login, but it is not a direct indicator of the absence of the home directory. Accounts with shells set to /usr/sbin/nologin
or /bin/false
can still have home directories configured for storing service data, even though they don't provide shell access. The other answers include misconceptions, as an expired password or incorrect group assignments would not cause an account to lack a home directory; these issues would affect the ability to login or permissions, respectively.
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 system accounts in Linux?
Why do some Linux accounts use the /usr/sbin/nologin shell?
How is the /etc/passwd file structured in Linux?
An administrator wants to conduct an aggressive scan to retrieve version information, run default scripts, and to detect the operating system of the target device. Which Nmap command option should be used?
-sn
-o
-p-
-A
Answer Description
The '-A' option in Nmap enables aggressive scanning, which combines OS detection, version detection, script scanning, and traceroute. This thorough scanning option is informative for deep network analysis. The '-sn' option is for ping scanning (host discovery), '-p-' scans all 65535 ports, and '-o' is an invalid option as it lacks the specifics for output files like '-oN' or '-oX'.
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 Nmap used for?
What does the '-A' option do during an Nmap scan?
How is '-p-' different from the default port scanning in Nmap?
A Linux administrator is configuring a system to make sure that any user attempting to access a certain service should present two different forms of identification. Which of the following authentication methods should the administrator configure?
Multifactor authentication (MFA)
Tokens
System Security Services Daemon (SSSD)
Pluggable authentication modules (PAM)
Answer Description
Multifactor authentication (MFA) requires users to provide two or more verification factors to gain access to a resource such as applications, online accounts, or VPNs, making it significantly more secure than single-factor authentication methods. Tokens and Pluggable Authentication Modules (PAM) are forms of single-factor authentication methods, whereas System Security Services Daemon (SSSD) is an authentication broker but does not inherently indicate a requirement for multiple forms of identification.
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 Multifactor Authentication (MFA)?
How does PAM differ from MFA in authentication?
What role does SSSD play in system authentication, and why is it not MFA?
A system administrator needs to create a compressed backup of the /var/log
directory. Which command should they use to create a gzip-compressed archive file named log_backup.tar.gz
?
tar -tzvf log_backup.tar.gz /var/log
tar -czvf log_backup.tar.gz /var/log
tar -xvf log_backup.tar.gz /var/log
tar -cvf log_backup.tar.gz /var/log
Answer Description
The correct answer is tar -czvf log_backup.tar.gz /var/log
because the options -c
create a new archive, -z
filter the archive through gzip for compression, -v
produce verbose output, showing all processed files, and -f
specify the filename of the archive. The incorrect options either do not specify gzip compression, which is required to produce a .gz
file, or use options that perform actions other than creating an archive, such as extracting files or listing the contents of an archive.
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 each tar option (-c, -z, -v, -f) do?
What is the difference between gzip and other compression tools like bzip2 or xz?
How can you verify the contents of a tar.gz file without extracting it?
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?
tune2fs -c 1 /dev/sda1
tune2fs -i 0 /dev/sda1
e2fsck -p /dev/sda1
tune2fs -C 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 `-c` flag do in the `tune2fs` command?
What is the difference between the `-c` and `-i` flags in `tune2fs`?
Why is it necessary to unmount the filesystem before using `fsck`?
A Linux system administrator notices that a custom service is supposed to start after the local MySQL database server is up and running. However, the custom service sometimes fails because it starts too quickly and does not detect the MySQL service being ready. Which directive should the administrator add to the [Unit] section of the custom service's systemd unit file to ensure it starts after the MySQL service?
Wants=mysqld.service
BindsTo=mysqld.service
After=mysqld.service
BindTo=mysqld.service
Answer Description
The correct answer is After=mysqld.service because the After=
directive ensures that the custom service starts only after the MySQL service (mysqld.service
) is active. The Wants=
directive is used to start units together but does not dictate order, and BindTo=
and BindsTo=
are incorrect because there is no systemd directive called BindTo=
, and BindsTo=
creates a stronger dependency than required for start-up order – it's used to bind the start/stop of units together.
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 'After=' directive in systemd?
How is 'Wants=' different from 'After=' in systemd unit files?
What is the function of the 'BindsTo=' directive in systemd?
Which of the following statements about achieving optimal throughput on modern PCIe/NVMe solid-state drives (SSDs) is TRUE?
Aligning partitions to 512-byte sector boundaries guarantees maximum SSD throughput regardless of thread count or queue depth.
Multi-threaded I/O with an appropriate queue depth can help saturate SSD bandwidth by leveraging the drive's internal parallelism.
Single-threaded synchronous I/O always yields the highest possible throughput on any SSD.
SSD performance is unaffected by the host's I/O scheduler because the device ignores all queuing decisions.
Answer Description
Modern SSD controllers contain many internal NAND channels that can be accessed in parallel. Generating multiple outstanding I/O requests (for example, by running several threads or processes or by increasing the I/O queue depth) allows the drive to keep these channels busy and reach its rated bandwidth and IOPS. Running a single synchronous thread typically issues only one request at a time, leaving most of the drive's internal resources idle, so throughput is lower. While filesystem alignment and scheduler choice can influence latency and consistency, they do not eliminate the need for concurrent I/O to reach peak performance, and modern SSDs do benefit from host-side queuing.
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 multi-threaded I/O, and how does it help with SSD performance?
What is queue depth, and why does it matter for achieving optimal SSD performance?
How do the host's I/O scheduler and partition alignment impact SSD performance?
An administrator is attempting to run a graphical network-configuration utility with elevated privileges on a desktop Linux system that uses PolicyKit. The administrator must ensure that PolicyKit rules are enforced and that any password prompt appears in a graphical dialog. Which command should be used to start the tool?
pexec network-configuration-tool
sudo network-configuration-tool
pkexec network-configuration-tool
polkit network-configuration-tool
Answer Description
The correct command is pkexec network-configuration-tool
. The pkexec wrapper hands the request to PolicyKit, which evaluates the defined policies and, if necessary, invokes the desktop's polkit authentication agent to display a GUI password dialog. Running sudo network-configuration-tool
would bypass PolicyKit and only present a terminal prompt. polkit network-configuration-tool
is invalid because polkit is the privilege framework, not a launcher. pexec
is an unrelated parallel-execution utility and provides no privilege-escalation or PolicyKit integration.
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 PolicyKit and how does it work?
Why is `pkexec` preferred over `sudo` for graphical tools in Linux?
What happens if PolicyKit rules are incorrectly configured or missing?
Which of the following while-loop constructs will create an infinite loop in a POSIX-compliant shell script (assuming no external signals are sent and no files are modified during execution)?
while read line; do echo "$line"; done < /etc/passwd
while [ -f /tmp/stop ]; do echo "Running"; sleep 1; done
while true; do echo "Running"; done
while false; do echo "Running"; done
Answer Description
The loop in option 1 uses the command true
, which always exits with status 0 (success). Because the while condition evaluates to success on every iteration, the body executes indefinitely, resulting in an infinite loop.
Option 2 will terminate if the file /tmp/stop is removed, option 3 ends when it reaches end-of-file on /etc/passwd, and option 4 never runs because the condition false
immediately returns a non-zero status.
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 `true` command do in a POSIX-compliant shell?
Why does the `while [ -f /tmp/stop ];` loop terminate while `while true;` does not?
What happens in `while read line; do echo "$line"; done < /etc/passwd` and why does it terminate?
A system administrator has noticed that a server's time is not in sync with its designated time source. They need to verify the current synchronization status and performance of the server's timekeeping. Which command should they use?
chronyc add server
chronyc sourcestats
chronyc tracking
chronyc sources
Answer Description
Use chronyc tracking
to view key synchronization metrics such as current system time offset, last offset, frequency, root delay, and dispersion. These values show whether the local clock is in sync and how well it is being disciplined.
chronyc sources
lists each configured or discovered time source and its reachability, but it does not summarize the overall state of the local clock.chronyc sourcestats
reports statistical data (frequency drift, standard deviation, etc.) for each source, which is useful for trend analysis rather than a quick status check.chronyc add server <address>
(shown here without parameters) adds a new NTP server dynamically; it does not display synchronization status.
Therefore, chronyc tracking
is the appropriate command for quickly confirming the server's current synchronization status and performance.
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 `chronyc tracking` command specifically display?
How does `chronyc sources` differ from `chronyc tracking`?
Why is accurate time synchronization important for servers?
What characteristic distinguishes a stateful firewall from its stateless counterpart in the context of network traffic?
Monitors and maintains the state of active connections
Operates at a higher performance level
Creates dynamic rules for each new connection
Filters traffic solely based on static rules
Answer Description
A stateful firewall has the capability to monitor the entire state of active connections, and thus can make decisions based on the context of the traffic (such as the state of the connection), rather than relying solely on predetermined rules. This allows it to permit or deny traffic based on the history of the connection, which is not something that stateless firewalls can do. Stateless firewalls can only permit or deny traffic based on static rules and do not have the ability to retain connection state information. Dynamic rule creation is not a feature directly associated with being stateful; while a stateful firewall could potentially create rules dynamically, it's the state tracking that defines it. Nor do performance considerations determine whether a firewall is stateful or stateless.
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 monitor the state of active connections in a stateful firewall?
How does a stateful firewall differ from a stateless firewall in decision-making?
What are some real-world use cases for stateful firewalls?
Gnarly!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.