Difficulty: Easy
Correct Answer: cp
Explanation:
Introduction / Context:
File copying is foundational in system administration and scripting. UNIX/Linux uses a concise, portable command to copy files, preserve attributes, and recursively copy directory trees with optional flags for safety and verbosity.
Given Data / Assumptions:
Concept / Approach:
The cp command copies files. Common flags include -r or -R for recursive directory copy, -p to preserve mode, ownership, and timestamps, -i to prompt before overwrite, and -v for verbose progress. For archival purposes, tools like tar or cpio are preferable, but for direct filesystem copies, cp is primary.
Step-by-Step Solution:
Copy a single file: cp source.txt dest.txtCopy into a directory: cp source.txt /path/dir/Recursive directory copy: cp -R srcdir dstdirPreserve attributes: cp -p source dest
Verification / Alternative check:
Use ls -l and diff or checksums (md5sum/sha256sum) to verify results. For maintaining sparse files or extended attributes, consult distro-specific flags or use rsync.
Why Other Options Are Wrong:
copy (Option A) is a DOS/Windows command, not UNIX.cpio (Option C) and tar (Option D) are archiving tools rather than simple copy utilities.
Common Pitfalls:
Final Answer:
cp
Discussion & Comments