The cpio application is another archiving format similar to tar. It is used to store files and directories in an archive with attributes such as permissions and ownership. The cpio format is used in RPM package archives (which are used in distros such as Fedora), initramfs files for the Linux kernel that contain the kernel image, and so on. This recipe will give simple examples of cpio.
Archiving with cpio
How to do it...
The cpio application accepts input filenames via stdin and it writes the archive to stdout. We have to redirect stdout to a file to save the cpio output:
- Create test files:
$ touch file1 file2 file3
- Archive the test files:
$ ls file* | cpio -ov > archive.cpio
- List files in a cpio archive:
$ cpio -it < archive...