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 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.
Scroll down to see your responses and detailed results
Free CompTIA Linux+ XK0-005 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 ManagementSecurityScripting, Containers, and AutomationTroubleshooting
A system administrator has been tasked with writing a shell script that reads a list of usernames from a text file named 'users.txt' and then checks whether each user exists on the system. The admin decides to use a loop along with a built-in command to verify this. Which command should be used within the loop to check the presence of a user account in the system environment?
- You selected this option
whoami
- You selected this option
pwd
- You selected this option
hostname
- You selected this option
id
- You selected this option
date
Answer Description
The 'id' command is used to obtain user and group identity information, which makes it an appropriate tool for checking whether a user account exists. Specifically, the id command returns the user and group information for the specified username, and if the user does not exist, it will produce an error message. The other commands listed do not serve the purpose of checking for the existence of a user account. For instance, 'pwd' displays the current directory, 'whoami' shows the current user, 'date' outputs the current date and time, and 'hostname' reveals the system's host name.
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 'id' command do beyond checking user existence?
Can you explain what a shell script is and how it works?
What are the differences between 'id', 'whoami', and 'pwd' commands?
A system administrator needs to check the maximum amount of RAM supported by the server's motherboard. Which command would provide this information?
- You selected this option
lsblk
- You selected this option
dmidecode --type memory
- You selected this option
dmidecode -s system-product-name
- You selected this option
lscpu
Answer Description
The command dmidecode --type memory
is used to retrieve detailed information about the server's memory, including the maximum capacity supported by the motherboard. This is critical when planning upgrades or diagnosing memory-related issues. The other commands listed either provide information about the overall system (dmidecode -s system-product-name
), display usage by current components (lsblk
), or provide specific processor information (lscpu
), but do not offer details about maximum RAM capacity.
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 `dmidecode` and how does it work?
What is the difference between the `dmidecode` commands listed in the question?
Why is knowing the maximum RAM supported important for system administrators?
The command 'at' can be used to schedule a job for a specific time without the requirement for that to recur at regular intervals.
- You selected this option
The statement is accurate
- You selected this option
The statement is inaccurate
Answer Description
The 'at' command is indeed used for one-time task scheduling on Linux systems. It does not provide a way to schedule recurring jobs; that functionality is handled by 'cron'. Therefore, 'at' is suitable for tasks that need to be run once at a certain point in time in the future.
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 'at' and 'cron' commands?
How do you use the 'at' command to schedule a task?
What types of tasks can be scheduled with the 'at' command?
The security policy of your company requires a stealthy scan to minimize the chances of detection by the target system's intrusion detection system (IDS). Which Nmap command would perform a SYN scan, while also spoofing the source port to appear as 53 (DNS) and avoiding port 22 on the target 10.0.0.12?
- You selected this option
nmap -sS -g 53 --exclude-ports 22 10.0.0.12
- You selected this option
nmap -sT --spoof-port 53 -p-22 10.0.0.12
- You selected this option
nmap -sS -D RND:10 -g 53 10.0.0.12
- You selected this option
nmap -sS --source-port 53 --excludefile no-scan-22.txt 10.0.0.12
- You selected this option
nmap -sU -g 53 -p !22 10.0.0.12
- You selected this option
nmap -sS -Pn -g 53 --skip-port 22 10.0.0.12
Answer Description
The correct answer is nmap -sS -g 53 --exclude-ports 22 10.0.0.12. The -sS flag specifies a SYN scan, which is considered stealthier than a connect scan. The -g 53 option sets the source port to 53, which may help in evading certain IDS configurations as it makes the scan look like DNS traffic. The --exclude-ports 22 option ensures that port 22 is not scanned. The other answers either do not correctly form the combination or are not the proper usage of Nmap flags, making them incorrect for the required stealthy scan excluding port 22.
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 a SYN scan in Nmap?
What does the '-g' option do in Nmap?
What is an Intrusion Detection System (IDS)?
A Linux administrator needs to grant a user named 'jane' write access to a file called 'data.log', which is currently only accessible by its owner 'john'. The file should not have its existing permissions altered for any other user or group. Which of the following commands would correctly grant 'jane' the required access?
- You selected this option
setfacl -m u:jane:rwx data.log
- You selected this option
setfacl -m u:jane:w data.log
- You selected this option
chmod u+w data.log
- You selected this option
chmod +w data.log
- You selected this option
chown jane data.log
- You selected this option
setfacl -m o:w data.log
Answer Description
The correct answer is setfacl -m u:jane:w data.log
because the setfacl
command is used to set Access Control Lists, and -m
is used to modify the ACL by adding a new rule. The rule u:jane:w
specifies that the user 'jane' is given write (w
) access. Using ACLs allows for extending the permission set beyond the traditional owner, group, and others model.
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 are Access Control Lists (ACLs)?
What is the difference between 'chmod' and 'setfacl'?
How does the 'setfacl -m' command work?
What operation should be periodically performed on a solid-state storage device to indicate which sectors are no longer in use?
- You selected this option
Performing a surface scan
- You selected this option
Running a defragmentation program
- You selected this option
Executing a trim command
- You selected this option
Increasing the partition size
- You selected this option
Conducting a sector-by-sector backup
Answer Description
The operation, known as 'trim,' is crucial for solid-state storage devices. It marks sectors as no longer in use, which allows the device's controller to manage flash memory cells efficiently. This process avoids unnecessary write and erase cycles, thus maintaining optimal performance and extending the lifespan of the storage device. It is important to note that traditional defragmentation is not only unnecessary for these devices but also potentially harmful, as it increases write operations without any performance gain.
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 trim command do specifically?
Why is defragmentation not recommended for SSDs?
How does the trim command extend the lifespan of SSDs?
As a system administrator, you have received a file named 'logins.txt' containing a list of usernames. However, the usernames are separated by commas and you need them to be separated by newlines to process them in a script. Using the 'tr' command, how would you translate the commas into newline characters in a shell script?
- You selected this option
tr ',' '\n' < logins.txt
- You selected this option
tr -s ',' '\n' logins.txt
- You selected this option
tr '\n' ',' < logins.txt
- You selected this option
tr -d ',' '\n' logins.txt
Answer Description
The command 'tr ',' '\n' < logins.txt' is used for replacing all commas in the file 'logins.txt' with newline characters. This is the correct use of the 'tr' command where the first argument is the set of characters to be replaced (commas) and the second argument is the set of characters to replace with (newline characters). The '<' operator is used to pass the contents of 'logins.txt' to the 'tr' command.
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 'tr' command do?
What does the '<' operator do in the command?
Why would newline characters be used instead of commas for usernames?
What is the primary function of the 'resolvectl' command in a Linux system?
- You selected this option
Manage DNS resolution on the system
- You selected this option
Enable or disable network interfaces
- You selected this option
Establish a VPN connection
- You selected this option
Monitor network traffic in real time
Answer Description
The 'resolvectl' command is used to query and change the system resolver settings, typically provided by the systemd-resolved
service. It effectively allows users to manage DNS settings, such as querying DNS records or changing the DNS server used by the system. Answer A is correct because it directly pertains to managing DNS resolution on the system, which is the primary role of 'resolvectl'. Answer B is incorrect because 'resolvectl' does not manage the enabling or disabling of network interfaces; 'ip' or 'ifconfig' would be used for that. Answer C is incorrect because 'resolvectl' does not provide the functionality to monitor network traffic, which would be accomplished with tools like 'tcpdump' or 'wireshark'. Answer D is incorrect as it describes a function of 'networkmanager' or 'nmcli', not 'resolvectl'.
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 DNS and why is it important?
What is systemd-resolved and how does it relate to 'resolvectl'?
Are there alternative tools to 'resolvectl' for managing DNS settings?
A system administrator needs to monitor resource usage and performance in real time to identify a process that is consuming an unusually high percentage of CPU resources. Which of the following commands provides the BEST solution for this requirement?
- You selected this option
cat /proc/cpuinfo
- You selected this option
pscat
- You selected this option
ps aux --sort -%cpu
- You selected this option
top
Answer Description
The 'top' command is the correct answer because it displays a real-time view of system processes, including CPU usage, memory consumption, and other important metrics. By using 'top', the administrator can easily identify processes that are using a high percentage of CPU resources. Other commands listed either do not provide real-time monitoring, or they address different aspects of system management.
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 information does the 'top' command provide about system processes?
How does 'top' compare to the 'ps' command in terms of monitoring resources?
What other commands can be used for monitoring CPU usage in Linux?
Which command would you use to download a file from the internet using the command line while ensuring that the output is saved with a specific filename?
- You selected this option
wget --output-file desired_filename http://example.com/file
- You selected this option
wget -O desired_filename http://example.com/file
- You selected this option
wget --save-as desired_filename http://example.com/file
- You selected this option
wget --download-as desired_filename http://example.com/file
Answer Description
The wget -O
command allows you to specify a filename for the saved content when downloading from the internet. This is useful when you want to control the naming of downloaded files, especially when the default name is not descriptive or conflicts with existing files in your directory. The -O
option specifically designates the output filename.
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 'wget' command do?
What are some common options used with 'wget'?
What is the difference between the '-O' option and saving files with the default name in 'wget'?
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?
- You selected this option
chronyc sources
- You selected this option
chronyc add server
- You selected this option
chronyc tracking
- You selected this option
chronyc sourcestats
Answer Description
To check the current time synchronization status and performance metrics such as system time, frequency, and estimated error, the chronyc tracking
command should be used. This command provides detailed information about the performance of the timekeeping system, making it invaluable for diagnosing issues related to time synchronization. Other commands like chronyc sources
, chronyc add server
, and chronyc sourcestats
serve different purposes: sources
displays information about the time sources that are currently being used, add server
is not a valid command, and sourcestats
reports on the drift and dispersion of the sources being tracked. However, when it comes to verifying the synchronization status and performance of the server, chronyc tracking
is the correct command to use.
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 provide?
What are the functions of the other `chronyc` commands mentioned?
What is the significance of time synchronization in servers?
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?
- You selected this option
noatime
- You selected this option
dirsync
- You selected this option
sync
- You selected this option
relatime
Answer Description
The correct answer is 'noatime'. This mount option disables the updating of access times on files when they are read, which can improve performance, especially on frequently accessed filesystems. The 'relatime' option updates access times only if the previous access time was earlier than the current modify or change time. 'sync' and 'dirsync' are not directly related to file access time updates; 'sync' makes all writes synchronous, and 'dirsync' ensures directory changes are written synchronously, but neither disables the update of access times.
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 'noatime' do in the context of filesystems?
How does 'relatime' differ from 'noatime'?
What are the implications of using 'sync' and 'dirsync' mount options?
The command make install
is used before the command ./configure
when compiling a package from source.
- You selected this option
True
- You selected this option
False
Answer Description
When compiling software from source in Linux, the correct sequence of commands starts with ./configure
to set up the environment and options for the compilation. Afterward, make
is used to compile the source code into executable binaries, and finally, make install
is executed to install the binaries into the system. Therefore, make install
comes after and not before ./configure
.
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 './configure' command do?
What is the role of 'make' in the compilation process?
How does 'make install' function in the software installation process?
As a system administrator, you need to remove a user's account from a Linux system. The user's account, 'johndoe', must be deleted along with the user's home directory and mail spool. Which command should you use to accomplish this task?
- You selected this option
removeuser --files johndoe
- You selected this option
userdel -r johndoe
- You selected this option
deluser johndoe
- You selected this option
userdel johndoe
Answer Description
The command userdel -r johndoe
will remove the user 'johndoe' and delete the user's home directory as well as the mail spool. The -r
option stands for 'remove' and is used specifically for this purpose. Simply using userdel johndoe
would not remove the home directory or mail spool. deluser
and removeuser
are not standard Linux commands. It is essential to use the correct options and command to ensure proper cleanup of user 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 does the -r option in the userdel command do?
What is the difference between userdel and deluser commands?
Why is it important to remove a user's home directory and mail spool?
As a systems administrator, you need to grant a user named 'techuser' the ability to run all commands as any user on a specific Linux server. To accomplish this, you decide to edit the sudoers file. Which of the following entries should you add to the sudoers file using the 'visudo' command to meet this requirement?
- You selected this option
techuser ALL=(ALL:ALL) ALL
- You selected this option
ALL techuser=(ALL:ALL) ALL
- You selected this option
techuser ALL=(ALL) ALL
- You selected this option
techuser ANY=(ALL:ALL) NOPASSWD: ALL
Answer Description
The correct entry is 'techuser ALL=(ALL:ALL) ALL' which grants the user 'techuser' the ability to run any command as any user on all hosts. The 'ALL=(ALL:ALL)' portion indicates that from any host (the first 'ALL'), 'techuser' can execute commands as any user (the second 'ALL') and as any group (after the colon). The final 'ALL' specifies that any command can be executed. This entry provides the specific privileges required without providing unnecessary access, adhering to the principle of least privilege. The incorrect answers either do not provide the required privileges, have syntax errors, or grant privileges that are too broad, which could pose a security risk.
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 sudoers file and why is it important?
What does the 'visudo' command do?
What does the syntax 'techuser ALL=(ALL:ALL) ALL' mean?
Wow!
Looks like that's it! You can go back and review your answers or click the button below to grade your test.