Difficulty: Easy
Correct Answer: cpio
Explanation:
Introduction / Context:
UNIX/Linux offers several tools for copying files and entire directory trees. While cp copies files and directories on the filesystem, cpio excels at moving directory structures into and out of archive streams, making it ideal for backups, restores, and piping with find and other tools.
Given Data / Assumptions:
Concept / Approach:
cpio reads file lists from standard input and creates or extracts archives. Typical usage pairs find with cpio to archive an entire tree reliably. It supports various formats and can preserve ownership, modes, and timestamps when run with appropriate privileges and flags.
Step-by-Step Solution:
Create an archive: find /src -depth -print | cpio -ov > backup.cpioExtract an archive: cpio -idv < backup.cpioCopy across filesystems via pipe: (cd /src; find . -print) | (cd /dst; cpio -pdmv)Verify with ls -lR or checksums to ensure integrity post-restore.
Verification / Alternative check:
Compare with tar for similar functionality. While tar is more prevalent today, cpio remains standard on many UNIX systems and integrates cleanly with find-generated file lists.
Why Other Options Are Wrong:
cp (Option A) copies files/dirs directly but is not an archive in/out utility.cp -p (Option C) preserves mode/timestamps/ownership but still is cp, not an archiver.copy (Option D) is a DOS/Windows command, not UNIX.
Common Pitfalls:
Final Answer:
cpio
Discussion & Comments