Blame SOURCES/cpio.1

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