Blame SOURCES/cpio.1

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