cpio: The cpio command is one of standard Unix backup utilities. It stands for "copy in/out." It is much less well known and more rarely used Unix utility in comparison with tar.
cpio works as a filter accepting standard input and writing to standard output. cpio allows you to copy files into and out of a cpio archive.
The input to cpio is the list of files. That means that results of ls or find command can be piped directly into cpio. You can specify a device or file to which cpio will send its output, rather than sending it to stdout.
Cpio uses two key options: -o (output) and –I (input) wither of which (but not both) must be there in the command line.
Examples:
To create a *.cpio file : We can create *.cpio files containing files and directory with the help of cpio command.
Syntax:
cpio -ov < name-list > archive
Here -ov is used as -o create the new archive and -v list the files processed.
tar: For creating a disk archive that contains a group of files or an entire directory structure, we need to use tar. The tar command was originally used to write files to a tape device for archiving. The tar program is used to create, modify, and access files archived in the tar format. "tar" stands for tape archive.
Syntax: tar function [options] object1 object2 ...
Example: tar -cvf test.tar test1 test2
To create an archive, we need to specify the name of the archive (with –f), the copy or write operation (-c) and the filenames as arguments. The use of –v (verbose) option is to display the progress while tar works. The above command creates the file archive test.tar from the two uncompressed files test1 and test2.