A cpio archive is a stream of files and directories in a single archive, and often ends with a .cpio file extension. The archive has header information that allows for an application such as the GNU_cpio tool to extract the files and directories into a file system. The header of a cpio archive also contains information such as the file name, time stamp, owner and permissions.
If you wanted to archive an entire directory tree, the find command can provide the file list to cpio:
% find . -print -depth | cpio -ov > tree.cpio
Cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive. It reads the list of files to copy from the standard input; the directory into which it will copy them is given as a non-option argument.
- % find . -depth -print0 | cpio --null -pvd new-dir
To extract files from a cpio archive, pass the archive to cpio as its standard input.
cpio -id < cpiofile
The -i flag indicates that cpio is reading in the archive to extract files, and the -d flag tells cpio to construct directories as necessary. You can also use the -v flag to have file names listed as files are extracted.