00:20:00

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.

Logo for CompTIA Linux+ XK0-005 (v7)
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-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

Press start when you are ready, or press Change to modify any settings for the practice test.

  • Questions: 20
  • Time: Unlimited
  • Included Topics:
    System Management
    Security
    Scripting, Containers, and Automation
    Troubleshooting
Question 1 of 20

Which lvchange option is used to prevent allocation of physical extents to a logical volume?

  • -r or --resizefs

  • -an or --activate no

  • -l +100%FREE

  • -a n or --alloc none

Question 2 of 20

A staging server needs to run a database from a prebuilt container image. The service must operate in the background, listen on host port 5432, use the name stagedb, and restart automatically on host reboot. Which command fulfills these requirements?

  • docker run --name stagedb -p 5432:5432 postgres:13

  • docker run -d --rm --name stagedb -p 5432:5432 --restart unless-stopped postgres:13

  • docker start -d --name stagedb -p 5432:5432 postgres:13

  • docker run -d --name stagedb -p 5432:5432 --restart unless-stopped postgres:13

Question 3 of 20

What command is used in a shell script to perform actions based on whether a particular condition is met or not?

  • case

  • while

  • if

  • for

Question 4 of 20

A Linux administrator runs the command ping -c 1 192.168.1.255 || echo "Host is not responding.". Under which of the following conditions will the message "Host is not responding." be displayed on the terminal?

  • The message will never be displayed because of a syntax error.

  • Only if the ping command successfully reaches the host.

  • Only if the ping command fails to reach the host.

  • The message will always be displayed, regardless of the ping result.

Question 5 of 20

A system administrator is writing a shell script that periodically checks the disk space usage on a Linux server. To ensure that the output of the disk check does not flood the terminal or logs when running the script via a cron job, the administrator wants to discard the standard output. Which command redirection to /dev/null achieves this purpose?

  • df -h | /dev/null

  • df -h &> /dev/null

  • df -h > /dev/null

  • df -h 2> /dev/null

Question 6 of 20

You download a custom .deb file and run dpkg --install package.deb, but the operation fails because other packages are not present. Which command will install this file and pull in any needed components from your configured repositories?

  • apt install ./package.deb

  • dpkg --force-depends package.deb

  • dpkg --install package.deb

  • apt-get install package.deb

Question 7 of 20

A Linux system administrator needs to modify the firewall settings to allow access to a web server service that has been recently configured to listen on a non-standard port, 8443 for secure traffic. Simultaneously, they must ensure that other services remain unaffected by this firewall change. To apply this change immediately and make it permanent for subsequent system reboots, which of the following commands should the administrator execute?

  • firewall-cmd --permanent --zone=public --add-port=443/tcp

  • firewall-cmd --permanent --add-port=8443/tcp && firewall-cmd --reload

  • iptables -I INPUT -p tcp --dport 8443 -j ACCEPT && service iptables save

  • firewall-cmd --permanent --add-service=https

Question 8 of 20

An administrator notices that a recently mounted ext4 filesystem is not correctly recording the access times of files when they are read. The administrator suspects that a mount option may be causing this behavior. Which of the following mount options did the administrator most likely use when mounting the filesystem?

  • relatime

  • noatime

  • sync

  • dirsync

Question 9 of 20

What is the role of a private key in a public key infrastructure (PKI)?

  • It is used to decrypt data that has been encrypted with the corresponding public key and to create digital signatures.

  • It is distributed to the public for encrypting data intended for the key's owner.

  • It verifies the authenticity of digital certificates issued by the certificate authority.

  • It acts as a universally recognized identifier for the key's owner in all encrypted communications.

Question 10 of 20

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

Question 11 of 20

A systems administrator needs to deploy a containerized application that requires high network performance and needs to bind directly to a port on the host machine, bypassing any network address translation (NAT). Which container network mode should the administrator use to achieve this?

  • none

  • bridge

  • overlay

  • host

Question 12 of 20

Which command would you use to create a new container from an existing image and start it immediately?

  • docker commit

  • docker run

  • docker build

  • docker create

Question 13 of 20

After installing a new network adapter in a Linux server, users report sporadic and sluggish connections to hosted services. Upon inspecting the interface statistics, you notice an abnormally high count of discarded packets. Identifying the probable root cause of this issue is your next step. Which of the following should you investigate first?

  • Verify that the network configurations on the server are correctly assigned

  • Check for duplex mismatch between the network adapter and the corresponding switch configuration

  • Examine the physical cables for signs of damage or wear

  • Investigate a possible speed mismatch between the server's network adapter and the clients' adapters

Question 14 of 20

A system administrator wrote a shell script to display a two‐line status message:

STATUS="Update complete\nReview logs for details"
echo "$STATUS"

When executed, the output shows the literal \n instead of splitting into two lines. Which modification ensures the backslash‐escaped sequence is rendered as an actual newline?

  • Include -e with the output command

  • Enclose the string in single quotes

  • Use a here‐document for the text block

  • Include -n with the output command

Question 15 of 20

In a Linux system, what is the effect of redirecting the output of a command to /dev/null (for example, mycommand > /dev/null)?

  • The data is compressed and stored in a temporary buffer for later retrieval.

  • The data is encrypted and saved in the user's home directory.

  • The data is mirrored to the system console while also remaining available in the file.

  • The data is discarded permanently; the write appears to succeed but nothing is stored.

Question 16 of 20

An employee reports they cannot log in because their account has been locked after multiple unsuccessful password attempts. Which command will restore access by reversing the lock state on their account?

  • passwd -u alice

  • passwd -d alice

  • chage -E 0 alice

  • usermod -L alice

Question 17 of 20

What command would be used to perform a basic scan of a target system's open ports using Nmap?

  • nmap --top-ports 10

  • nmap

  • nmap -sV

  • nmap -A

Question 18 of 20

A system administrator is writing a shell script that must prompt a user for a file name and then efficiently read only the first line of that file into a variable. Which of the following commands is the most efficient and idiomatic method to achieve this in Bash?

  • read -p "Enter the file name: " file; IFS= read -r line < "$file"

  • read -p "Enter the file name: " file; IFS= read -r line <<< $(cat "$file")

  • read -p "Enter the file name: " file; IFS= read -r line <<< "$file"

  • read -p "Enter the file name: " file; line=$(cat "$file" | head -n 1)

Question 19 of 20

A system administrator created a timer unit named backup.timer in /etc/systemd/system with the following sections:

[Unit]
Description=Run backup script after boot

[Timer]
OnBootSec=5min

[Install]
WantedBy=multi-user.target

After running systemctl daemon-reload, enabling backup.timer, and rebooting, the backup.service did not run 5 minutes after boot. What modification ensures the timer starts and triggers as intended?

  • Set DefaultDependencies=no in [Install]

  • Change WantedBy in [Install] to timers.target

  • Add Persistent=true under [Timer]

  • None of the options

Question 20 of 20

A systemd unit must invoke a shell script once the daemon’s main process exits and its shutdown sequence has finished. Which [Service] directive specifies this script?

  • ExecStopPost=/usr/local/bin/cleanup.sh

  • ExecReload=/usr/local/bin/cleanup.sh

  • ExecStartPre=/usr/local/bin/cleanup.sh

  • ExecStartPost=/usr/local/bin/cleanup.sh