You are reorganizing a large set of configuration files on a running server. Everything under /etc/myapp (including hidden files) must be copied to /var/lib/myapp/backups on the same host immediately, with ownership, permissions, hard links, and modification times preserved. Because the application is live, you cannot waste time creating an intermediate archive file-you only want to copy the tree directly to the new location. Which command meets these requirements?
The task requires cpio's copy-pass (-p or --pass-through) mode, which reads a list of pathnames on standard input and writes them directly to the specified destination directory. This method is efficient because it eliminates the need to create an intermediate archive file.
The correct command is find /etc/myapp -print0 | cpio --null -pdmv /var/lib/myapp/backups.
-p: Engages pass-through mode.
--null: Used with find -print0, this ensures that filenames containing spaces or other special characters are handled safely.
-d: Creates any missing destination directories as needed.
-m: Preserves the original file modification times.
-v: Provides verbose output, listing the files as they are processed.
When cpio is run by the root user, it automatically preserves file ownership and permissions. In pass-through mode, it also correctly preserves hard links.
The other options are incorrect for the following reasons:
The command using cpio -ov is incorrect because the -o (copy-out) option creates an archive file instead of copying the files directly to the destination directory.
The command using cpio -id is incorrect because the -i (copy-in) option extracts files from an existing archive, which does not exist in this scenario.
The command using tar would also accomplish the file copy, but this question is focused on the usage of the cpio utility, as indicated by the other options and the tool's inclusion in the exam objectives for archiving.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the --null option in the cpio command?
Open an interactive chat with Bash
How does the -p flag in cpio differ from the -o and -i options?
Open an interactive chat with Bash
Why is cpio preferred over tar in this scenario?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access