CompTIA certification · Exam XK0-006

XK0-006 Mock Exam Page 3

CompTIA Linux+ V8

Free XK0-006 mock exam questions 21–30, each with the answer and an explanation.

20 questions · 21 minutes · free, no sign-up

Free XK0-006 questions

21–30 of 45 free
Question 21 Choose 1
Which of the following best describes journald?
Show answerHide answer

Correct answer: A A system service that collects and stores logging data

Explanation

Explanation:

journald is part of the systemd suite. It is a daemon that collects, stores, and manages log data from the kernel, system services, and user applications.
Logs are stored in a binary journal format, which can be queried using the journalctl command.
This provides centralized, structured logging, making it easier to filter, search, and analyze system events.

Why the Other Options Are Wrong

A feature that creates crash dumps in case of kernel failure → That’s handled by kdump, not journald.
A service responsible for keeping the filesystem journal → That’s part of the filesystem itself (e.g., ext4 journaling), not journald.
A service responsible for writing audit records to a disk → That’s the role of auditd, not journald.

Reference:
Systemd documentation: journald is the logging service that stores logs in binary format and integrates with journalctl for querying.
CompTIA Linux+ XK0-006 Exam Objectives: Log Management and Monitoring (Domain: Security).
Question 22 Choose 1
Which of the following filesystems contains non-persistent or volatile data?
Show answerHide answer

Correct answer: C /proc

Explanation

Explanation:

The /proc directory is a pseudo-filesystem (often called a virtual filesystem) that serves as an interface to the Linux kernel and process information.

Non-Persistent/Volatile:
The data within /proc does not exist on any physical disk. Instead, it is generated "on the fly" by the kernel in the system's RAM.

System State:
It contains information about currently running processes (organized by PID) and hardware configuration (e.g., /proc/cpuinfo, /proc/meminfo).

Volatility:
Because it exists only in memory, all data in /proc is lost instantly when the system is powered down or rebooted.

Explanation of Incorrect Answers

/boot:
This directory contains the files needed to start the system, such as the Linux kernel, initramfs, and the GRUB bootloader configuration. This data is persistent and must be stored on a physical disk (usually a dedicated partition) to be available during the power-on self-test (POST) and boot process.

/usr:
The /usr (Unix System Resources) directory contains the majority of user utilities and applications (e.g., /usr/bin, /usr/lib). This is a read-only, persistent filesystem that holds static data installed by the package manager.

/var:
The /var directory is used for variable data that changes during system operation, such as logs (/var/log), mail, and print spools. While the data inside changes frequently, the directory itself is persistent and resides on a physical disk so that logs are preserved across reboots for troubleshooting.

Reference:
CompTIA Exam Objective: Domain 1.0 (System Management) – Subsection 1.1: "Summarize and utilize Linux command line tools" and "Manage the filesystem hierarchy."
Reference: Filesystem Hierarchy Standard (FHS); Official CompTIA Linux+ Study Guide, Chapter on Filesystem Management and Hierarchy.
Question 23 Choose 1
Which of the following best describes the role of initrd?
Show answerHide answer

Correct answer: B It contains basic kernel modules and drivers required to start the system.

Explanation

Explanation:

initrd (initial ramdisk) or initramfs (initial RAM filesystem) is a temporary filesystem used by the Linux kernel during the boot process before the real root filesystem is mounted. Its primary role is to provide essential modules and drivers needed to access the actual root filesystem.

What initrd/initramfs does:
Purpose:
Loads necessary drivers for hardware that isn't built directly into the kernel
Provides modules for storage controllers (SATA, SCSI, NVMe)
Contains filesystem drivers (ext4, XFS, Btrfs) to mount the real root
Includes LVM, RAID, or encryption modules if the root is on such volumes
Performs early userspace setup before switching to the real root

Boot process with initrd:
1. BIOS/UEFI → Bootloader (GRUB)
2. Bootloader loads kernel and initrd into memory
3. Kernel decompresses and starts, mounts initrd as temporary root
4. Kernel runs /init from initrd
5. initrd loads necessary modules and drivers
6. initrd mounts the real root filesystem
7. initrd performs pivot_root to switch to real root
8. Real init system (systemd) takes over

When initrd is essential:
Root on LVM: Needs LVM modules to activate volume groups
Root on encrypted disk: Needs crypto modules to unlock the drive
Root on network: Needs network drivers for NFS root
Root on uncommon hardware: Needs drivers for specialized storage controllers
Root on RAID: Needs MD RAID modules to assemble arrays

Why other options are incorrect:

❌ It is required to connect to the system via SSH.
SSH connectivity is managed by the SSH daemon (sshd) which runs AFTER the system has fully booted
SSH requires network configuration, which happens in the main system, not during early boot
initrd is long gone by the time SSH is available
SSH has nothing to do with the initial hardware detection and root mounting phase

❌ It contains trusted certificates and secret keys of the system.
Certificates and keys are typically stored in /etc/ssl/certs or /etc/ssh/ on the root filesystem
These are security credentials for services, not boot components
initrd is temporary and not designed for persistent secret storage
Some specific setups (like disk encryption) might include keys in initrd, but this is not its primary purpose

❌ It is required to initialize a random device within a Linux system.
The random device (/dev/random, /dev/urandom) is provided by the kernel, not initrd
Random number generation is a kernel feature that initializes independently
Some early boot entropy gathering might occur, but this is not the role of initrd

Reference:
initrd = Initial RAM Disk
initramfs = Initial RAM Filesystem (modern replacement)
Required when kernel lacks built-in drivers for boot hardware
Created by tools like mkinitramfs (Debian) or dracut (RHEL/Fedora)
Without initrd, the kernel would need every possible driver compiled in, making the kernel huge
Question 24 Choose 1
A Linux administrator wants to add a user to the Docker group without changing the user’s primary group.
Which of the following commands should the administrator use to complete this task?
Show answerHide answer

Correct answer: C sudo usermod -aG docker user

Explanation

Explanation:

To add a user to a supplementary group like docker without affecting their primary group, the -a (append) and -G (groups) flags are required. The -a flag is critical because it ensures the user is added to the new group while remaining a member of all their current secondary groups. Without it, the user would be removed from any other existing secondary groups.

Why other options are incorrect

❌ sudo groupmod docker user:
The groupmod command is used to modify the properties of the group itself (such as its name or GID), not to manage user membership within that group.

❌ sudo usermod -g docker user:
The lowercase -g flag changes the user's primary group. This would violate the requirement to add the user to the group without changing their primary group assignment.

❌ sudo groupmod -G docker user:
The groupmod command does not support a -G flag for adding users. As mentioned, this utility is intended for group metadata, not membership administration.
Question 25 Choose 1
A Linux administrator tries to install Ansible in a Linux environment. One of the steps is to change the owner and the group of the directory /opt/Ansible and its contents. Which of the following commands will accomplish this task?
Show answerHide answer

Correct answer: B chown -R Ansible:Ansible /opt/Ansible

Explanation

Explanation:

The chown (change owner) command is the primary tool used to modify the ownership of files and directories.

Ansible:Ansible: This syntax defines both the owner and the group simultaneously. The first "Ansible" refers to the user account, and the second "Ansible" (following the colon) refers to the group name.

-R (Recursive): This flag is the most critical part of the requirement to change the owner of the directory and its contents. It ensures the ownership changes are applied to all subdirectories and files within /opt/Ansible.

/opt/Ansible: This is the target directory path being modified.

Explanation of Incorrect Answers
groupmod -g Ansible -n /opt/Ansible:
The groupmod command is used to modify group definitions (such as changing the Group ID or the group's name). It does not change the ownership of files or directories.

usermod -aG Ansible /opt/Ansible:
The usermod command is used to modify user accounts. This specific command would attempt to add a user to a group, but the syntax is incorrect as it uses a directory path (/opt/Ansible) where a username should be.

chmod -c /opt/Ansible:
The chmod command changes permissions (read, write, execute), not ownership. The -c flag stands for "changes," which outputs a diagnostic message for every file processed, but it does not address the requirement to change the owner and group.

Reference
CompTIA Exam Objective: Domain 1.0 (System Management) – Subsection 1.1: "Configure and manage software and kernel modules" (specifically File and Directory Permissions/Ownership).
Reference: Linux Man Pages (man chown); Official CompTIA Linux+ Study Guide, Chapter on File and Directory Management.
Question 26 Choose 1
Which of the following describes the method of consolidating system events to a single location?
Show answerHide answer

Correct answer: A Log aggregation

Explanation

Explanation:

Log aggregation is the process of collecting system events and logs from multiple sources (applications, servers, containers, network devices) and consolidating them into a single location.

This makes it easier to:
* Monitor system health.
* Detect anomalies or security incidents.
* Perform centralized analysis and troubleshooting.

Tools like ELK Stack (Elasticsearch, Logstash, Kibana), Splunk, or Graylog are commonly used for log aggregation.

❌ Why the Other Options Are Wrong
Health checks → Monitor system availability and performance, not consolidate logs.
Webhooks → Provide event-driven notifications between systems, not log collection.
Threshold monitoring → Alerts when metrics exceed defined limits, but does not consolidate logs.

👉 So the method of consolidating system events to a single location is: Log aggregation.
Question 27 Choose 1
A Linux user runs the following command:
nohup ping comptia.com &
Which of the following commands should the user execute to attach the process to the current terminal?
Show answerHide answer

Correct answer: D fg

Explanation

Explanation:

The fg (foreground) command is used to move a background process into the current terminal's foreground.

Process Resumption: When a command is run with an ampersand (&), it executes in the background, allowing the user to continue using the shell.

Attaching to Terminal: Running fg without arguments will bring the most recently backgrounded job to the foreground.

Interaction: Once a process is in the foreground, it "attaches" to the terminal, meaning it will display its output directly to the screen and respond to keyboard interrupts like Ctrl+C.

Context: The nohup (no hangup) utility ensures the process continues running even if the user logs out, but fg is the specific mechanism used to bring that running process back to the active terminal session.

Explanation of Incorrect Answers
renice:
This command is used to alter the scheduling priority (nice value) of an already running process. It affects how much CPU time the process receives but does not change whether the process is in the background or foreground.

jobs:
The jobs command lists the active jobs and their status (Running, Stopped, etc.) for the current shell session. While it helps you identify which job number to use with fg, it does not perform the attachment itself.

exec:
The exec command is used to replace the current shell with a new process. It does not resume or attach to an existing background process; instead, it terminates the current shell and starts the specified command in its place.

Reference
CompTIA Exam Objective: Domain 1.0 (System Management) – Subsection 1.1: "Summarize and utilize Linux command line tools" (specifically Process Management and Job Control).
Reference: Linux Man Pages (man fg, man jobs); Official CompTIA Linux+ Study Guide, Chapter on Process and Job Management.
Question 28 Choose 1
A Linux systems administrator needs to extract the contents of a file named /home/dev/web.bkp to the /var /www/html/ directory. Which of the following commands should the administrator use?
Show answerHide answer

Correct answer: B pushd /var/www/html/ && cpio -idv < /home/dev/web.bkp && popd

Explanation

Explanation:

The administrator needs to extract the contents of a backup file:
/home/dev/web.bkp
into:
/var/www/html/

The correct command uses cpio, which is commonly used for backup archives (.bkp files).

pushd /var/www/html/ && cpio -idv < /home/dev/web.bkp && popd

What each part does
pushd /var/www/html/
Temporarily changes to the target directory.

cpio -idv
-i → extract files
-d → create directories as needed
-v → verbose output

< /home/dev/web.bkp
Reads archive input from the backup file.

popd
Returns to the original working directory.

✅ Result: files are extracted directly into /var/www/html/.

❌ Why the Other Options Are Incorrect
❌ cd ... && gzip -c ... | tar xf -
Assumes the backup is gzip + tar formatted.
No indication the file is compressed.
Incorrect extraction method.

❌ tar -c -f /home/dev/web.bkp /var/www/html/
-c creates an archive.
Opposite of what is required.

❌ unzip -c /home/dev/web.bkp /var/www/html/
unzip works only with .zip archives.
.bkp is not a ZIP file.

🧠 Linux+ XK0-006 Exam Tip
Common archive tools:
Tool Typical Extension
tar .tar, .tar.gz
cpio .cpio, .bkp ✅
gzip .gz
unzip .zip

💡 Exam keyword trigger:
If you see a generic backup file (.bkp) and redirection < file, think cpio -i for extraction.
Question 29 Choose 1
A systems administrator manages multiple Linux servers and needs to set up a reliable and secure way to handle the complexity of managing event records on the OS and application levels. Which of the following should the administrator do?
Show answerHide answer

Correct answer: B Implement a centralized log aggregation solution.

Explanation

Explanation:

Managing multiple Linux servers means logs are scattered across different machines and applications.

A centralized log aggregation solution (e.g., ELK Stack, Splunk, Graylog, Fluentd) collects logs from all servers and applications into a single, secure location.

Benefits:
Simplifies troubleshooting and auditing.
Provides real-time monitoring and alerting.
Enhances security by preventing tampering with local logs.
Enables correlation of events across systems.

❌ Why the Other Options Are Wrong
Create an automated process to retrieve logs from the server by demand → Reactive and inefficient; doesn’t scale well.
Configure daily automatic backups of logs to remote storage → Provides redundancy but not real-time visibility or correlation.
Deploy log rotation procedures to manage the records → Prevents log files from growing too large, but doesn’t address complexity across multiple servers.

📖 Reference
Red Hat Documentation: Centralized logging improves monitoring and security.
CompTIA Linux+ XK0-006 Exam Objectives: Log Management and Monitoring (Domain: Security).
Question 30 Choose 1
An administrator needs to remove the directory /home/user1/data and all of its contents. Which of the following commands should the administrator use?
Show answerHide answer

Correct answer: C rm -r /home/user1/data

Explanation

Explanation:

The rm (remove) command is the primary utility for deleting files and directories in Linux.
-r (Recursive): This flag is essential when dealing with directories. It instructs the command to descend into the specified directory and remove all files, subdirectories, and the target directory itself.
Effectiveness: Without the -r (or -R) flag, rm will fail when targeting a directory, reporting that it cannot remove a directory.
Safety Note: Administrators often use -rf (recursive and force) to bypass confirmation prompts, though this should be used with extreme caution.

Explanation of Incorrect Answers
rmdir -p /home/user1/data: The rmdir command is designed to remove empty directories only. The -p (parents) flag allows for the removal of a directory and its ancestors if they are also empty. If /home/user1/data contains any files or subdirectories, this command will fail with an "Directory not empty" error.

ln -d /home/user1/data: The ln command is used to create links between files. The -d flag is a restricted option that allows the superuser to attempt to make a hard link to a directory, which is generally not permitted on most modern Linux filesystems to prevent loops. It does not delete data.

cut -d /home/user1/data: The cut command is a text processing utility used to extract sections (columns) from lines of files. The -d flag specifies a delimiter for parsing text. It has no capability to delete files or directories.

Reference
CompTIA Exam Objective: Domain 1.0 (System Management) – Subsection 1.1: "Summarize and utilize Linux command line tools" (specifically File and Directory Management).
Reference: Linux Man Pages (man rm, man rmdir); Official CompTIA Linux+ Study Guide, Chapter on File and Directory Management.
Full mock exam

Sit the XK0-006 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real XK0-006 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full XK0-006 mock exam
  • 87questions per mock
  • 90 mintime limit
  • 150questions in the bank
  • Newmock on every attempt