1 \input texinfo @c -*-texinfo-*-
10 * Cpio: (cpio). Copy-in-copy-out archiver to tape or disk.
16 This manual documents GNU cpio (version @value{VERSION}, @value{UPDATED}).
18 Copyright @copyright{} 1995, 2001, 2002, 2004 Free Software Foundation, Inc.
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.2 or
23 any later version published by the Free Software Foundation; with no
24 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
25 and with the Back-Cover Texts as in (a) below. A copy of the license
26 is included in the section entitled ``GNU Free Documentation License''.
28 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
29 this GNU Manual, like GNU software. Copies published by the Free
30 Software Foundation raise funds for GNU development.''
36 @subtitle @value{VERSION} @value{UPDATED}
37 @author by Robert Carleton
40 @vskip 0pt plus 1filll
43 Published by the Free Software Foundation @*
44 51 Franklin Street, Fifth Floor, @*
45 Boston, MA 02110-1301, USA @*
48 @node Top, Introduction, (dir), (dir)
49 @comment node-name, next, previous, up
54 GNU cpio is a tool for creating and extracting archives, or copying
55 files from one place to another. It handles a number of cpio formats as
56 well as reading and writing tar files. This is the first edition of the
57 GNU cpio documentation and is consistent with @value{VERSION}.
63 * Tutorial:: Getting started.
64 * Invoking cpio:: How to invoke @command{cpio}.
65 * Media:: Using tapes and other archive media.
66 * Reports:: Reporting bugs or suggestions
67 * Concept Index:: Concept index.
70 --- The Detailed Node Listing ---
82 @node Introduction, Tutorial, Top, Top
83 @comment node-name, next, previous, up
86 GNU cpio copies files into or out of a cpio or tar archive, The archive
87 can be another file on the disk, a magnetic tape, or a pipe.
89 GNU cpio supports the following archive formats: binary, old ASCII, new
90 ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1 tar. The
91 tar format is provided for compatibility with the tar program. By
92 default, cpio creates binary format archives, for compatibility with
93 older cpio programs. When extracting from archives, cpio automatically
94 recognizes which kind of archive it is reading and can read archives
95 created on machines with a different byte-order.
97 @node Tutorial, Invoking cpio, Introduction, Top
98 @comment node-name, next, previous, up
100 @cindex creating a cpio archive
101 @cindex extracting a cpio archive
102 @cindex copying directory structures
103 @cindex passing directory structures
106 GNU cpio performs three primary functions. Copying files to an
107 archive, Extracting files from an archive, and passing files to another
108 directory tree. An archive can be a file on disk, one or more floppy
109 disks, or one or more tapes.
111 When creating an archive, cpio takes the list of files to be processed
112 from the standard input, and then sends the archive to the standard
113 output, or to the device defined by the @option{-F} option.
114 @xref{Copy-out mode}. Usually find or ls is used to provide this list
115 to the standard input. In the following example you can see the
116 possibilities for archiving the contents of a single directory.
121 % ls | cpio -ov > directory.cpio
125 The @option{-o} option creates the archive, and the @option{-v} option
126 prints the names of the files archived as they are added. Notice that
127 the options can be put together after a single @option{-} or can be placed
128 separately on the command line. The @samp{>} redirects the cpio output
129 to the file @samp{directory.cpio}.
132 If you wanted to archive an entire directory tree, the find command can
133 provide the file list to cpio:
138 % find . -print -depth | cpio -ov > tree.cpio
143 This will take all the files in the current directory, the directories
144 below and place them in the archive tree.cpio. Again the @option{-o}
145 creates an archive, and the @option{-v} option shows you the name of the
146 files as they are archived. @xref{Copy-out mode}. Using the @samp{.} in the
147 find statement will give you more flexibility when doing restores, as it
148 will save file names with a relative path vice a hard wired, absolute
149 path. The @option{-depth} option forces @samp{find} to print of the
150 entries in a directory before printing the directory itself. This
151 limits the effects of restrictive directory permissions by printing the
152 directory entries in a directory before the directory name itself.
157 Extracting an archive requires a bit more thought because cpio will not
158 create directories by default. Another characteristic, is it will not
159 overwrite existing files unless you tell it to.
164 % cpio -iv < directory.cpio
168 This will retrieve the files archived in the file directory.cpio and
169 place them in the present directory. The @option{-i} option extracts the
170 archive and the @option{-v} shows the file names as they are extracted.
171 If you are dealing with an archived directory tree, you need to use the
172 @option{-d} option to create directories as necessary, something like:
176 % cpio -idv < tree.cpio
180 This will take the contents of the archive tree.cpio and extract it to
181 the current directory. If you try to extract the files on top of files
182 of the same name that already exist (and have the same or later
183 modification time) cpio will not extract the file unless told to do so
184 by the -u option. @xref{Copy-in mode}.
187 In copy-pass mode, cpio copies files from one directory tree to another,
188 combining the copy-out and copy-in steps without actually using an
189 archive. It reads the list of files to copy from the standard input;
190 the directory into which it will copy them is given as a non-option
191 argument. @xref{Copy-pass mode}.
195 % find . -depth -print0 | cpio --null -pvd new-dir
200 The example shows copying the files of the present directory, and
201 sub-directories to a new directory called new-dir. Some new options are
202 the @option{-print0} available with GNU find, combined with the
203 @option{--null} option of cpio. These two options act together to send
204 file names between find and cpio, even if special characters are
205 embedded in the file names. Another is @option{-p}, which tells cpio to
206 pass the files it finds to the directory @samp{new-dir}.
208 @node Invoking cpio, Media, Tutorial, Top
209 @comment node-name, next, previous, up
210 @chapter Invoking cpio
211 @cindex invoking cpio
212 @cindex command line options
221 @node Copy-out mode, Copy-in mode, Invoking cpio, Invoking cpio
222 @comment node-name, next, previous, up
223 @section Copy-out mode
225 In copy-out mode, cpio copies files into an archive. It reads a list
226 of filenames, one per line, on the standard input, and writes the
227 archive onto the standard output. A typical way to generate the list
228 of filenames is with the find command; you should give find the -depth
229 option to minimize problems with permissions on directories that are
234 cpio @{-o|--create@} [-0acvABLV] [-C bytes] [-H format]
235 [-M message] [-O [[user@@]host:]archive] [-F [[user@@]host:]archive]
236 [--file=[[user@@]host:]archive] [--format=format]
237 [--message=message][--null] [--reset-access-time] [--verbose]
238 [--dot] [--append] [--block-size=blocks] [--dereference]
239 [--io-size=bytes] [--rsh-command=command] [--help] [--version]
240 < name-list [> archive]
243 @node Copy-in mode, Copy-pass mode, Copy-out mode, Invoking cpio
244 @comment node-name, next, previous, up
245 @section Copy-in mode
247 In copy-in mode, cpio copies files out of an archive or lists the
248 archive contents. It reads the archive from the standard input. Any
249 non-option command line arguments are shell globbing patterns; only
250 files in the archive whose names match one or more of those patterns are
251 copied from the archive. Unlike in the shell, an initial @samp{.} in a
252 filename does match a wildcard at the start of a pattern, and a @samp{/} in a
253 filename can match wildcards. If no patterns are given, all files are
254 extracted. @xref{Options}.
257 cpio @{-i|--extract@} [-bcdfmnrtsuvBSV] [-C bytes] [-E file]
258 [-H format] [-M message] [-R [user][:.][group]]
259 [-I [[user@@]host:]archive] [-F [[user@@]host:]archive]
260 [--file=[[user@@]host:]archive] [--make-directories]
261 [--nonmatching] [--preserve-modification-time]
262 [--numeric-uid-gid] [--rename] [--list] [--swap-bytes] [--swap]
263 [--dot] [--unconditional] [--verbose] [--block-size=blocks]
264 [--swap-halfwords] [--io-size=bytes] [--pattern-file=file]
265 [--format=format] [--owner=[user][:.][group]]
266 [--no-preserve-owner] [--message=message] [--help] [--version]
267 [--absolute-filenames] [--sparse] [-only-verify-crc] [-quiet]
268 [--rsh-command=command] [pattern...] [< archive]
271 @node Copy-pass mode, Options, Copy-in mode, Invoking cpio
272 @comment node-name, next, previous, up
273 @section Copy-pass mode
275 In copy-pass mode, cpio copies files from one directory tree to
276 another, combining the copy-out and copy-in steps without actually
277 using an archive. It reads the list of files to copy from the
278 standard input; the directory into which it will copy them is given as
279 a non-option argument.
283 cpio @{-p|--pass-through@} [-0adlmuvLV] [-R [user][:.][group]]
284 [--null] [--reset-access-time] [--make-directories] [--link]
285 [--preserve-modification-time] [--unconditional] [--verbose]
286 [--dot] [--dereference] [--owner=[user][:.][group]] [--sparse]
287 [--no-preserve-owner] [--help] [--version] destination-directory
293 @node Options, , Copy-pass mode, Invoking cpio
294 @comment node-name, next, previous, up
303 Read a list of filenames terminated by a null character, instead of a
304 newline, so that files whose names contain newlines can be archived.
305 GNU find is one way to produce a list of null-terminated filenames.
306 This option may be used in copy-out and copy-pass modes.
309 @itemx --reset-access-time
310 Reset the access times of files after reading them, so
311 that it does not look like they have just been read.
315 Append to an existing archive. Only works in copy-out
316 mode. The archive must be a disk file specified with
317 the @option{-O} or @option{-F} (@option{--file}) option.
321 Swap both halfwords of words and bytes of halfwords in the data.
322 Equivalent to -sS. This option may be used in copy-in mode. Use this
323 option to convert 32-bit integers between big-endian and little-endian
327 Set the I/O block size to 5120 bytes. Initially the
328 block size is 512 bytes.
330 @item --block-size=@var{block-size}
331 Set the I/O block size to @var{block-size} * 512 bytes.
334 Use the old portable (ASCII) archive format.
336 @item -C @var{io-size}
337 @itemx --io-size=@var{io-size}
338 Set the I/O block size to @var{io-size} bytes.
341 @itemx --make-directories
342 Create leading directories where needed.
345 @itemx --pattern-file=@var{file}
346 Read additional patterns specifying filenames to extract or list from
347 @var{file}. The lines of @var{file} are treated as if they had been non-option
348 arguments to cpio. This option is used in copy-in mode,
352 Only copy files that do not match any of the given
355 @item -F @var{archive}
356 @itemx --file=@var{archive}
357 Archive filename to use instead of standard input or output. To use a
358 tape drive on another machine as the archive, use a filename that starts
359 with @samp{@var{hostname}:}, where @var{hostname} is the name or IP
360 address of the machine. The hostname can be preceded by a username and an
361 @samp{@@} to access the remote tape drive as that user, if you have
362 permission to do so (typically an entry in that user's @file{~/.rhosts}
366 With @option{-F}, @option{-I}, or @option{-O}, take the archive file name to be a
367 local file even if it contains a colon, which would
368 ordinarily indicate a remote host name.
370 @item -H @var{format}
371 @itemx --format=@var{format}
372 Use archive format @var{format}. The valid formats are listed below; the same
373 names are also recognized in all-caps. The default in copy-in mode is
374 to automatically detect the archive format, and in copy-out mode is
379 The obsolete binary format.
382 The old (POSIX.1) portable format.
385 The new (SVR4) portable format, which supports file systems having more
389 The new (SVR4) portable format with a checksum added.
395 The POSIX.1 tar format. Also recognizes GNU tar archives, which are
396 similar but not identical.
399 The obsolete binary format used by HPUX's cpio (which stores device
403 The portable format used by HPUX's cpio (which stores device files
412 @item -I @var{archive}
413 Archive filename to use instead of standard input. To use a tape drive
414 on another machine as the archive, use a filename that starts with
415 @samp{@var{hostname}:}, where @var{hostname} is the name or IP address
416 of the remote host. The hostname can be preceded by a username and an @samp{@@} to
417 access the remote tape drive as that user, if you have permission to do
418 so (typically an entry in that user's @file{~/.rhosts} file).
421 Ignored; for compatibility with other versions of cpio.
425 Link files instead of copying them, when possible.
429 Copy the file that a symbolic link points to, rather than the symbolic
433 @itemx --preserve-modification-time
434 Retain previous file modification times when creating files.
436 @item -M @var{message}
437 @itemx --message=@var{message}
438 Print @var{message} when the end of a volume of the backup media (such as a
439 tape or a floppy disk) is reached, to prompt the user to insert a new
440 volume. If @var{message} contains the string @samp{%d}, it is replaced by the
441 current volume number (starting at 1).
444 @itemx --numeric-uid-gid
445 Show numeric UID and GID instead of translating them into names when using the
446 @option{--verbose} option.
448 @item --absolute-filenames
449 Do not strip leading file name components that contain ".." and
450 leading slashes from file names in copy-in mode
452 @item --no-preserve-owner
453 Do not change the ownership of the files; leave them owned by the user
454 extracting them. This is the default for non-root users, so that users
455 on System V don't inadvertantly give away files. This option can be
456 used in copy-in mode and copy-pass mode
460 Run in copy-out mode.
461 @xref{Copy-out mode}.
463 @item -O @var{archive}
464 Archive filename to use instead of standard output. To use a tape drive
465 on another machine as the archive, use a filename that starts with
466 @samp{@var{hostname}:}, where @var{hostname} is the name or IP address
467 of the machine. The hostname can be preceded by a username and an @samp{@@} to
468 access the remote tape drive as that user, if you have permission to do
469 so (typically an entry in that user's @file{~/.rhosts} file).
471 @item --only-verify-crc
472 Verify the CRC's of each file in the archive, when reading a CRC format
473 archive. Don't actually extract the files.
476 @itemx --pass-through
477 Run in copy-pass mode.
478 @xref{Copy-pass mode}.
481 Do not print the number of blocks copied.
485 Interactively rename files.
488 @itemx --owner @var{owner}
490 In copy-in and copy-pass mode, set the ownership of all files created
491 to the specified @var{owner} (this operation is allowed only for the
492 super-user). In copy-out mode, store the supplied owner information in
495 The argument can be either the user name or the user name
496 and group name, separated by a dot or a colon, or the group name,
497 preceeded by a dot or a colon, as shown in the examples below:
503 cpio --owner smith:users
509 If the group is omitted but the @samp{:} or @samp{.} separator is
510 given, as in the second example. the given user's login group will be
513 @item --rsh-command=@var{command}
514 Notifies cpio that is should use @var{command} to communicate with remote
519 Swap the bytes of each halfword (pair of bytes) in the files. This option
520 can be used in copy-in mode.
523 @itemx --swap-halfwords
524 Swap the halfwords of each word (4 bytes) in the files. This option may
525 be used in copy-in mode.
528 Write files with large blocks of zeros as sparse files. This option is
529 used in copy-in and copy-pass modes.
533 Print a table of contents of the input.
536 @itemx --unconditional
537 Replace all files, without asking whether to replace
538 existing newer files with older files.
542 List the files processed, or with @option{-t}, give an @samp{ls -l} style
543 table of contents listing. In a verbose table of contents of a ustar
544 archive, user and group names in the archive that do not exist on the
545 local system are replaced by the names that correspond locally to the
546 numeric UID and GID stored in the archive.
550 Print a @samp{.} for each file processed.
553 Print the cpio program version number and exit.
557 @node Media, Reports, Invoking cpio, Top
558 @comment node-name, next, previous, up
559 @chapter Magnetic Media
560 @cindex magnetic media
562 Archives are usually written on removable media--tape cartridges, mag
563 tapes, or floppy disks.
565 The amount of data a tape or disk holds depends not only on its size,
566 but also on how it is formatted. A 2400 foot long reel of mag tape
567 holds 40 megabytes of data when formated at 1600 bits per inch. The
568 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
570 Magnetic media are re-usable--once the archive on a tape is no longer
571 needed, the archive can be erased and the tape or disk used over. Media
572 quality does deteriorate with use, however. Most tapes or disks should
573 be disgarded when they begin to produce data errors.
575 Magnetic media are written and erased using magnetic fields, and should
576 be protected from such fields to avoid damage to stored data. Sticking
577 a floppy disk to a filing cabinet using a magnet is probably not a good
580 @node Reports, Concept Index, Media, Top
581 @chapter Reporting bugs or suggestions
583 It is possible you will encounter a bug in @command{cpio}.
584 If this happens, we would like to hear about it. As the purpose of bug
585 reporting is to improve software, please be sure to include maximum
586 information when reporting a bug. The information needed is:
589 @item Version of the package you are using.
590 @item Compilation options used when configuring the package.
591 @item Conditions under which the bug appears.
594 Send your report to <bug-cpio@@gnu.org>. Allow us a couple of
597 @node Concept Index, , Reports, Top
598 @comment node-name, next, previous, up
599 @unnumbered Concept Index