a8e481
.TH CPIO 1L \" -*- nroff -*-
a8e481
.SH NAME
a8e481
cpio \- copy files to and from archives
a8e481
.SH SYNOPSIS
a8e481
\&\fBCopy-out mode\fR
a8e481
.PP
a8e481
In copy-out mode, cpio copies files into an archive.  It reads a list
a8e481
of filenames, one per line, on the standard input, and writes the
a8e481
archive onto the standard output.  A typical way to generate the list
a8e481
of filenames is with the find command; you should give find the \-depth
a8e481
option to minimize problems with permissions on directories that are
a8e481
unreadable.  see \*(lqOptions\*(rq.
a8e481
.PP
a8e481
.B cpio
a8e481
{\-o|\-\-create} [\-0acvABLV] [\-C bytes] [\-H format]
a8e481
[\-M message] [\-O [[user@]host:]archive] [\-F [[user@]host:]archive]
a8e481
[\-\-file=[[user@]host:]archive] [\-\-format=format] [\-\-warning=FLAG]
a8e481
[\-\-message=message][\-\-null] [\-\-reset\-access\-time] [\-\-verbose]
a8e481
[\-\-dot] [\-\-append] [\-\-block\-size=blocks] [\-\-dereference]
a8e481
[\-\-io\-size=bytes] [\-\-rsh\-command=command]  [\-\-license] [\-\-usage]
a8e481
[\-\-help] [\-\-version]
a8e481
< name-list [> archive]
a8e481
.PP
a8e481
\&\fBCopy-in mode\fR
a8e481
.PP
a8e481
In copy-in mode, cpio copies files out of an archive or lists the
a8e481
archive contents.  It reads the archive from the standard input.  Any
a8e481
non-option command line arguments are shell globbing patterns; only
a8e481
files in the archive whose names match one or more of those patterns are
a8e481
copied from the archive.  Unlike in the shell, an initial `\fB.\fR' in a
a8e481
filename does match a wildcard at the start of a pattern, and a `\fB/\fR' in a
a8e481
filename can match wildcards.  If no patterns are given, all files are
a8e481
extracted.  see \*(lqOptions\*(rq.
a8e481
.PP
a8e481
.B cpio
a8e481
{\-i|\-\-extract} [\-bcdfmnrtsuvBSV] [\-C bytes] [\-E file] [\-H format]
a8e481
[\-M message] [\-R [user][:.][group]] [\-I [[user@]host:]archive]
a8e481
[\-F [[user@]host:]archive] [\-\-file=[[user@]host:]archive]
a8e481
[\-\-make-directories] [\-\-nonmatching] [\-\-preserve-modification-time]
a8e481
[\-\-numeric-uid-gid] [\-\-rename] [\-t|\-\-list] [\-\-swap-bytes] [\-\-swap]
a8e481
[\-\-dot] [\-\-warning=FLAG] [\-\-unconditional] [\-\-verbose]
a8e481
[\-\-block-size=blocks] [\-\-swap-halfwords] [\-\-io-size=bytes]
a8e481
[\-\-pattern-file=file] [\-\-format=format] [\-\-owner=[user][:.][group]]
a8e481
[\-\-no-preserve-owner] [\-\-message=message]
a8e481
[\-\-force\-local] [\-\-no\-absolute\-filenames] [\-\-absolute\-filenames]
a8e481
[\-\-sparse] [\-\-only\-verify\-crc] [\-\-to\-stdout] [\-\-quiet]
a8e481
[\-\-rsh-command=command] [\-\-license] [\-\-usage] [\-\-help]
a8e481
[\-\-version] [pattern...] [< archive]
a8e481
.PP
a8e481
\&\fBCopy-pass mode\fR
a8e481
.PP
a8e481
In copy-pass mode, cpio copies files from one directory tree to
a8e481
another, combining the copy-out and copy-in steps without actually
a8e481
using an archive.  It reads the list of files to copy from the standard
a8e481
input; the directory into which it will copy them is given as a
a8e481
non-option argument.  see \*(lqOptions\*(rq.
a8e481
.PP
a8e481
.B cpio
a8e481
{\-p|\-\-pass-through} [\-0adlmuvLV] [\-R [user][:.][group]]
a8e481
[\-\-null] [\-\-reset-access-time] [\-\-make-directories] [\-\-link] [\-\-quiet]
a8e481
[\-\-preserve-modification-time] [\-\-unconditional] [\-\-verbose] [\-\-dot]
a8e481
[\-\-warning=FLAG] [\-\-dereference] [\-\-owner=[user][:.][group]]
a8e481
[\-\-no-preserve-owner] [\-\-sparse]  [\-\-license] [\-\-usage] [\-\-help]
a8e481
[\-\-version] destination-directory < name-list
a8e481
.PP
a8e481
.SH DESCRIPTION
a8e481
GNU cpio is a tool for creating and extracting archives, or copying
a8e481
files from one place to another.  It handles a number of cpio formats as
a8e481
well as reading and writing tar files.
a8e481
.PP
a8e481
Following archive formats are supported: binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old
a8e481
ASCII, old tar, and POSIX.1 tar.  The tar format is provided for compatibility with the tar program. By
a8e481
default, cpio creates binary format archives, for compatibility with older cpio programs.  When extracting
a8e481
from archives, cpio automatically recognizes which kind of archive it is reading and can read archives created 
a8e481
on machines with a different byte-order.
a8e481
.PP
a8e481
.SH OPTIONS
a8e481
.TP
a8e481
`\fB\-0, \-\-null\fR'
a8e481
Read a list of filenames terminated by a null character, instead
a8e481
of a newline, so that files whose names contain newlines can be
a8e481
archived.  \s-1GNU\s0 find is one way to produce a list of
a8e481
null-terminated filenames.  This option may be used in copy-out
a8e481
and copy-pass modes.
a8e481
.TP
a8e481
`\fB\-a, \-\-reset\-access\-time\fR'
a8e481
Reset the access times of files after reading them, so that it
a8e481
does not look like they have just been read.
a8e481
.TP
a8e481
`\fB\-A, \-\-append\fR'
a8e481
Append to an existing archive.  Only works in copy-out mode.  The
a8e481
archive must be a disk file specified with the \-O or \-F (\-file)
a8e481
option.
a8e481
.TP
a8e481
`\fB\-b, \-\-swap\fR'
a8e481
Swap both halfwords of words and bytes of halfwords in the data.
a8e481
Equivalent to \-sS.  This option may be used in copy-in mode.  Use
a8e481
this option to convert 32\-bit integers between big-endian and
a8e481
little-endian machines.
a8e481
.TP
a8e481
`\fB\-B\fR'
a8e481
Set the I/O block size to 5120 bytes.  Initially the block size is
a8e481
512 bytes.
a8e481
.TP
a8e481
`\fB\-\-block\-size=BLOCK\-SIZE\fR'
a8e481
Set the I/O block size to BLOCK-SIZE * 512 bytes.
a8e481
.TP
a8e481
`\fB\-c\fR'
a8e481
Identical to \*(lq\-H newc\*(rq, use the new (\s-1SVR4\s0) portable format.
a8e481
If you wish the old portable (\s-1ASCII\s0) archive format, use \*(lq\-H odc\*(rq instead.
a8e481
.TP
a8e481
`\fB\-C \s-1IO\-SIZE\s0, \-\-io\-size=IO\-SIZE\fR'
a8e481
Set the I/O block size to IO-SIZE bytes.
a8e481
.TP
a8e481
`\fB\-d, \-\-make\-directories\fR'
a8e481
Create leading directories where needed.
a8e481
.TP
a8e481
`\fB\-\-device\-independent, \-\-reproducible\fR'
a8e481
Create reproducible archives.  This is equivalent to \fB\-\-ignore\-devno
a8e481
\-\-renumber\-inodes\fR.
a8e481
.TP
a8e481
`\fB\-E \s-1FILE\s0, \-\-pattern\-file=FILE\fR'
a8e481
Read additional patterns specifying filenames to extract or list
a8e481
from \s-1FILE\s0.  The lines of \s-1FILE\s0 are treated as if they had been
a8e481
non-option arguments to cpio.  This option is used in copy-in mode,
a8e481
.TP
a8e481
`\fB\-f, \-\-nonmatching\fR'
a8e481
Only copy files that do not match any of the given patterns.
a8e481
.TP
a8e481
`\fB\-F, \-\-file=archive\fR'
a8e481
Archive filename to use instead of standard input or output.  To
a8e481
use a tape drive on another machine as the archive, use a filename
a8e481
that starts with `\fB\s-1HOSTNAME:\s0\fR'.  The hostname can be preceded by a
a8e481
username and an `\fB@\fR' to access the remote tape drive as that user,
a8e481
if you have permission to do so (typically an entry in that user's
a8e481
`\fB~/.rhosts\fR' file).
a8e481
.TP
a8e481
`\fB\-\-force\-local\fR'
a8e481
With \-F, \-I, or \-O, take the archive file name to be a local file
a8e481
even if it contains a colon, which would ordinarily indicate a
a8e481
remote host name.
a8e481
.TP
a8e481
`\fB\-H \s-1FORMAT\s0, \-\-format=FORMAT\fR'
a8e481
Use archive format \s-1FORMAT\s0.  The valid formats are listed below;
a8e481
the same names are also recognized in all\-caps.  The default in
a8e481
copy-in mode is to automatically detect the archive format, and in
a8e481
copy-out mode is `\fBbin\fR'.
a8e481
.TP
a8e481
`bin'
a8e481
The obsolete binary format.
a8e481
.TP
a8e481
`odc'
a8e481
The old (\s-1POSIX\s0.1) portable format.
a8e481
.TP
a8e481
`newc'
a8e481
The new (\s-1SVR4\s0) portable format, which supports file systems
a8e481
having more than 65536 i\-nodes.
a8e481
.TP
a8e481
`crc'
a8e481
The new (\s-1SVR4\s0) portable format with a checksum (Sum32) added.
a8e481
.TP
a8e481
`tar'
a8e481
The old tar format.
a8e481
.TP
a8e481
`ustar'
a8e481
The \s-1POSIX\s0.1 tar format.  Also recognizes \s-1GNU\s0 tar archives,
a8e481
which are similar but not identical.
a8e481
.TP
a8e481
`hpbin'
a8e481
The obsolete binary format used by \s-1HPUX\s0's cpio (which stores
a8e481
device files differently).
a8e481
.TP
a8e481
`hpodc'
a8e481
The portable format used by \s-1HPUX\s0's cpio (which stores device
a8e481
files differently).
a8e481
.TP
a8e481
`\fB\-i, \-\-extract\fR'
a8e481
Run in copy-in mode.  see \*(lqCopy\-in mode\*(rq.
a8e481
.TP
a8e481
`\fB\-I archive\fR'
a8e481
Archive filename to use instead of standard input.  To use a tape
a8e481
drive on another machine as the archive, use a filename that
a8e481
starts with `\fB\s-1HOSTNAME:\s0\fR'.  The hostname can be preceded by a
a8e481
username and an `\fB@\fR' to access the remote tape drive as that user,
a8e481
if you have permission to do so (typically an entry in that user's
a8e481
`\fB~/.rhosts\fR' file).
a8e481
.TP
a8e481
`\fB\-\-ignore\-devno\fR'
a8e481
Store 0 in the device number field of each archive member, instead of the
a8e481
actual device number.
a8e481
.TP
a8e481
`\fB\-k\fR'
a8e481
Ignored; for compatibility with other versions of cpio.
a8e481
.TP
a8e481
`\fB\-l, \-\-link\fR'
a8e481
Link files instead of copying them, when possible.
a8e481
.TP
a8e481
`\fB\-L, \-\-dereference\fR'
a8e481
Copy the file that a symbolic link points to, rather than the
a8e481
symbolic link itself.
a8e481
.TP
a8e481
`\fB\-m, \-\-preserve\-modification\-time\fR'
a8e481
Retain previous file modification times when creating files.
a8e481
.TP
a8e481
`\fB\-M \s-1MESSAGE\s0, \-\-message=MESSAGE\fR'
a8e481
Print \s-1MESSAGE\s0 when the end of a volume of the backup media (such
a8e481
as a tape or a floppy disk) is reached, to prompt the user to
a8e481
insert a new volume.  If \s-1MESSAGE\s0 contains the string \*(lq%d\*(rq, it is
a8e481
replaced by the current volume number (starting at 1).
a8e481
.TP
a8e481
`\fB\-n, \-\-numeric\-uid\-gid\fR'
a8e481
Show numeric \s-1UID\s0 and \s-1GID\s0 instead of translating them into names
a8e481
when using the `\fB\-\-verbose option\fR'.
a8e481
.TP
a8e481
`\fB\-\-no\-absolute\-filenames\fR'
a8e481
Create all files relative to the current directory in copy-in
a8e481
mode, even if they have an absolute file name in the archive.
a8e481
.TP
a8e481
`\fB\-\-absolute\-filenames\fR' (default)
a8e481
Do not strip leading file name components that contain \*(lq..\*(rq
a8e481
and leading slashes from file names in copy-in mode
a8e481
.TP
a8e481
`\fB\-\-no\-preserve\-owner\fR'
a8e481
Do not change the ownership of the files; leave them owned by the
a8e481
user extracting them.  This is the default for non-root users, so
a8e481
that users on System V don't inadvertently give away files.  This
a8e481
option can be used in copy-in mode and copy-pass mode
a8e481
.TP
a8e481
`\fB\-o, \-\-create\fR'
a8e481
Run in copy-out mode.  see \*(lqCopy\-out mode\*(rq.
a8e481
.TP
a8e481
`\fB\-O archive\fR'
a8e481
Archive filename to use instead of standard output.  To use a tape
a8e481
drive on another machine as the archive, use a filename that
a8e481
starts with `\fB\s-1HOSTNAME:\s0\fR'.  The hostname can be preceded by a
a8e481
username and an `\fB@\fR' to access the remote tape drive as that user,
a8e481
if you have permission to do so (typically an entry in that user's
a8e481
`\fB~/.rhosts\fR' file).
a8e481
.TP
a8e481
`\fB\-\-only\-verify\-crc\fR'
a8e481
Verify the \s-1Sum32 checksum\s0's of each file in the archive, when reading a
a8e481
\s-1crc\s0 format archive. Don't actually extract the files.
a8e481
.TP
a8e481
`\fB\-p, \-\-pass\-through\fR'
a8e481
Run in copy-pass mode.  see \*(lqCopy\-pass mode\*(rq.
a8e481
.TP
a8e481
`\fB\-\-quiet\fR'
a8e481
Do not print the number of blocks copied.
a8e481
.TP
a8e481
`\fB\-r, \-\-rename\fR'
a8e481
Interactively rename files.
a8e481
.TP
a8e481
`\fB\-\-renumber\-inodes\fR'
a8e481
Renumber inodes when storing them in the archive.
a8e481
.TP
a8e481
`\fB\-R [user][:.][group], \-\-owner [user][:.][group]\fR'
a8e481
Set the ownership of all files created to the specified user and/or
a8e481
group in copy-out and copy-pass modes.  Either the user, the
a8e481
group, or both, must be present.  If the group is omitted but the
a8e481
\&\*(lq:\*(rq or \*(lq.\*(rq separator is given, use the given user's login group.
a8e481
Only the super-user can change files' ownership.
a8e481
.TP
a8e481
`\fB\-\-rsh\-command=COMMAND\fR'
a8e481
Notifies cpio that is should use \s-1COMMAND\s0 to communicate with remote
a8e481
devices.
a8e481
.TP
a8e481
`\fB\-s, \-\-swap\-bytes\fR'
a8e481
Swap the bytes of each halfword (pair of bytes) in the files.This
a8e481
option can be used in copy-in mode.
a8e481
.TP
a8e481
`\fB\-S, \-\-swap\-halfwords\fR'
a8e481
Swap the halfwords of each word (4 bytes) in the files.  This
a8e481
option may be used in copy-in mode.
a8e481
.TP
a8e481
`\fB\-\-sparse\fR'
a8e481
Write files with large blocks of zeros as sparse files.  This
a8e481
option is used in copy-in and copy-pass modes.
a8e481
.TP
a8e481
`\fB\-t, \-\-list\fR'
a8e481
Print a table of contents of the input.
a8e481
.TP
a8e481
`\fB\-\-to\-stdout\fR'
a8e481
Extract files to standard output.  This option may be used in
a8e481
copy-in mode.
a8e481
.TP
a8e481
`\fB\-u, \-\-unconditional\fR'
a8e481
Replace all files, without asking whether to replace existing
a8e481
newer files with older files.
a8e481
.TP
a8e481
`\fB\-v, \-\-verbose\fR'
a8e481
List the files processed, or with `\fB\-t\fR', give an `\fBls \-l\fR' style
a8e481
table of contents listing.  In a verbose table of contents of a
a8e481
ustar archive, user and group names in the archive that do not
a8e481
exist on the local system are replaced by the names that
a8e481
correspond locally to the numeric \s-1UID\s0 and \s-1GID\s0 stored in the
a8e481
archive.
a8e481
.TP
a8e481
`\fB\-V, \-\-dot\fR'
a8e481
Print a `\fB.\fR' for each file processed.
a8e481
.TP
a8e481
`\fB\-W, \-\-warning\fR'
a8e481
Control warning display. Currently FLAG is one of 'none', 'truncate', 'all'. Multiple options accumulate.
a8e481
.TP
a8e481
`\fB\-\-license\fR'
a8e481
Print license and exit.
a8e481
.TP
a8e481
`\fB?, \-\-help\fR'
a8e481
Give a help page similar to this manpage.
a8e481
.TP
a8e481
`\fB\-\-usage\fR'
a8e481
Give a short usage message.
a8e481
.TP
a8e481
`\fB\-\-version\fR'
a8e481
Print the cpio program version number and exit.
a8e481
a8e481
.PP
a8e481
.SH EXAMPLES
a8e481
When creating an archive, cpio takes the list of files to be
a8e481
processed from the standard input, and then sends the archive to the
a8e481
standard output, or to the device defined by the `\fB\-F\fR' option.
a8e481
Usually find or ls is used to provide this list to
a8e481
the standard input.  In the following example you can see the
a8e481
possibilities for archiving the contents of a single directory.
a8e481
.PP
a8e481
.B % ls | cpio \-ov > directory.cpio
a8e481
.PP
a8e481
The `\fB\-o\fR' option creates the archive, and the `\fB\-v\fR' option prints the
a8e481
names of the files archived as they are added.  Notice that the options
a8e481
can be put together after a single `\fB\-\fR' or can be placed separately on
a8e481
the command line.  The `\fB>\fR' redirects the cpio output to the file
a8e481
`\fBdirectory.cpio\fR'.
a8e481
.PP
a8e481
If you wanted to archive an entire directory tree, the find command
a8e481
can provide the file list to cpio:
a8e481
.PP
a8e481
.B % find . \-print \-depth | cpio \-ov > tree.cpio
a8e481
.PP
a8e481
This will take all the files in the current directory, the
a8e481
directories below and place them in the archive tree.cpio.  Again the
a8e481
`\fB\-o\fR' creates an archive, and the `\fB\-v\fR' option shows you the name of the
a8e481
files as they are archived.  see \*(lqCopy\-out mode\*(rq.  Using the `\fB.\fR' in
a8e481
the find statement will give you more flexibility when doing restores,
a8e481
as it will save file names with a relative path vice a hard wired,
a8e481
absolute path.  The `\fB\-depth\fR' option forces `\fBfind\fR' to print of the
a8e481
entries in a directory before printing the directory itself.  This
a8e481
limits the effects of restrictive directory permissions by printing the
a8e481
directory entries in a directory before the directory name itself.
a8e481
.PP
a8e481
Extracting an archive requires a bit more thought because cpio will
a8e481
not create directories by default.  Another characteristic, is it will
a8e481
not overwrite existing files unless you tell it to.
a8e481
.PP
a8e481
.B % cpio \-iv < directory.cpio
a8e481
.PP
a8e481
This will retrieve the files archived in the file directory.cpio and
a8e481
place them in the present directory.  The `\fB\-i\fR' option extracts the
a8e481
archive and the `\fB\-v\fR' shows the file names as they are extracted.  If
a8e481
you are dealing with an archived directory tree, you need to use the
a8e481
`\fB\-d\fR' option to create directories as necessary, something like:
a8e481
.PP
a8e481
.B % cpio \-idv < tree.cpio
a8e481
.PP
a8e481
This will take the contents of the archive tree.cpio and extract it
a8e481
to the current directory.  If you try to extract the files on top of
a8e481
files of the same name that already exist (and have the same or later
a8e481
modification time) cpio will not extract the file unless told to do so
a8e481
by the \-u option.  see \*(lqCopy\-in mode\*(rq.
a8e481
.PP
a8e481
In copy-pass mode, cpio copies files from one directory tree to
a8e481
another, combining the copy-out and copy-in steps without actually
a8e481
using an archive.  It reads the list of files to copy from the standard
a8e481
input; the directory into which it will copy them is given as a
a8e481
non-option argument.  see \*(lqCopy\-pass mode\*(rq.
a8e481
.PP
a8e481
.B % find . \-depth \-print0 | cpio \-\-null \-pvd new-dir
a8e481
.PP
a8e481
The example shows copying the files of the present directory, and
a8e481
sub-directories to a new directory called new\-dir.  Some new options are
a8e481
the `\fB\-print0\fR' available with \s-1GNU\s0 find, combined with the `\fB\-\-null\fR'
a8e481
option of cpio.  These two options act together to send file names
a8e481
between find and cpio, even if special characters are embedded in the
a8e481
file names.  Another is `\fB\-p\fR', which tells cpio to pass the files it
a8e481
finds to the directory `\fBnew-dir\fR'.
a8e481
a8e481
.SH BUGS
a8e481
The GNU folks, in general, abhor man pages, and create info documents instead.  The maintainer of 
a8e481
.B cpio 
a8e481
falls
a8e481
into  this  category.  Thus this man page may not be complete, nor current, and was included in the Red Hat
a8e481
CVS tree because man is a great tool :).
a8e481
.PP
a8e481
.SH REPORTING BUGS
a8e481
Please report bugs via https://bugzilla.redhat.com.
a8e481
.PP
a8e481
.SH SEE ALSO
a8e481
The full documentation for
a8e481
.B cpio
a8e481
is maintained as a Texinfo manual.  If the
a8e481
.B info
a8e481
and
a8e481
.B cpio
a8e481
programs are properly installed at your site, the command
a8e481
.IP
a8e481
.B info cpio
a8e481
.PP
a8e481
should give you access to the complete manual. The online copy of the documentation 
a8e481
is available at the following address:
a8e481
.PP
a8e481
http://www.gnu.org/software/cpio/manual
a8e481