cpio VS tar and cp
I see no reason to use cpio for any reason other than ripping opened RPM files, via disrpm or rpm2cpio, but there may be corner cases in which cpio is preferable to tar.
History and popularity
Both tar and cpio are competing archive formats that were introduced in Version 7 Unix in 1979 and then included in POSIX.1-1988, though only tar remained in the next standard, POSIX.1-20011.
Cpio's file format has changed several times and has not remained fully compatible between versions. For example, there is now an ASCII-encoded representation of binary file information data.
Tar is more universally known, has become more versatile over the years, and is more likely to be supported on a given system. Cpio is still used in a few areas, such as the Red Hat package format (RPM), though RPM v5 (which is admittedly obscure) uses xar instead of cpio.
Both live on most Unix-like systems, though tar is more common. Here are Debian's install stats:
#rank name inst vote old recent no-files (maintainer)
13 tar 189206 172133 3707 13298 68 (Bdale Garbee)
61 cpio 189028 71664 96346 20920 98 (Anibal Monsalve Salazar)
Modes
Copy-out: This is for archive creation, akin to tar -pc
Copy-in: This is for archive extraction, akin to tar -px
Pass-through: This is basically both of the above, akin to tar -pc … |tar -px
but in a single command (and therefore microscopically faster). It's similar to cp -pdr
, though both cpio and (especially) tar have more customizability. Also consider rsync -a
, which people often forget since it's more typically used across a network connection.
I have not compared their performance, but I expect they'll be quite similar in CPU, memory, and archive size (after compression).