Blame SOURCES/cpio.1

ca6c51
.\" DO NOT MODIFY THIS FILE!  It was (partly) generated by help2man from
ca6c51
.\" cpio --help/cpio --version output and partly patched by downstream
ca6c51
.\" package maintainers.
ca6c51
.TH CPIO 1L \" -*- nroff -*-
ca6c51
.SH NAME
ca6c51
cpio \- copy files to and from archives
ca6c51
.SH __WARNING__
ca6c51
.PP
ca6c51
The cpio utility is considered LEGACY based on POSIX specification.  Users are
ca6c51
encouraged to use other archiving tools for archive creation.
ca6c51
ca6c51
If you decided to use cpio, you should almost always force cpio to use the
ca6c51
ustar format in copy-out mode by the -H option (cpio -o -H ustar).  This is
ca6c51
because the ustar format is well defined in POSIX specification and thus
ca6c51
readable by wide range of other archiving tools (including tar e.g.).
ca6c51
ca6c51
By default, GNU cpio uses (for historical reasons) the very old binary format
ca6c51
('bin') which has significant problems nowadays, e.g. with storing big inode
ca6c51
numbers (see the Red Hat bug #952313).
ca6c51
ca6c51
Note also that these days the modern 'pax' archive format should be considered
ca6c51
as the default -- but this format is not implemented in GNU cpio.  You should,
ca6c51
again, consider using other archivers (e.g. 'tar --format=pax').
ca6c51
ca6c51
.SH SYNOPSIS
ca6c51
\&\fBCopy-out mode\fR
ca6c51
.PP
ca6c51
In copy-out mode, cpio copies files into an archive.  It reads a list
ca6c51
of filenames, one per line, on the standard input, and writes the
ca6c51
archive onto the standard output.  A typical way to generate the list
ca6c51
of filenames is with the find command; you should give find the \-depth
ca6c51
option to minimize problems with permissions on directories that are
ca6c51
unreadable.  see \*(lqOptions\*(rq.
ca6c51
.PP
ca6c51
.B cpio
ca6c51
{\-o|\-\-create} [\-0acvABLV] [\-C bytes] [\-H format] [\-D DIR]
ca6c51
[\-M message] [\-O [[user@]host:]archive] [\-F [[user@]host:]archive]
ca6c51
[\-\-file=[[user@]host:]archive] [\-\-format=format] [\-\-warning=FLAG]
ca6c51
[\-\-message=message][\-\-null] [\-\-reset\-access\-time] [\-\-verbose]
ca6c51
[\-\-dot] [\-\-append] [\-\-block\-size=blocks] [\-\-dereference]
ca6c51
[\-\-io\-size=bytes] [\-\-rsh\-command=command]  [\-\-license] [\-\-usage]
ca6c51
[\-\-help] [\-\-version]
ca6c51
< name-list [> archive]
ca6c51
.PP
ca6c51
\&\fBCopy-in mode\fR
ca6c51
.PP
ca6c51
In copy-in mode, cpio copies files out of an archive or lists the
ca6c51
archive contents.  It reads the archive from the standard input.  Any
ca6c51
non-option command line arguments are shell globbing patterns; only
ca6c51
files in the archive whose names match one or more of those patterns are
ca6c51
copied from the archive.  Unlike in the shell, an initial `\fB.\fR' in a
ca6c51
filename does match a wildcard at the start of a pattern, and a `\fB/\fR' in a
ca6c51
filename can match wildcards.  If no patterns are given, all files are
ca6c51
extracted.  see \*(lqOptions\*(rq.
ca6c51
.PP
ca6c51
.B cpio
ca6c51
{\-i|\-\-extract} [\-bcdfmnrtsuvBSV] [\-C bytes] [\-E file] [\-H format]
ca6c51
[\-D DIR]
ca6c51
[\-M message] [\-R [user][:.][group]] [\-I [[user@]host:]archive]
ca6c51
[\-F [[user@]host:]archive] [\-\-file=[[user@]host:]archive]
ca6c51
[\-\-make-directories] [\-\-nonmatching] [\-\-preserve-modification-time]
ca6c51
[\-\-numeric-uid-gid] [\-\-rename] [\-t|\-\-list] [\-\-swap-bytes] [\-\-swap]
ca6c51
[\-\-dot] [\-\-warning=FLAG] [\-\-unconditional] [\-\-verbose]
ca6c51
[\-\-block-size=blocks] [\-\-swap-halfwords] [\-\-io-size=bytes]
ca6c51
[\-\-pattern-file=file] [\-\-format=format] [\-\-owner=[user][:.][group]]
ca6c51
[\-\-no-preserve-owner] [\-\-message=message]
ca6c51
[\-\-force\-local] [\-\-no\-absolute\-filenames] [\-\-absolute\-filenames]
ca6c51
[\-\-sparse] [\-\-only\-verify\-crc] [\-\-to\-stdout] [\-\-quiet]
ca6c51
[\-\-ignore\-devno] [\-\-renumber\-inodes] [\-\-device\-independent]
ca6c51
[\-\-reproducible]
ca6c51
[\-\-rsh-command=command] [\-\-license] [\-\-usage] [\-\-help]
ca6c51
[\-\-version] [pattern...] [< archive]
ca6c51
.PP
ca6c51
\&\fBCopy-pass mode\fR
ca6c51
.PP
ca6c51
In copy-pass mode, cpio copies files from one directory tree to
ca6c51
another, combining the copy-out and copy-in steps without actually
ca6c51
using an archive.  It reads the list of files to copy from the standard
ca6c51
input; the directory into which it will copy them is given as a
ca6c51
non-option argument.  see \*(lqOptions\*(rq.
ca6c51
.PP
ca6c51
.B cpio
ca6c51
{\-p|\-\-pass-through} [\-0adlmuvLV] [\-R [user][:.][group]] [\-D DIR]
ca6c51
[\-\-null] [\-\-reset-access-time] [\-\-make-directories] [\-\-link] [\-\-quiet]
ca6c51
[\-\-preserve-modification-time] [\-\-unconditional] [\-\-verbose] [\-\-dot]
ca6c51
[\-\-warning=FLAG] [\-\-dereference] [\-\-owner=[user][:.][group]]
ca6c51
[\-\-no-preserve-owner] [\-\-sparse]  [\-\-license] [\-\-usage] [\-\-help]
ca6c51
[\-\-version] destination-directory < name-list
ca6c51
.PP
ca6c51
.SH DESCRIPTION
ca6c51
GNU cpio is a tool for creating and extracting archives, or copying
ca6c51
files from one place to another.  It handles a number of cpio formats as
ca6c51
well as reading and writing tar files.
ca6c51
.PP
ca6c51
Following archive formats are supported: binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old
ca6c51
ASCII, old tar, and POSIX.1 tar.  The tar format is provided for compatibility with the tar program. By
ca6c51
default, cpio creates binary format archives, for compatibility with older cpio programs.  When extracting
ca6c51
from archives, cpio automatically recognizes which kind of archive it is reading and can read archives created 
ca6c51
on machines with a different byte-order.
ca6c51
.PP
ca6c51
.SS "Main operation mode:"
ca6c51
.TP
ca6c51
\fB\-i\fR, \fB\-\-extract\fR
ca6c51
Extract files from an archive (run in copy\-in
ca6c51
mode)
ca6c51
.TP
ca6c51
\fB\-o\fR, \fB\-\-create\fR
ca6c51
Create the archive (run in copy\-out mode)
ca6c51
.TP
ca6c51
\fB\-p\fR, \fB\-\-pass\-through\fR
ca6c51
Run in copy\-pass mode
ca6c51
.TP
ca6c51
\fB\-t\fR, \fB\-\-list\fR
ca6c51
Print a table of contents of the input
ca6c51
.SS "Operation modifiers valid in any mode:"
ca6c51
.TP
ca6c51
\fB\-\-block\-size\fR=\fI\,BLOCK\-SIZE\/\fR
ca6c51
Set the I/O block size to BLOCK\-SIZE * 512
ca6c51
bytes
ca6c51
.TP
ca6c51
\fB\-B\fR
ca6c51
Set the I/O block size to 5120 bytes.
ca6c51
Initially the block size is 512 bytes.
ca6c51
.TP
ca6c51
\fB\-c\fR
ca6c51
Identical to "\-H newc", use the new (SVR4)
ca6c51
portable format. If you wish the old portable
ca6c51
(ASCII) archive format, use "\-H odc" instead.
ca6c51
.TP
ca6c51
\fB\-C\fR, \fB\-\-io\-size\fR=\fI\,NUMBER\/\fR
ca6c51
Set the I/O block size to the given NUMBER of
ca6c51
bytes
ca6c51
.TP
ca6c51
\fB\-D\fR, \fB\-\-directory\fR=\fI\,DIR\/\fR
ca6c51
Change to directory DIR
ca6c51
.TP
ca6c51
\fB\-\-force\-local\fR
ca6c51
With \-F, \-I, or \-O, take the archive file name to be a local file
ca6c51
even if it contains a colon, which would ordinarily indicate a
ca6c51
remote host name.
ca6c51
.TP
ca6c51
\fB\-H\fR, \fB\-\-format\fR=\fI\,FORMAT\/\fR
ca6c51
Use given archive FORMAT.
ca6c51
The valid formats are listed below; the same names are also recognized in
ca6c51
all\-caps.  The default in copy-in mode is to automatically detect the archive
ca6c51
format, and in copy-out mode is `\fBbin\fR'.
ca6c51
.TP
ca6c51
`bin'
ca6c51
The obsolete binary format.
ca6c51
.TP
ca6c51
`odc'
ca6c51
The old (\s-1POSIX\s0.1) portable format.
ca6c51
.TP
ca6c51
`newc'
ca6c51
The new (\s-1SVR4\s0) portable format, which supports file systems
ca6c51
having more than 65536 i\-nodes.
ca6c51
.TP
ca6c51
`crc'
ca6c51
The new (\s-1SVR4\s0) portable format with a checksum (Sum32) added.
ca6c51
.TP
ca6c51
`tar'
ca6c51
The old tar format.
ca6c51
.TP
ca6c51
`ustar'
ca6c51
The \s-1POSIX\s0.1 tar format.  Also recognizes \s-1GNU\s0 tar archives,
ca6c51
which are similar but not identical.
ca6c51
.TP
ca6c51
`hpbin'
ca6c51
The obsolete binary format used by \s-1HPUX\s0's cpio (which stores
ca6c51
device files differently).
ca6c51
.TP
ca6c51
`hpodc'
ca6c51
The portable format used by \s-1HPUX\s0's cpio (which stores device
ca6c51
files differently).
ca6c51
.TP
ca6c51
\fB\-\-quiet\fR
ca6c51
Do not print the number of blocks copied
ca6c51
.TP
ca6c51
\fB\-R\fR, \fB\-\-owner\fR=\fI\,[USER][\/\fR:.][GROUP]
ca6c51
Set the ownership of all files created to the
ca6c51
specified USER and/or GROUP.
ca6c51
Either the user, the group, or both, must be present.  If the group is omitted
ca6c51
but the \&\*(lq:\*(rq or \*(lq.\*(rq separator is given, use the given user's
ca6c51
login group.  Only the super-user can change files' ownership in copy\-in mode.
ca6c51
.TP
ca6c51
\fB\-v\fR, \fB\-\-verbose\fR
ca6c51
List the files processed, or with `\fB\-t\fR', give an `\fBls \-l\fR' style
ca6c51
table of contents listing.  In a verbose table of contents of a
ca6c51
ustar archive, user and group names in the archive that do not
ca6c51
exist on the local system are replaced by the names that
ca6c51
correspond locally to the numeric \s-1UID\s0 and \s-1GID\s0 stored in the
ca6c51
archive.
ca6c51
.TP
ca6c51
\fB\-V\fR, \fB\-\-dot\fR
ca6c51
Print a "." for each file processed
ca6c51
.TP
ca6c51
\fB\-W\fR, \fB\-\-warning\fR=\fI\,FLAG\/\fR
ca6c51
Control warning display. Currently FLAG is one of
ca6c51
\&'none', 'truncate', 'all'. Multiple options
ca6c51
accumulate.
ca6c51
.SS "Operation modifiers valid in copy-in and copy-out modes:"
ca6c51
.TP
ca6c51
\fB\-F\fR, \fB\-\-file\fR=\fI\,[[USER\/\fR@]HOST:]FILE\-NAME
ca6c51
Use this FILE\-NAME instead of standard input or
ca6c51
output. Optional USER and HOST specify the user
ca6c51
and host names in case of a remote archive
ca6c51
.TP
ca6c51
\fB\-M\fR, \fB\-\-message\fR=\fI\,STRING\/\fR
ca6c51
Print \s-1STRING\s0 when the end of a volume of the backup media (such
ca6c51
as a tape or a floppy disk) is reached, to prompt the user to
ca6c51
insert a new volume.  If \s-1STRING\s0 contains the string \*(lq%d\*(rq, it is
ca6c51
replaced by the current volume number (starting at 1).
ca6c51
.TP
ca6c51
\fB\-\-rsh\-command\fR=\fI\,COMMAND\/\fR
ca6c51
Use COMMAND instead of rsh
ca6c51
(typically /usr/bin/ssh)
ca6c51
.SS "Operation modifiers valid only in copy-in mode:"
ca6c51
.TP
ca6c51
\fB\-b\fR, \fB\-\-swap\fR
ca6c51
Swap both halfwords of words and bytes of
ca6c51
halfwords in the data. Equivalent to \fB\-sS\fR
ca6c51
Use this option to convert 32\-bit integers between big-endian and little-endian
ca6c51
machines.
ca6c51
.TP
ca6c51
\fB\-f\fR, \fB\-\-nonmatching\fR
ca6c51
Only copy files that do not match any of the given
ca6c51
patterns
ca6c51
.TP
ca6c51
\fB\-I\fR [[USER@]HOST:]FILE\-NAME
ca6c51
Archive filename to use instead of standard input.
ca6c51
Optional USER and HOST specify the user and host
ca6c51
names in case of a remote archive
ca6c51
.TP
ca6c51
\fB\-n\fR, \fB\-\-numeric\-uid\-gid\fR
ca6c51
In the verbose table of contents listing, show
ca6c51
numeric UID and GID
ca6c51
.TP
ca6c51
\fB\-r\fR, \fB\-\-rename\fR
ca6c51
Interactively rename files
ca6c51
.TP
ca6c51
\fB\-s\fR, \fB\-\-swap\-bytes\fR
ca6c51
Swap the bytes of each halfword in the files
ca6c51
.TP
ca6c51
\fB\-S\fR, \fB\-\-swap\-halfwords\fR
ca6c51
Swap the halfwords of each word (4 bytes) in the
ca6c51
files
ca6c51
.TP
ca6c51
\fB\-\-to\-stdout\fR
ca6c51
Extract files to standard output
ca6c51
.TP
ca6c51
\fB\-E\fR, \fB\-\-pattern\-file\fR=\fI\,FILE\/\fR
ca6c51
Read additional patterns specifying filenames to
ca6c51
extract or list from FILE
ca6c51
.TP
ca6c51
\fB\-\-only\-verify\-crc\fR
ca6c51
When reading a CRC format archive, only verify the
ca6c51
checksum of each file in the archive, don't
ca6c51
actually extract the files
ca6c51
.SS "Operation modifiers valid only in copy-out mode:"
ca6c51
.TP
ca6c51
\fB\-A\fR, \fB\-\-append\fR
ca6c51
Append to an existing archive.
ca6c51
The archive must be a disk file specified with the \-O or \-F (\-file) option.
ca6c51
.TP
ca6c51
\fB\-\-device\-independent\fR, \fB\-\-reproducible\fR
ca6c51
Create device\-independent (reproducible) archives
ca6c51
.TP
ca6c51
\fB\-\-ignore\-devno\fR
ca6c51
Don't store device numbers
ca6c51
.TP
ca6c51
\fB\-O\fR [[USER@]HOST:]FILE\-NAME
ca6c51
Archive filename to use instead of standard
ca6c51
output. Optional USER and HOST specify the user
ca6c51
and host names in case of a remote archive
ca6c51
.TP
ca6c51
\fB\-\-renumber\-inodes\fR
ca6c51
Renumber inodes
ca6c51
.SS "Operation modifiers valid only in copy-pass mode:"
ca6c51
.TP
ca6c51
\fB\-l\fR, \fB\-\-link\fR
ca6c51
Link files instead of copying them, when
ca6c51
possible
ca6c51
.SS "Operation modifiers valid in copy-in and copy-out modes:"
ca6c51
.TP
ca6c51
\fB\-\-absolute\-filenames\fR
ca6c51
Do not strip file system prefix components from
ca6c51
the file names
ca6c51
.TP
ca6c51
\fB\-\-no\-absolute\-filenames\fR
ca6c51
Create all files relative to the current
ca6c51
directory
ca6c51
.SS "Operation modifiers valid in copy-out and copy-pass modes:"
ca6c51
.TP
ca6c51
\fB\-0\fR, \fB\-\-null\fR
ca6c51
Filenames in the list are delimited by null
ca6c51
characters instead of newlines, so that files whose names contain newlines can
ca6c51
be archived.  \s-1GNU\s0 find is one way to produce a list of null-terminated
ca6c51
filenames.
ca6c51
.TP
ca6c51
\fB\-a\fR, \fB\-\-reset\-access\-time\fR
ca6c51
Reset the access times of files after reading them, so that it
ca6c51
does not look like they have just been read.
ca6c51
.TP
ca6c51
\fB\-L\fR, \fB\-\-dereference\fR
ca6c51
Dereference  symbolic  links  (copy  the files
ca6c51
that they point to instead of copying the links).
ca6c51
.SS "Operation modifiers valid in copy-in and copy-pass modes:"
ca6c51
.TP
ca6c51
\fB\-d\fR, \fB\-\-make\-directories\fR
ca6c51
Create leading directories where needed
ca6c51
.TP
ca6c51
\fB\-m\fR, \fB\-\-preserve\-modification\-time\fR
ca6c51
Retain previous file modification times when
ca6c51
creating files
ca6c51
.TP
ca6c51
\fB\-\-no\-preserve\-owner\fR
ca6c51
Do not change the ownership of the files; leave them owned by the
ca6c51
user extracting them.  This is the default for non-root users, so
ca6c51
that users on System V don't inadvertently give away files.  This
ca6c51
option can be used in copy-in mode and copy-pass mode
ca6c51
.TP
ca6c51
\fB\-\-sparse\fR
ca6c51
Write files with large blocks of zeros as sparse
ca6c51
files
ca6c51
.TP
ca6c51
\fB\-u\fR, \fB\-\-unconditional\fR
ca6c51
Replace all files unconditionally
ca6c51
.TP
ca6c51
\-?, \fB\-\-help\fR
ca6c51
give this help list
ca6c51
.TP
ca6c51
\fB\-\-usage\fR
ca6c51
give a short usage message
ca6c51
.TP
ca6c51
\fB\-\-version\fR
ca6c51
print program version
ca6c51
.PP
ca6c51
Mandatory or optional arguments to long options are also mandatory or optional
ca6c51
for any corresponding short options.
ca6c51
ca6c51
.PP
ca6c51
.SH EXAMPLES
ca6c51
When creating an archive, cpio takes the list of files to be
ca6c51
processed from the standard input, and then sends the archive to the
ca6c51
standard output, or to the device defined by the `\fB\-F\fR' option.
ca6c51
Usually find or ls is used to provide this list to
ca6c51
the standard input.  In the following example you can see the
ca6c51
possibilities for archiving the contents of a single directory.
ca6c51
.PP
ca6c51
.B % ls | cpio \-ov > directory.cpio
ca6c51
.PP
ca6c51
The `\fB\-o\fR' option creates the archive, and the `\fB\-v\fR' option prints the
ca6c51
names of the files archived as they are added.  Notice that the options
ca6c51
can be put together after a single `\fB\-\fR' or can be placed separately on
ca6c51
the command line.  The `\fB>\fR' redirects the cpio output to the file
ca6c51
`\fBdirectory.cpio\fR'.
ca6c51
.PP
ca6c51
If you wanted to archive an entire directory tree, the find command
ca6c51
can provide the file list to cpio:
ca6c51
.PP
ca6c51
.B % find . \-print \-depth | cpio \-ov > tree.cpio
ca6c51
.PP
ca6c51
This will take all the files in the current directory, the
ca6c51
directories below and place them in the archive tree.cpio.  Again the
ca6c51
`\fB\-o\fR' creates an archive, and the `\fB\-v\fR' option shows you the name of the
ca6c51
files as they are archived.  see \*(lqCopy\-out mode\*(rq.  Using the `\fB.\fR' in
ca6c51
the find statement will give you more flexibility when doing restores,
ca6c51
as it will save file names with a relative path vice a hard wired,
ca6c51
absolute path.  The `\fB\-depth\fR' option forces `\fBfind\fR' to print of the
ca6c51
entries in a directory before printing the directory itself.  This
ca6c51
limits the effects of restrictive directory permissions by printing the
ca6c51
directory entries in a directory before the directory name itself.
ca6c51
.PP
ca6c51
Extracting an archive requires a bit more thought because cpio will
ca6c51
not create directories by default.  Another characteristic, is it will
ca6c51
not overwrite existing files unless you tell it to.
ca6c51
.PP
ca6c51
.B % cpio \-iv < directory.cpio
ca6c51
.PP
ca6c51
This will retrieve the files archived in the file directory.cpio and
ca6c51
place them in the present directory.  The `\fB\-i\fR' option extracts the
ca6c51
archive and the `\fB\-v\fR' shows the file names as they are extracted.  If
ca6c51
you are dealing with an archived directory tree, you need to use the
ca6c51
`\fB\-d\fR' option to create directories as necessary, something like:
ca6c51
.PP
ca6c51
.B % cpio \-idv < tree.cpio
ca6c51
.PP
ca6c51
This will take the contents of the archive tree.cpio and extract it
ca6c51
to the current directory.  If you try to extract the files on top of
ca6c51
files of the same name that already exist (and have the same or later
ca6c51
modification time) cpio will not extract the file unless told to do so
ca6c51
by the \-u option.  see \*(lqCopy\-in mode\*(rq.
ca6c51
.PP
ca6c51
In copy-pass mode, cpio copies files from one directory tree to
ca6c51
another, combining the copy-out and copy-in steps without actually
ca6c51
using an archive.  It reads the list of files to copy from the standard
ca6c51
input; the directory into which it will copy them is given as a
ca6c51
non-option argument.  see \*(lqCopy\-pass mode\*(rq.
ca6c51
.PP
ca6c51
.B % find . \-depth \-print0 | cpio \-\-null \-pvd new-dir
ca6c51
.PP
ca6c51
The example shows copying the files of the present directory, and
ca6c51
sub-directories to a new directory called new\-dir.  Some new options are
ca6c51
the `\fB\-print0\fR' available with \s-1GNU\s0 find, combined with the `\fB\-\-null\fR'
ca6c51
option of cpio.  These two options act together to send file names
ca6c51
between find and cpio, even if special characters are embedded in the
ca6c51
file names.  Another is `\fB\-p\fR', which tells cpio to pass the files it
ca6c51
finds to the directory `\fBnew-dir\fR'.
ca6c51
ca6c51
ca6c51
.SH AUTHOR
ca6c51
Written by Phil Nelson, David MacKenzie, John Oleynick,
ca6c51
and Sergey Poznyakoff.
ca6c51
.SH "REPORTING BUGS"
ca6c51
Report bugs to <bug\-cpio@gnu.org>.
ca6c51
Report bugs in this manual page via https://bugzilla.redhat.com.
ca6c51
.SH COPYRIGHT
ca6c51
Copyright \(co 2015 Free Software Foundation, Inc.
ca6c51
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
ca6c51
.br
ca6c51
This is free software: you are free to change and redistribute it.
ca6c51
There is NO WARRANTY, to the extent permitted by law.
ca6c51
.SH "SEE ALSO"
ca6c51
The full documentation for
ca6c51
.B cpio
ca6c51
is maintained as a Texinfo manual.  If the
ca6c51
.B info
ca6c51
and
ca6c51
.B cpio
ca6c51
programs are properly installed at your site, the command
ca6c51
.IP
ca6c51
.B info cpio
ca6c51
.PP
ca6c51
should give you access to the complete manual.
ca6c51
ca6c51
The online copy of the documentation is available at the following address:
ca6c51
.PP
ca6c51
http://www.gnu.org/software/cpio/manual