Archiving with cpio
cpio is another archiving format similar to tar
. It is used to store files and directories in a file with attributes such as permissions, ownership, and so on. But, it is not commonly used as much as tar
. However, cpio
is used in RPM package archives (which are used in distros such as Fedora), initramfs files for the Linux kernel which contain the kernel image, and so on. This recipe will give minimal usage examples of cpio
.
How to do it...
cpio
takes input filenames through stdin
and it writes the archive into stdout
. We have to redirect stdout
to a file to receive the output cpio
file as follows:
Create test files:
$ touch file1 file2 file3
We can archive the test files as follows:
$ echo file1 file2 file3 | cpio -ov > archive.cpio
In order to list files in a
cpio
archive use the following command:$ cpio -it < archive.cpio
In order to extract files from the
cpio
archive use:$ cpio -id < archive.cpio
How it works...
For the archiving command:
-o
specifies the output...