CompTIA Linux+ Practice Test (XK0-006)
Use the form below to configure your CompTIA Linux+ Practice Test (XK0-006). 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-006 (V8) Information
CompTIA Linux+ (v8 / XK0-006) Exam
The CompTIA Linux+ (XK0-006) 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-006 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-006 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-006) 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-006 (V8) 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 ManagementServices and User ManagementSecurityAutomation, Orchestration, and ScriptingTroubleshooting
Free Preview
This test is a free preview, no account required.
Subscribe to unlock all content, keep track of your scores, and access AI features!
A system administrator needs to permanently add the nomodeset
kernel parameter to the GRUB 2 boot-loader configuration. Which of the following methods should the administrator use to ensure the change persists after a kernel update?
Edit the
GRUB_CMDLINE_LINUX_DEFAULT
line in/etc/default/grub
and then runupdate-grub
.Add the line
kernel.nomodeset=1
to the/etc/sysctl.conf
file and runsysctl -p
.Directly edit the
/boot/grub/grub.cfg
file and add the parameter to thelinux
line.Append
nomodeset
to the end of the/proc/cmdline
file.
Answer Description
The persistent way to add a kernel parameter in GRUB 2 is to edit /etc/default/grub
and then regenerate the main configuration. Add nomodeset
to the GRUB_CMDLINE_LINUX
or GRUB_CMDLINE_LINUX_DEFAULT
variable in /etc/default/grub
, save the file, and run the appropriate command to rebuild the menu: update-grub
on Debian/Ubuntu systems or grub2-mkconfig -o /boot/grub2/grub.cfg
on RHEL-derived systems (UEFI systems use the /boot/efi/EFI/<distro>/grub.cfg
stub). Editing /boot/grub2/grub.cfg
(or /boot/grub/grub.cfg
) directly is incorrect because those files are auto-generated and will be overwritten the next time the rebuild command runs-such as during a kernel update. /proc/cmdline
only reflects the parameters of the currently running kernel, and /etc/sysctl.conf
controls runtime kernel tunables, not boot-loader parameters.
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 `nomodeset` kernel parameter?
Why is editing `/etc/default/grub` preferred over directly editing `/boot/grub/grub.cfg`?
What are the commands `update-grub` and `grub2-mkconfig`, and how do they differ?
A Linux system administrator needs to modify the system-wide configuration for network services on a server. According to the Filesystem Hierarchy Standard (FHS), in which directory should the administrator primarily look for these configuration files?
/var
/home
/boot
/etc
Answer Description
The correct answer is /etc
. The Filesystem Hierarchy Standard (FHS) specifies that the /etc
directory is for host-specific, system-wide configuration files and directories. It should not contain any binaries. The /var
directory is for variable data files, such as logs, spool files, and caches, which change during normal system operation. The /home
directory is the default location for user-specific files and configurations, not system-wide ones. The /boot
directory contains the static files required for the system's boot process, such as the kernel and bootloader files, not general service configurations.
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 Filesystem Hierarchy Standard (FHS)?
Why is the `/etc` directory important in Linux systems?
How does `/var` differ from `/etc` in terms of functionality?
You are hardening a Linux server that sometimes remounts its root filesystem read-only during maintenance. A health-check script must confirm at runtime that /tmp is really mounted with the noexec flag, even if /etc/mtab is unavailable or out of date. Which single file should the script read to obtain an authoritative, up-to-date list of all mounts and their current options?
/proc/mounts
/proc/partitions
/etc/fstab
/run/mount/utab
Answer Description
The kernel maintains the definitive mount table and exposes it through the pseudo-file /proc/mounts (a symbolic link to /proc/self/mounts on modern kernels). Because the contents are generated on demand by the kernel, the file always shows the mounts that are visible in the calling process's mount namespace, regardless of whether /etc/mtab exists, is stale, or is a symlink. Reading /etc/fstab only shows administrator-configured entries, /proc/partitions lists block devices but not current mount options, and /run/mount/utab is a private runtime database used by libmount (util-linux) to track user-mount metadata-it is not maintained by the kernel and can be missing or stale. Therefore, parsing /proc/mounts is the most reliable way to verify that /tmp-or any filesystem-is currently mounted with the desired flags.
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 /proc/mounts and /etc/fstab?
What is the purpose of the noexec flag in mount options?
Why is /proc/mounts considered more reliable than /run/mount/utab?
A system administrator is teaching a new intern about the Filesystem Hierarchy Standard (FHS) on a Linux server. The intern asks about the purpose of the topmost directory. According to the FHS, what is the primary role of the root (/) directory?
It contains the majority of multi-user utilities, applications, and their libraries.
It contains all system-wide configuration files and host-specific settings.
It serves as the primary hierarchy and contains all other directories and files.
It contains variable data files that change during system operation, such as logs and mail spools.
Answer Description
The correct answer is that the root (/) directory is the primary hierarchy and contains the entire filesystem. According to the Filesystem Hierarchy Standard (FHS), all files and directories appear under the root directory, even if they are on different physical devices. The other options are incorrect as they describe other specific top-level directories:
- System-wide configuration files are stored in
/etc
. - Shareable, read-only user utilities and applications are stored in
/usr
. - Variable data files, such as logs and spools, are stored in
/var
.
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 Filesystem Hierarchy Standard (FHS)?
What is the difference between the root (/) directory and the /root directory?
How does the FHS handle files across multiple physical devices?
You have booted a Linux server into single-user (rescue) mode after an unexpected power loss. Before you run fsck on the root file system (/), you must switch that file system to read-only without changing its mount point or rebooting. Which single command accomplishes this task?
mount -o remount,nosuid /
mount -o bind,ro / /
mount -o remount,rw /
mount -o remount,ro /
Answer Description
The remount option tells the kernel to change the mount options of an already-mounted file system in place. Adding ro sets the mount to read-only. Therefore, mount -o remount,ro /
immediately flips the root file system to read-only while it remains mounted at /.
The other choices are incorrect:
mount -o bind,ro / /
attempts a bind mount; it would create a second mount of the same directory and is not how you change an existing mount's permissions.mount -o remount,nosuid /
changes only the nosuid flag; the file system would still be read-write.mount -o remount,rw /
explicitly keeps the file system read-write, the opposite of what is required.
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 'remount' option do in the mount command?
What is the purpose of single-user mode in Linux?
Why must the root file system be switched to read-only before running fsck?
A system administrator is running a lengthy script, ./update.sh
, that generates important progress information to standard output. The administrator needs to capture this output in a file named update.log
for later analysis, but also wants to monitor the script's execution in real time on the terminal. Which of the following commands will achieve this?
./update.sh > update.log
./update.sh | tee update.log
./update.sh > update.log && tail -f update.log
tee update.log < ./update.sh
Answer Description
The correct command is ./update.sh | tee update.log
. The tee
command reads from standard input and writes to both standard output and one or more files simultaneously. The pipe symbol |
sends the standard output of the ./update.sh
script to the standard input of the tee
command. tee
then displays that output on the terminal (its standard output) and saves it to the update.log
file.
- The command
./update.sh > update.log
uses the output redirection operator>
, which sends the standard output only to the file, not to the screen. - The command
./update.sh > update.log && tail -f update.log
would only runtail -f
after the./update.sh
script has finished successfully, which does not allow for real-time monitoring of the script as it runs. - The command
tee update.log < ./update.sh
incorrectly tries to use the script file itself as standard input fortee
, rather than executing the script and capturing its 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 `tee` command do in Linux?
What is the difference between `>` and `|` in Linux?
How does `tail -f` differ from using `tee` for real-time monitoring?
A system administrator is running a script that generates a large amount of verbose output to both standard output and standard error. The administrator only needs to check the script's exit code and wants to prevent all output from being displayed on the terminal or written to a log file. Which of the following commands will achieve this?
script.sh > /dev/random
script.sh | /dev/null
script.sh > /dev/zero
script.sh > /dev/null 2>&1
Answer Description
The correct command is script.sh > /dev/null 2>&1
. This command structure first redirects standard output (stdout, file descriptor 1) to the special device file /dev/null
, which discards all data written to it. Then, 2>&1
redirects standard error (stderr, file descriptor 2) to the same location as standard output, effectively discarding error messages as well. Redirecting to /dev/zero
is incorrect; its primary purpose is to provide a stream of null characters when read. Using a pipe (|
) with /dev/null
is incorrect because /dev/null
is a device file, not a command that accepts standard input. Redirecting to /dev/random
is also incorrect as this file is a source for random data and not intended for discarding 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 is the purpose of /dev/null in Linux?
What does the '2>&1' part of the command mean?
Why can't /dev/zero or /dev/random be used for discarding output?
During a new Linux deployment you create a separate logical volume for user data so the operating system can be re-installed without touching personal files. According to the Filesystem Hierarchy Standard (FHS), to which top-level directory should you mount this volume so that each user's dotfiles and other personal data are found automatically by shells, desktop environments, and standard tools without any extra configuration?
/opt
/home
/usr/local
/srv
Answer Description
The FHS designates /home as the default location for regular users' home directories. Placing a dedicated filesystem at /home lets every non-root account store its personal files and hidden configuration files in a predictable path such as /home/alice or /home/bob. The other paths serve different purposes: /usr/local is reserved for locally installed software that should survive distribution upgrades, /opt is intended for add-on application packages, and /srv holds data offered by network services such as web or FTP servers. Mounting the user volume at any of those locations would break established conventions and could confuse system tools or administrators; therefore /home is the correct choice.
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 /home the correct choice for user data according to FHS?
What is the purpose of /usr/local in Linux?
How is /srv different from /home in Linux?
You are preparing a RHEL-based server that boots with GRUB 2 on a BIOS system. The kernel must always start with the noapic parameter, and the setting must be preserved when new kernels are installed. After making the change you will regenerate the boot-loader configuration with:
grub2-mkconfig -o /boot/grub2/grub.cfg
Which single configuration file should you edit before running the command so the new parameter is applied persistently?
/boot/grub2/custom.cfg
/boot/grub2/grub.cfg
/etc/grub.d/10_linux
/etc/default/grub
Answer Description
GRUB 2's human-editable settings are stored in /etc/default/grub. When grub2-mkconfig runs, it combines the values in this file (especially the GRUB_CMDLINE_LINUX line) with the scripts in /etc/grub.d/ to build a fresh /boot/grub2/grub.cfg. Editing /etc/default/grub therefore ensures that any kernel parameters you add-such as noapic-are written into every menu entry and are kept when future kernels are installed.
The other choices are unsuitable:
- /boot/grub2/grub.cfg is the generated file; any manual edits are overwritten the next time grub2-mkconfig or a kernel update runs.
- /etc/grub.d/10_linux is a script snippet, not the central place for simple kernel-parameter changes, and editing it risks syntax errors that break the whole menu.
- /boot/grub2/custom.cfg is intended for custom menu entries only; modifications there are not propagated to new kernels installed by the package manager.
Therefore, editing /etc/default/grub is the correct and supported method.
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 /etc/default/grub used for kernel parameter changes?
What happens if you manually edit /boot/grub2/grub.cfg instead?
What is the purpose of /etc/grub.d/10_linux?
You need to permanently disable IPv6 on a BIOS-based RHEL server that uses GRUB 2. The change must survive future kernel updates and must follow the vendor-recommended workflow for modifying the boot loader configuration. Which action will achieve this goal?
Add "ipv6.disable=1" to the GRUB_CMDLINE_LINUX line in /etc/default/grub and run "grub2-mkconfig -o /boot/grub2/grub.cfg".
Add "ipv6.disable=1" to the DEFAULTKERNEL variable in /etc/sysconfig/kernel and run "dracut -f" to rebuild the initramfs.
Create a custom menuentry with "ipv6.disable=1" inside /etc/grub.d/40_custom and run "grubby --update-kernel=ALL".
Append "ipv6.disable=1" directly to the linux line in /boot/grub2/grub.cfg and save the file.
Answer Description
GRUB 2 regenerates its binary menu (/boot/grub2/grub.cfg) from templates in /etc/grub.d and the settings found in /etc/default/grub. Red Hat documentation states that you should edit /etc/default/grub (for example, by adding ipv6.disable=1 to the GRUB_CMDLINE_LINUX line) and then rebuild the menu with grub2-mkconfig -o /boot/grub2/grub.cfg. Editing grub.cfg directly is discouraged because the file is overwritten whenever grub2-mkconfig or update-grub is run. Placing the parameter in /etc/grub.d/40_custom or in /etc/sysconfig/kernel does not automatically propagate the option to every new kernel and therefore is not the preferred, maintainable approach.
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 GRUB 2 and how does it function in Linux?
Why is editing `/boot/grub2/grub.cfg` directly discouraged?
What does the kernel parameter `ipv6.disable=1` do?
A network administrator is using iperf3
to troubleshoot network throughput between two Linux servers, ServerA
(10.0.1.10) and ServerB
(10.0.1.20). The administrator starts the iperf3
server process on ServerA
. To measure the download speed from ServerA
to ServerB
, which command should be executed on ServerB
?
iperf3 -s -c 10.0.1.10
iperf3 -c 10.0.1.10 --get-server-output
iperf3 -c 10.0.1.10
iperf3 -c 10.0.1.10 -R
Answer Description
The correct command is iperf3 -c 10.0.1.10 -R
. By default, an iperf3
test sends data from the client to the server, which measures the upload speed of the client. The -R
(or --reverse
) flag reverses the direction of the test, causing the server (ServerA
) to send data to the client (ServerB
). This correctly measures the download speed on the client machine. The command iperf3 -c 10.0.1.10
would measure the upload speed from ServerB
to ServerA
. The command iperf3 -s -c 10.0.1.10
is invalid because the -s
(server) and -c
(client) flags are mutually exclusive. The --get-server-output
flag is used to retrieve the server's final report at the client, but it does not alter the direction of the data transfer.
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 `-R` flag do in `iperf3`?
Why can't the `-s` and `-c` flags be used together in `iperf3`?
What is the purpose of the `--get-server-output` flag in `iperf3`?
During an overnight maintenance window you plan to shrink the ext4 file system located on /dev/mapper/vgdata-lvarchive. Before reducing the size of the underlying logical volume, you need to know exactly how many file-system blocks the volume can be reduced to so that you do not make it smaller than the data it contains. The file system is currently unmounted, and you want a command that only reports this minimum size without modifying anything. Which single command satisfies this requirement?
resize2fs -P /dev/mapper/vgdata-lvarchive
e2fsck -f /dev/mapper/vgdata-lvarchive
resize2fs -f /dev/mapper/vgdata-lvarchive
resize2fs -M /dev/mapper/vgdata-lvarchive
Answer Description
resize2fs with the -P (print minimum) option calculates and displays the minimum number of blocks required for the current contents and then exits without altering the file system. Using -M would immediately shrink the file system to that minimum, -f merely forces a resize operation if one is attempted, and e2fsck only checks or repairs consistency-it does not report the minimum shrinkable size. Therefore the correct choice is the command that uses -P.
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 -P option in resize2fs do?
How does resize2fs differ from e2fsck?
Can you explain the difference between -P and -M options in resize2fs?
You are writing a Bash deployment script that must append the following stanza to /etc/httpd/conf.d/example.conf:
<VirtualHost *:80>
ServerName $SERVERNAME
DocumentRoot $DOCROOT
</VirtualHost>
The script has two requirements:
- The $SERVERNAME and $DOCROOT variables must be substituted by the parent shell before the text is written.
- The four leading spaces that indent each inner line are literal spaces and must be preserved exactly as written.
Which of the following command constructions meets both requirements and appends the stanza to the file?
cat <<< "<VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT " >> /etc/httpd/conf.d/example.conf
cat <<'EOF' >> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF
cat <
> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF cat <<-EOF >> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF
Answer Description
Using an unquoted delimiter with the standard here-document operator (<<) allows the shell to treat the body of the document like a double-quoted string: parameter expansion and command substitution occur. Crucially, all characters, including literal leading spaces, are copied to the command's standard input. This meets both requirements. Quoting the delimiter (<<'EOF') disables all expansions, so $SERVERNAME and $DOCROOT would be written literally. The <<- operator strips leading tab characters from each line of the document. Because the required indentation consists of spaces, this operator is not the correct tool for the job. The <<< operator is a here-string, not a here-document; it is designed to supply a single string to a command's standard input and is not the correct tool for embedding multi-line blocks of text. Therefore, the construction that uses an unquoted delimiter with << and a >> redirection is the only choice that satisfies both requirements.
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 << in a Bash script?
How does quoting the delimiter (<<'EOF') affect the output?
What is the difference between << and <<< in Bash scripting?
During installation of a new x86_64 server, the root filesystem is placed inside a LUKS-encrypted logical volume (LVM). After running dracut to regenerate the initial RAM disk, the machine boots successfully and asks for the passphrase early in the boot sequence. Which statement best explains why the initramfs stage is mandatory for this setup?
It allows GRUB2 to read /etc/default/grub from the encrypted disk and rebuild the boot menu on every startup.
It supplies the user-space tools and kernel modules needed to unlock the LUKS container and activate the LVM so the kernel can mount the real root filesystem.
It contains the systemd unit files that start normal services after the kernel boots into the real root filesystem.
It provides firmware code that lets the BIOS or UEFI locate and launch the bootloader on the disk.
Answer Description
The kernel itself cannot access an encrypted, LVM-based root filesystem without first loading extra drivers and user-space helpers. Those drivers (dm-crypt, LVM, the storage controller) and the utilities that unlock the LUKS container and activate the volume group are packaged inside the initramfs. When the kernel finishes its own hardware initialization, it runs the /init script from the initramfs. That script loads the required modules, starts cryptsetup to decrypt the volume, runs vgchange to make the logical volumes available, mounts the real root filesystem, and then hands control to the regular init system. If the initramfs were missing or incomplete, the kernel would have no way to reach the encrypted root device and the boot would fail. The other options describe tasks handled by GRUB, systemd, or the system firmware, none of which solve the problem of accessing an encrypted LVM root early in 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.
Why does the initramfs include user-space tools for unlocking LUKS-encrypted volumes?
What role does the initramfs play in activating LVM volumes?
What would happen if the initramfs were incomplete or missing in this setup?
A Linux administrator has placed a new set of custom scripts in the /usr/local/sbin
directory and made them executable. When the administrator tries to run a script by typing only its name, the shell returns a "command not found" error. The output of echo $PATH
is as follows:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Which of the following commands must the administrator run to allow the scripts in /usr/local/sbin
to be executed by name for the duration of the current session?
source /usr/local/sbin
export PATH="/usr/local/sbin"
export PATH=$PATH:/usr/local/sbin
chmod +x /usr/local/sbin/*
Answer Description
The correct command is export PATH=$PATH:/usr/local/sbin
. The PATH
environment variable contains a colon-separated list of directories that the shell searches for executable files. To allow the shell to find the new scripts, their directory must be added to the PATH
. The syntax $PATH:/usr/local/sbin
takes the existing value of the PATH
variable ($PATH
) and appends the new directory, /usr/local/sbin
, to the end of the list. The export
command makes this new PATH
variable available to any subsequent commands executed in the current session. Overwriting the PATH
with export PATH="/usr/local/sbin"
would remove all other essential system directories, causing most standard commands to fail. The source
command is used to execute a script in the current shell, not to add a directory to the PATH
. Setting permissions with chmod
is a necessary step to make a script runnable, but it does not solve the issue of the shell not being able to locate 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 is the purpose of the PATH environment variable?
Why does the `$PATH:/usr/local/sbin` syntax work for appending directories?
What happens if you use `export PATH="/usr/local/sbin"` instead?
Smashing!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.