00:15:00

Free CompTIA Linux+ XK0-005 Practice Test

Prepare for the CompTIA Linux+ XK0-005 exam with this free practice test. Randomly generated and customizable, this test allows you to choose the number of questions.

  • Questions: 15
  • Time: 15 minutes (60 seconds per question)
  • Included Objectives:
    • System Management
    • Security
    • Scripting, Containers, and Automation
    • Troubleshooting
Question 1 of 15

What is typically the primary consequence of unchecked memory leaks over time on a Linux system?

  • Increase in disk capacity

  • Memory exhaustion

  • Increased CPU utilization

  • Network bandwidth limitations

Question 2 of 15

A system administrator needs to write a shell script that prompts the user for a file name and then reads a single line from that file. The goal is to store this line in a variable for further processing. Which of the following options achieves this while making sure the script asks for the file name and reads only the first line of the provided 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)

  • 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)

Question 3 of 15

An administrator is tasked with running a remote session for a graphically-intensive application on a Linux server, where the display output is needed on a local machine. Given security considerations and the necessity for GUI rendering, which SSH command should the administrator use to initiate this remote session securely?

  • ssh -Y user@hostname

  • ssh -X user@hostname

  • ssh -x user@hostname

  • ssh -C user@hostname

Question 4 of 15

An administrator is diagnosing an issue where a filesystem on their Linux server appears to be mounted read-only, preventing users from writing data. Which mount option should have been specified during the mounting process to allow both read and write operations on the filesystem?

  • ro

  • user

  • rw

  • sync

Question 5 of 15

A process that has terminated but still appears in the process table with a status code 'Z' can be interacted with using the kill command to release its consumed resources.

  • True

  • False

Question 6 of 15

An administrator needs to download the latest version of an Ubuntu image for container deployment. Which of the following commands will perform this operation?

  • docker pull ubuntu

  • docker push ubuntu

  • pull ubuntu

  • docker rmi ubuntu

Question 7 of 15

Which command utility can be used to search for and replace patterns within a file, and it requires no additional scripting or programming?

  • awk

  • grep

  • tail

  • sed

Question 8 of 15

A system administrator needs to ensure a specific service starts automatically on system boot. Which of the following systemctl subcommands would allow the administrator to achieve this?

  • enable

  • start

  • status

  • reload

Question 9 of 15

A system administrator notices that an important server is experiencing intermittent problems with data integrity, and suspects filesystem corruption on one of its disks. After running fsck on the unmounted filesystem and fixing several errors, the administrator needs to ensure that the filesystem will be checked and repaired if necessary during the next system boot. Which of the following commands should the administrator use to schedule a filesystem check on boot?

  • tune2fs -i 0 /dev/sda1

  • e2fsck -p /dev/sda1

  • tune2fs -c 1 /dev/sda1

  • tune2fs -C 0 /dev/sda1

Question 10 of 15

A system administrator needs to find occurrences of the word 'refused' in the 'auth.log' file, which indicates failed SSH login attempts, and then count how many times this occurs. Which command will provide the accurate count?

  • grep -c 'refused' /var/log/auth.log

  • grep 'refused' /var/log/auth.log -c

  • grep -v 'refused' /var/log/auth.log | wc -l

  • grep 'refused' /var/log/auth.log | wc -l

Question 11 of 15

An administrator wants to prevent users from creating hard links to a certain sensitive file on a Linux system. Which command should the administrator use to achieve this security measure?

  • chmod 700 /path/to/file

  • chattr +i /path/to/file

  • chattr +a /path/to/file

  • setfacl -m u:user:--- /path/to/file

Question 12 of 15

What would be the result of the following command: echo 'The quick brown fox' | sed 's/quick/slow/'?

  • The quick brown fox

  • Theslowbrownfox

  • The slow brown fox

  • The quick slow brown fox

Question 13 of 15

A system administrator wants to generate a report of disk usage by each user in the home directory and store the output to a file called disk_report.txt, overwriting any existing data in the file. Which command should they use to accomplish this task?

  • du -h /home/* < disk_report.txt

  • du -h /home/* &> disk_report.txt

  • du -h /home/* > disk_report.txt

  • du -h /home/* >> disk_report.txt

Question 14 of 15

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

  • nmap --top-ports 10

  • nmap -A

  • nmap

  • nmap -sV

Question 15 of 15

During your routine system maintenance, you need to create an archive of the /var/log directory to preserve the system logs before clearing them for the new fiscal year. You decide to use the tar command to create a compressed archive. Which of the following commands correctly creates a gzip compressed archive of the /var/log directory named system_logs.tar.gz?

  • tar -rvf system_logs.tar.gz /var/log

  • tar cvzf /var/log > system_logs.tar.gz

  • tar -cv system_logs.tar.gz /var/log

  • tar -czvf system_logs.tar.gz /var/log