Blame SOURCES/cpio.1

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