00:20:00

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.

Logo for CompTIA Linux+ XK0-006 (V8)
Questions
Number of questions in the practice test
Free users are limited to 20 questions, upgrade to unlimited
Seconds Per Question
Determines how long you have to finish the practice test
Exam Objectives
Which exam objectives should be included in the practice test

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. CompTIA Linux+ practice test 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.

CompTIA Linux+ XK0-006 (V8) Logo
  • Free CompTIA Linux+ XK0-006 (V8) Practice Test

  • 20 Questions
  • Unlimited time
  • System Management
    Services and User Management
    Security
    Automation, Orchestration, and Scripting
    Troubleshooting
Question 1 of 20

During a compliance audit on an x86_64 server running a 6.x Linux kernel, you list the contents of /boot and see the following files:

/boot/initramfs-6.7.9-amd64.img
/boot/vmlinuz-6.7.9-amd64
/boot/System.map-6.7.9-amd64
/boot/grub/grub.cfg

The auditors ask you to justify the presence of the initramfs-6.7.9-amd64.img file. Which statement accurately describes the purpose of this file in the Linux boot process?

  • It is the main GRUB2 configuration file that lists available boot entries and kernel parameters.

  • It provides a minimal root filesystem loaded into RAM so the kernel can load drivers and scripts required to mount the real root filesystem before normal boot continues.

  • It is a sector map generated by LILO that tells the bootloader where kernel sectors are located on disk.

  • It is a compressed copy of the kernel that the firmware expands before handing control to the bootloader.

Question 2 of 20

A system administrator needs to temporarily disable password-based login for a user account named temp_user without deleting the user or their current password. The administrator wants to be able to easily re-enable login later. Which of the following commands will accomplish this?

  • passwd -l temp_user

  • passwd -d temp_user

  • passwd -e temp_user

  • passwd -u temp_user

Question 3 of 20

A systems administrator is configuring a new virtualization server using Linux. They have chosen KVM as the hypervisor to leverage its direct integration with the Linux kernel for managing CPU and memory. For emulating I/O devices, such as network and storage controllers, which accompanying technology is primarily used with KVM?

  • libvirt

  • QEMU

  • VirtIO

  • Xen

Question 4 of 20

A systems administrator uses a large language model (LLM) to generate an Ansible playbook designed to configure a fleet of new web servers. The playbook appears correct at a glance. What is the most important best practice the administrator must follow before executing the playbook on production systems?

  • Immediately run the playbook on a single production node to confirm it works before running it on the entire fleet.

  • Check the playbook's syntax using an automated linter without manually reviewing the logic.

  • Add comments to the playbook crediting the AI model that generated it and noting the date of generation.

  • Thoroughly review the playbook for correctness and security, and then test it in a staging environment that mirrors production.

Question 5 of 20

A Linux administrator is configuring a new KVM virtual machine that will host a web server. The web server must be directly accessible to other physical servers on the same local network segment, using an IP address from the same subnet as the host machine. Which network mode should the administrator configure for the virtual machine's network interface to achieve this?

  • Host-only

  • Bridged

  • NAT

  • Routed

Question 6 of 20

A system administrator needs to start a script named long_backup.sh that will take several hours to complete. The administrator must be able to disconnect their SSH session from the server without causing the script to terminate. Which of the following commands should the administrator use?

  • bg ./long_backup.sh

  • exec ./long_backup.sh

  • nohup ./long_backup.sh &

  • ./long_backup.sh &

Question 7 of 20

A system administrator is hardening a legacy Linux server and discovers that TCP port 23 is open and listening. A network packet capture confirms that authentication credentials are being sent in plaintext during remote login sessions. To remediate this critical security vulnerability, which of the following services should the administrator disable and replace with a secure alternative?

  • SFTP

  • Telnet

  • SSH

  • FTP

Question 8 of 20

A KVM host uses external snapshots for one of its guests. After several disk-only snapshots, the backing-file chain for the guest's vda disk is now:

base.img ← snap1.qcow2 ← active-overlay (current)

The guest must stay online, but the administrator wants to merge all data in the overlays back into base.img and immediately pivot the running VM so it continues to use base.img, allowing the overlay files to be deleted. Which single virsh command will perform this task?

  • virsh blockcommit vm1 vda --active --pivot --verbose

  • virsh snapshot-revert vm1 snap1 --running

  • virsh blockpull vm1 vda --wait --verbose

  • virsh blockcopy vm1 vda /var/lib/libvirt/images/base.img --wait

Question 9 of 20

A PHP application running under Apache on a CentOS 9 Stream server fails to open a TCP connection to a remote MariaDB database on port 3306 while SELinux is in enforcing mode. The audit log records a name_connect denial for the httpd_t domain to mysql_port_t. To permanently grant only the required permission-letting the web server reach the database but not other arbitrary network ports-which SELinux Boolean should you enable?

  • allow_httpd_connect_mysql

  • httpd_can_network_connect

  • httpd_can_network_connect_db

  • httpd_can_network_memcache

Question 10 of 20

A systems administrator is managing a KVM hypervisor and needs to dynamically increase the memory available to a running virtual machine named 'db-server-01'. The VM is currently running with 2GB of RAM but is configured to support a maximum of 8GB. Which of the following commands will successfully allocate a total of 4GB of RAM to the running VM without requiring a restart?

  • virsh edit db-server-01

  • virsh setmem db-server-01 4G --live

  • virsh setmaxmem db-server-01 4G --config

  • virsh memtune db-server-01 --hard-limit 4G

Question 11 of 20

A systems administrator is editing a script file in the nano text editor and needs to replace every instance of the word "temp" with "local". After opening the file in nano, which key combination should the administrator press to initiate the search and replace function?

  • Ctrl+\

  • Ctrl+O

  • Ctrl+G

  • Ctrl+W

Question 12 of 20

A system administrator is writing a backup script. The script should use the directory specified in the BACKUP_DIR environment variable. If BACKUP_DIR is not set or is empty, the script should default to using /var/backups for the current operation without permanently changing the BACKUP_DIR variable.

Which of the following commands correctly assigns the appropriate directory to the target_dir variable?

  • target_dir=${BACKUP_DIR:-/var/backups}

  • target_dir=${BACKUP_DIR:?/var/backups}

  • target_dir=${BACKUP_DIR:+/var/backups}

  • target_dir=$

Question 13 of 20

A system administrator is tasked with deploying a multi-service web application. The application's source code includes a docker-compose.yml file that defines all the necessary services, networks, and volumes. Which of the following commands should the administrator run from the directory containing the file to build, create, and start the entire application stack in the foreground?

  • docker-compose start

  • docker-compose up

  • docker-compose exec

  • docker-compose build

Question 14 of 20

An organization must run dozens of containers on a production Linux server that is connected to an access-layer switch enforcing a "one-MAC-address-per-port" security rule. Each container must still obtain its own routable IPv4 address on the same VLAN and communicate directly with other hosts on that segment, without the NAT that the default bridge network applies. Which container network type should the administrator configure for these containers?

  • IPvlan network driver

  • Host network driver

  • Bridge network driver

  • Macvlan network driver

Question 15 of 20

While reviewing a Python 3 script that inventories running services, you notice the author indented one line with a tab and the next with four spaces. Running the script immediately raises:

TabError: inconsistent use of tabs and spaces in indentation

The developer also wants to make the code conform to the PEP 8 style guide. Which modification will resolve the error and satisfy PEP 8 recommendations?

  • Replace every indentation level with a single tab character; PEP 8 requires tabs rather than spaces.

  • Add a shebang of #!/usr/bin/env python -tt so Python automatically treats tabs as four spaces at runtime.

  • Replace every indentation level with exactly four space characters and remove all tabs.

  • Convert the file's line endings to LF (Unix style); inconsistent CRLF endings are what trigger the TabError.

Question 16 of 20

While logged into a Bash shell on a Linux server, you start a large copy operation in the foreground:

$ cp -av /media/usb/ /srv/data/

Realizing you chose the wrong destination, you press Ctrl + c in the same terminal. The copy stops immediately and the prompt returns. According to POSIX signal behavior, which signal did the terminal send to the cp process and what is that signal's default action?

  • SIGINT (signal 2) - terminate the process

  • SIGTSTP (signal 20) - suspend (stop) the process

  • SIGTERM (signal 15) - request the process to terminate gracefully

  • SIGQUIT (signal 3) - terminate the process and create a core dump

Question 17 of 20

A systems administrator is writing a troubleshooting script that calls head on whatever files are passed on the command line. The script should show the first 15 lines of each file and print a filename header (the "> filename <" line) even when the script receives only a single file. Which head invocation satisfies these requirements if the shell variable $FILES already holds the list of filenames?

(Note: assume a GNU/Linux system with the standard coreutils implementation of head.)

  • head -c 15 -v $FILES

  • head -q -n 15 $FILES

  • head -n 15 -v $FILES

  • head -n 15 $FILES

Question 18 of 20

A system administrator needs to update a configuration file named app.conf. They must replace every instance of the old IP address 192.168.1.5 with the new IP address 10.10.0.5 within the file. The changes need to be saved directly back into app.conf. Which of the following commands will accomplish this task correctly?

  • sed 's/192.168.1.5/10.10.0.5/g' app.conf

  • sed -i 's/192.168.1.5/10.10.0.5/' app.conf

  • sed -i 's/192.168.1.5/10.10.0.5/g' app.conf

  • sed 's/192.168.1.5/10.10.0.5/g' app.conf > app.conf

Question 19 of 20

On a freshly installed Ubuntu 22.04 server you create a user called alex and add the account to the sudo group with:

sudo usermod -aG sudo alex

After logging out and back in, alex can run sudo apt update even though neither /etc/sudoers nor any file in /etc/sudoers.d has been edited.
Which explanation correctly describes why this procedure works?

  • The default /etc/sudoers file contains the entry %sudo ALL=(ALL:ALL) ALL, so any user added to the sudo group may execute any command with sudo after entering their own password.

  • A built-in polkit rule maps the sudo group to the wheel role, providing password-less root access only from the system console.

  • When a session is started by a sudo group member, PAM grants the CAP_SYS_ADMIN capability to all of the user's processes, eliminating the need for sudo.

  • Members of the sudo group are automatically assigned UID 0 in /etc/passwd, giving them root privileges without needing sudo or a password.

Question 20 of 20

A Linux administrator manages a multi-container application with a compose.yaml file. After a successful deployment with podman-compose up -d, they need to completely tear down the environment for a system update. This process requires stopping the containers, removing the containers and their associated networks, and also deleting the named volumes defined in the compose.yaml file. Which single command should the administrator use to achieve this full cleanup?

  • podman-compose down --volumes

  • podman-compose down

  • podman-compose rm --force --volumes

  • podman-compose stop