A technician needs to copy a directory tree from /home/user/docs to a backup location /backup/docs, preserving all permissions, ownership, and timestamps. Which command should they use?
The `-a` (archive) flag bundles `-dR --preserve=all`, recursing through the tree while retaining permissions, ownership, timestamps, and symlinks. This directly satisfies the stem's requirement to preserve all three attributes during the copy from /home/user/docs to /backup/docs.
Why this answer
The `cp -a` (archive) command preserves all file attributes, including permissions, ownership, and timestamps, while recursively copying the entire directory tree. This is the most comprehensive single command for duplicating a directory with full metadata integrity.
Exam trap
CompTIA often tests the distinction between `-p` and `-a` by making candidates think preserving permissions and timestamps is sufficient, while the key requirement to preserve ownership is only met by `-a` (or running `-p` as root).
How to eliminate wrong answers
Option A is wrong because `cp -r` only performs a recursive copy without preserving ownership or timestamps; it may also alter permissions based on the current umask. Option C is wrong because `cp -p` preserves permissions and timestamps but does not preserve ownership (files will be owned by the copying user unless run as root). Option D is wrong because `rsync -r` recursively copies files but does not preserve ownership or timestamps by default; it requires additional flags like `-a` or `--archive` to achieve full preservation.