This lesson covers the cpio utility for creating and extracting archives in UNIX, highlighting its usage and command options.
In this lesson, we’ll dive into the cpio utility, a classic UNIX tool for creating and extracting archives. Whether you’re bundling application files or unpacking backup archives, cpio offers a straightforward, scriptable interface.
CPIO stands for Copy In, Copy Out. Unlike tar, which handles device archives too, cpio reads and writes archives strictly via standard input and standard output. You typically pipe a file list into cpio to create an archive, or feed an archive into cpio to extract its contents.
Unpack the contents of archive.cpio, creating directories as needed:
Copy
Ask AI
cpio -id < archive.cpio
Breakdown:
cpio -i reads an archive from stdin.
-d ensures that all required directories are created.
< archive.cpio feeds the archive into cpio.
By default, cpio preserves file ownership and permissions. Run as root only if you trust the archive contents to avoid overwriting critical system files.