Archiving with cpio
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.
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
cpioarchive:
$ cpio -it < archive.cpio- Extract files from the
cpioarchive:
$ cpio -id < archive.cpioHow it works...
For the archiving command, the options are as follows:
-o: This specifies the output-v: This is used for printing a list of files archived
Note
Using cpio, we can also archive using files...