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.

Practise LPIC-1 Exam 101-500

More questions on this objective

All questions on GNU and Unix commands

Practise LPIC-1 Exam 101-500