You want to archive every file under /etc with cpio, feeding it the list of names produced by find. Which command builds the archive?
LPIC-1 Exam 101-500, objective 103. GNU and Unix commands hard
Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.
Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
The options
Correct find /etc -depth -print | cpio -o -H newc > /backup/etc.cpio
Correct. -o is copy-out mode: cpio reads a list of path names on standard input and writes the archive to standard output. -H newc selects the portable SVR4 header format, which supports large inode numbers.
Not correct find /etc -depth -print | cpio -i > /backup/etc.cpio
Wrong direction. -i is copy-in mode: it reads an ARCHIVE on standard input and extracts members from it, so it would try to parse the list of names as archive data.
Not correct find /etc -depth -print | cpio -p /backup
Wrong. -p is pass-through mode, which copies the named files straight into the destination directory as files. No archive is produced.
Not correct cpio -t /etc > /backup/etc.cpio
Wrong. -t lists the table of contents of an archive read from standard input, and any operand is a pattern selecting members of that archive, not a directory to walk. With no archive on stdin nothing is built; the redirection only creates an empty file.
Why
cpio has exactly three modes and always works through the standard streams: -o copy-out builds an archive from names on stdin, -i copy-in extracts from an archive on stdin, and -p pass-through copies a tree to another directory. Unlike tar it does not walk directories itself, which is why it is always paired with find. That division is also why the initramfs, which is a cpio archive in newc format, is built with this pipeline.
Where this comes from
- Cited
- manual page cpio(1)
Practise this
Reading one question is not practice. The trainer will draw a short set from objective 103 and space the ones you get wrong.
More questions on this objective
- A user starts a new terminal window in a running graphical desktop session, which launches bash as an interactive shell that is NOT a login shell. Which file in the user's home directory does bash read in that case? machine-checked
- In bash, which history expansion re-runs the entire previous command line? machine-checked
- Which bash command prints the literal five characters $USER instead of the current user name? machine-checked
- You want /opt/bin searched for executables, after all the directories already in PATH, in the current bash session and in every command started from it. Which command does that? machine-checked
- There is a passwd manual page in section 1 (the command) and another in section 5 (the /etc/passwd file format). Which command opens the section 5 page? machine-checked
- Select the TWO true statements about shell variables and the environment in bash. machine-checked