nerdexam
CompTIACompTIA

XK0-005 · Question #1831

XK0-005 Question #1831: Real Exam Question with Answer & Explanation

The correct answer is B: cp -R /opt/tools ~. To copy the /opt/tools directory and its contents to the /home/admin directory, the cp -R command with the tilde shorthand for the home directory is the correct approach.

System Management

Question

An administrator wants to copy files from /opt/tools to the home directory at /home/admin. Which of the following should the administrator run?

Options

  • Amkdir -p /home/admin/tools
  • Bcp -R /opt/tools ~
  • Ccd /opt/tools; rsync /home/admin
  • Dscp /opt/tools localhost:/

Explanation

To copy the /opt/tools directory and its contents to the /home/admin directory, the cp -R command with the tilde shorthand for the home directory is the correct approach.

Common mistakes.

  • A. mkdir -p only creates a directory if it does not already exist; it does not copy any files or directories.
  • C. rsync requires both a source and a destination, and the provided syntax is incomplete and incorrect for the stated goal of copying, as cd only changes the current directory.
  • D. scp is used for secure copying, but localhost:/ specifies the root directory on the local host, not the home directory, and this syntax is not the most direct way to copy a directory to a user's home folder.

Concept tested. File and directory copying with cp

Reference. https://linux.die.net/man/1/cp

Topics

#Linux Commands#File Copy#cp command#Home directory shortcut

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions