comptia xk0-004 online test

CompTIA Linux+ Certification Exam

What students need to know about the xk0-004 exam

  • Total 268 Questions & Answers

Question 1

A file server is sharing a directory called /share between team members inside a company. The fileshare needs to be moved
from serverA to /newshare located on serverB with all permissions and attributes preserved. Which of the following
commands would BEST achieve this task?

  • A. rsync -aHAX /share/* serverB:/newshare
  • B. dd if=/share/* of=serverB:/newshare
  • C. tar -cvf /share/* serverB:/newshare
  • D. mirrorlv /share/* serverB:/newshare
Answer:

A

Discussions

Question 2

A Linux administrator needs to back up files from a user's home directory to a remote server. The administrator copied the
files last week but must ensure any files created or modified since then are added.
Which of the following is the BEST command for the administrator to use?

Answer:

B

Discussions

Question 3

A member of the production group issues the following command:
echo "Monday through Friday" > /production_docs/days
The command fails to execute, so the user obtains the following output:
drwxr--r-- root production 0 Jun 16 2018 production
-rw-r--r-- production production 4096 Jun 14 2018 days
Which of the following commands should the user execute to BEST fix the issue?

  • A. chmod g+w production to change the permissions on the days file
  • B. chgrp root production_docs/days to change the group ownership of the production_docs/days file
  • C. chmod g+S production to set the GUID on the production_docs directory
  • D. chown production to change the ownership of the production_docs directory
Answer:

D

Discussions

Question 4

A Linux administrator needs the tech account to have the option to run elevated commands as root.
Which of the following commands would BEST meet this goal?

  • A. $ su – tech –c “/bin/bash”
  • B. # usermod –aG wheel tech
  • C. # sudo –i tech
  • D. # groupadd –u tech –g root
Answer:

B

Discussions

Question 5

An administrator needs to mount the shared NFS file system testhost:/testvolume to mount point /mnt/testvol and make the
mount persistent after reboot.
Which of the following BEST demonstrates the commands necessary to accomplish this task?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Answer:

A

Discussions

Question 6

A user issues the following command:
ls l /var/log | egrep e ^d[rwx]{3}.*[rw-]{3}.*
The list of files in the system is shown below:

Which of the following results matches the command issued?

  • A. drwxr-x--- 2 root adm 4096 Apr 25 14:41 unattended-upgrades drwxr-x--- 2 root adm 4096 Apr 25 15:41 attended- upgrades
  • B. drwxr-xr-x 2 root root 4096 Apr 24 08:36 apt drwxr-xr-x 2 root root 4096 Apr 9 14:25 dist-upgrade drwxr-x--- 2 root adm 4096 Apr 25 14:41 unattended-upgrades
  • C. drwxr-xr-x 2 root root 4096 Apr 24 08:36 apt drwxr-xr-x 2 root root 4096 Apr 9 14:25 dist-upgrade drwxr-x--- 2 root adm 4096 Apr 25 15:41 attended-upgrades
  • D. -rw-r--r-- 1 root root 2877 Apr 24 14:14 alternatives.log -rw-r--r-- 1 syslog adm 246139 Jun 12 15:21 cloud-init.log -rw-r--r-- 1 root root 8872 Jun 12 15:21 cloud-init-output.log
Answer:

D

Discussions

Question 7

During the final step of staging new Linux hardware, GRUB2 is installed to the system drive. Which of the following BEST
describes the role of GRUB2 in a new Linux installation?

  • A. It provides a menu for creating administrator task shortcuts.
  • B. It provides a menu for running special shell scripts.
  • C. It provides a method to partition a hard drive.
  • D. It provides a method to pass parameters to the Linux kernel on startup.
Answer:

B

Explanation:
Reference: https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/kernel-module-driver-
configuration/Working_with_the_GRUB_2_Boot_Loader/

Discussions

Question 8

Ann, a Linux administrator, wants to edit a configuration management file. When she opens the file to edit, her text editor
reports that the file has been opened in read-only mode. She then tries to edit the file as root by elevating via sudo and is still
unable to save any changes. The error message in her text editor says that the read-only option is set on the file. Ann
checks the permissions on the file and sees the following:
-rw-rw-r-- 1 root wheel 30 Jun 13 15:38 infrastructure.yml
Which of the following commands is the BEST option to allow her to successfully modify the file?

  • A. chmod 600 infrastructure.yml
  • B. chown root: infrastructure.yml
  • C. chattr -i infrastructure.yml
  • D. chmod o+w infrastructure.yml
Answer:

D

Explanation:
Reference: https://cets.seas.upenn.edu/answers/chmod.html

Discussions

Question 9

A Linux administrator has configured a Linux system to be used as a router. The administrator confirms that two network
adapters are properly installed and functioning correctly. In addition, the output of the iptables L command appears to
contain a complete firewall configuration.
Which of the following commands does the administrator need to issue for the router to be fully functional?

  • A. echo “1” > /proc/sys/net/ipv4/ip_forward
  • B. echo “0” > /proc/sys/net/ipv4/tcp_abort_on_overflow
  • C. echo “0” > /proc/sys/net/ipv4/max_connections
  • D. echo “1” > /proc/sys/net/ipv4/ip_default_ttl
Answer:

A

Discussions

Question 10

An administrator has a CSV file named hosts.csv. The contents of hosts.csv include the following:
192.168.2.57,lnx1prd.example.com,Linux,Production
192.168.2.58,lnx2prd.example.com,Linux,Production
192.168.1.4,server15.example.com,Windows,Development
The administrator needs to create a second comma-separated list of only the Linux server IP addresses. Which of the
following commands would achieve this need?

  • A. for ip in $(grep “Linux” hosts.csv | cut –d”,” –f1); do echo –n “$ip,”; done
  • B. for ip in $( cut –d”,” –f1 hosts.csv | grep “Linux”); do echo –n “$ip,”; done
  • C. for ip in $(grep “Linux” hosts.csv | sed “/$1//’); do echo –n “$ip,”; done
  • D. for ip in $(awk –F, ‘{print $1}’ hosts.csv | grep “Linux”); do echo –n “$ip,”; done
Answer:

C

Discussions
To page 2