Free XK0-004 Sample Questions — CompTIA Linux+

Free XK0-004 sample questions for the CompTIA Linux+ exam. No account required: study at your own pace.

Want an interactive quiz? Take the full XK0-004 practice test

Looking for more? Click here to get the full PDF with 279+ practice questions for $10 for offline study and deeper preparation.

Question 1

An administrator needs to create a file named hello in the home directory that contains the following text: it's me! Which of the following commands would accomplish this goal?

  • A. mkdir ~/hello touch ~/"it's me!"
  • B. touch ~/hello echo "it's me!" > ~/hello
  • C. mv ~/hello cp "it's me!" > ~/hello
  • D. type ~/hello print "it's me!"
Show Answer
Correct Answer:
B. touch ~/hello echo "it's me!" > ~/hello
Question 2

An administrator notices that a long-running script, /home/user/script.sh, is taking up a large number of system resources. The administrator does not know the script's function. Which of the following commands should the administrator use to minimize the script's impact on system resources?

  • A. renice
  • B. kill
  • C. bg
  • D. nohup
Show Answer
Correct Answer:
A. renice
Question 3

A Linux administrator is setting up a testing environment and needs to connect to a separate testing server using the production server name. The administrator needs to override the hostname that the DNS is returning in order to use the test environment. Which of the following commands should be run on each of the testing systems to BEST meet this goal?

  • A. # hostnamectl set-hostname "192.168.1.100 production.company.com"
  • B. # grep ""i IP "${ip addr show} production.company.com" > /etc/resolv.conf
  • C. # ip addr add 192.168.1.100/24 dev eth0 && rndc reload production.company.com
  • D. # echo "192.168.1.100 production.company.com" >> /etc/hosts
Show Answer
Correct Answer:
D. # echo "192.168.1.100 production.company.com" >> /etc/hosts
Question 4

A site reliability engineer updated the latest configuration management scripts and committed them to a workstream called either test or patch. A Linux administrator wants to ensure these latest workstreams are able to be retrieved to the server. Which of the following is the BEST Git attribute to use?

  • A. branch
  • B. fetch
  • C. log
  • D. pull
Show Answer
Correct Answer:
B. fetch
Question 5

A systems administrator suspects a process with a PID of 2864 is consuming resources at an alarming rate. The administrator uses the command renice -n - 5 -p2864, but it does not solve the issue. Which of the following commands should the administrator execute to correct the issue?

  • A. nice -n 5 -p 2864
  • B. nice -n -5 -p 2864
  • C. renice -n 10 -p 2864
  • D. renice -n -10 -p 2864
Show Answer
Correct Answer:
C. renice -n 10 -p 2864
Question 6

A Linux user wants to give read-only permissions to a directory and its contents. Which of the following commands will allow the user to accomplish this task?

  • A. chmod ""R 400 /new_directory/
  • B. chmod ""R 600 /new_directory/
  • C. chmod 400 /new_directory/
  • D. chmod 600 /new_directory/
Show Answer
Correct Answer:
A. chmod ""R 400 /new_directory/
Question 7

A Linux administrator is troubleshooting an issue with a shell script. Users in the accounting department are unable to run the script, but users in the sales department are not having issues. Users in both departments should be able to run the script. The administrator checks the permissions on the script and receives the following information: -r-xr-xr-- joe sales script.sh Which of the following commands should the administrator execute to resolve the problem?

  • A. chgrp accounting script.sh
  • B. chmod 644 script.sh
  • C. chown accounting script.sh
  • D. chmod a+x script.sh
Show Answer
Correct Answer:
D. chmod a+x script.sh
Question 8

Using which of the following control mode commands is the correct way to substitute all occurrences of /dev/sdc with /dev/sdd while editing a file in vi?

  • A. :s//dev/sdc//dev/sdd
  • B. :s/\/dev\/sdc/\/dev\/sdd/g
  • C. :s/\/dev\/sdc/\/dev\/sdd
  • D. :%s/\/dev\/sdc/\/dev\/sdd
Show Answer
Correct Answer:
D. :%s/\/dev\/sdc/\/dev\/sdd
Question 9

Which of the following commands would show the default printer on a Linux system?

  • A. lpr
  • B. lpq
  • C. lpstat
  • D. lspci
Show Answer
Correct Answer:
C. lpstat
Question 10

A systems administrator wants to mount an ISO to access its content. Using /mnt as a mount point, which of the following is the correct syntax?

  • A. mount -o iso9660 /dev/sr0 /mnt
  • B. mount -o loop -t iso /mnt
  • C. mount -o loop /tmp/image.iso /mnt
  • D. mount -o loop /dev/kvm /mnt
Show Answer
Correct Answer:
C. mount -o loop /tmp/image.iso /mnt
Question 11

The development team has automated their software build process so each time a change is submitted to the source code repository, a new software build is compiled. They are requesting that the Linux operations team look into automating the deployment of the software build into the test environment. Which of the following is the benefit to the development team for implementing deployment automation?

  • A. To ensure the build commits are also deployed to the test environment
  • B. To enable notifications when builds are deployed to the test environment
  • C. To ensure software builds in test are not accidentally deployed to production
  • D. To streamline the deployment process for deploying builds into test environments
Show Answer
Correct Answer:
D. To streamline the deployment process for deploying builds into test environments
Question 12

A Linux administrator is creating a new local Linux user account for a web application. The account has the following requirements: • Use /var/www as the home directory • Have the service_accounts group as its primary group • Have the www user group as a secondary group • Disable the account when the password expires Which of the following BEST meets these requirements?

  • A. useradd -D /var/www/ -g service_accounts -G www -e 0
  • B. useradd -d /var/www/ -G service_accounts -f www -g 0
  • C. useradd -D /var/www -G service_accounts -g www -e 0
  • D. useradd -d /var/www/ -g service_accounts –G www -f 0
Show Answer
Correct Answer:
D. useradd -d /var/www/ -g service_accounts –G www -f 0
Question 13

Which of the following is true about Type 2 hypervisors?

  • A. Type 2 hypervisors run on top of another general purpose OS
  • B. Type 2 hypervisors are often called bare-metal or native hypervisors
  • C. Type 2 hypervisors offer a performance increase to the guests in comparison to a Type 1 hypervisor
  • D. Only Type 2 hypervisors allow direct access to CPU virtualization features
Show Answer
Correct Answer:
A. Type 2 hypervisors run on top of another general purpose OS
Question 14

Given that a company's policy states that users cannot install third-party tools on Window servers, which of the following protocols will allow a Linux GUI to connect to a Windows server?

  • A. VNC
  • B. NX
  • C. RDP
  • D. X11
Show Answer
Correct Answer:
C. RDP
Question 15

After connecting a USB drive, the system is unable to detect it. There is no entry in /dev, and there is no information in the message log. Which of the following is the issue?

  • A. The USB drive is formatted as a DVD
  • B. The USB drive is not formatted
  • C. The kernel module is not installed
  • D. The permissions of /dev/usb are incorrect
Show Answer
Correct Answer:
C. The kernel module is not installed
Question 16

Which of the following is the purpose of the monitoring server role?

  • A. To aggregate web traffic to watch which websites employees are visiting
  • B. To collect status and performance information about the servers in an environment
  • C. To provide user authentication services to a network
  • D. To provide real-time analysis of potential threats to the organization
Show Answer
Correct Answer:
D. To provide real-time analysis of potential threats to the organization
Question 17

Which of the following allows communication over port 3389 to access GUI services?

  • A. XRDP
  • B. VNC
  • C. Xfce
  • D. KDE
  • E. X-forwarding
Show Answer
Correct Answer:
A. XRDP
Question 18

An administrator needs to deploy 100 identical CentOS workstations via PXE boot. Which of the following should the administrator use to minimize the amount of interaction with the consoles needed?

  • A. Kickstart script
  • B. Ghost image on a distribution server
  • C. Hard disk duplicator
  • D. Hard disk duplicator
  • E. Ubiquity script
Show Answer
Correct Answer:
A. Kickstart script
Question 19

An administrator is setting up a script named script.sh to be executed daily at 3:15 a.m. Which of the following is the correct way to define this in crontab?

  • A. * * * 15 3 script.sh
  • B. 3 15 * * * script.sh
  • C. * * * 3 15 script.sh
  • D. 15 3 * * * script.sh
Show Answer
Correct Answer:
D. 15 3 * * * script.sh
Question 20

After running an Nmap scan on a local area network, a penetration tester notices several older Linux servers have port 23 open. Which of the following should the systems administrator do as a security best practice?

  • A. Use a non-standard port for Telnet
  • B. Disable and uninstall the Telnet service
  • C. Ensure the kernels are up to date with the latest patches
  • D. Configure the firewall to allow Telnet access only from trusted networks
Show Answer
Correct Answer:
A. Use a non-standard port for Telnet

Aced these? Get the Full Exam

Download the complete XK0-004 study bundle with 279+ questions in a single printable PDF.