source: trunk/essentials/app-arch/cpio/doc/cpio.texi

Last change on this file was 3332, checked in by bird, 18 years ago

cpio 2.7

File size: 18.7 KB
Line 
1\input texinfo @c -*-texinfo-*-
2@c %**start of header
3@setfilename cpio.info
4@settitle cpio
5@setchapternewpage off
6@c %**end of header
7
8@dircategory Archiving
9@direntry
10* Cpio: (cpio). Copy-in-copy-out archiver to tape or disk.
11@end direntry
12
13@include version.texi
14
15@copying
16This manual documents GNU cpio (version @value{VERSION}, @value{UPDATED}).
17
18Copyright @copyright{} 1995, 2001, 2002, 2004 Free Software Foundation, Inc.
19@sp 1
20@quotation
21Permission is granted to copy, distribute and/or modify this document
22under the terms of the GNU Free Documentation License, Version 1.2 or
23any later version published by the Free Software Foundation; with no
24Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
25and with the Back-Cover Texts as in (a) below. A copy of the license
26is included in the section entitled ``GNU Free Documentation License''.
27
28(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
29this GNU Manual, like GNU software. Copies published by the Free
30Software Foundation raise funds for GNU development.''
31@end quotation
32@end copying
33
34@titlepage
35@title GNU CPIO
36@subtitle @value{VERSION} @value{UPDATED}
37@author by Robert Carleton
38@c copyright page
39@page
40@vskip 0pt plus 1filll
41@insertcopying
42@sp 2
43Published by the Free Software Foundation @*
4451 Franklin Street, Fifth Floor, @*
45Boston, MA 02110-1301, USA @*
46@end titlepage
47
48@node Top, Introduction, (dir), (dir)
49@comment node-name, next, previous, up
50
51@ifinfo
52@top
53
54GNU cpio is a tool for creating and extracting archives, or copying
55files from one place to another. It handles a number of cpio formats as
56well as reading and writing tar files. This is the first edition of the
57GNU cpio documentation and is consistant with @value{VERSION}.
58
59@end ifinfo
60
61@menu
62* Introduction::
63* Tutorial:: Getting started.
64* Invoking `cpio':: How to invoke `cpio'.
65* Media:: Using tapes and other archive media.
66* Reports:: Reporting bugs or suggestions
67* Concept Index:: Concept index.
68
69@detailmenu
70 --- The Detailed Node Listing ---
71
72Invoking cpio
73
74* Copy-out mode::
75* Copy-in mode::
76* Copy-pass mode::
77* Options::
78@end detailmenu
79@end menu
80
81@node Introduction, Tutorial, Top, Top
82@comment node-name, next, previous, up
83@chapter Introduction
84
85GNU cpio copies files into or out of a cpio or tar archive, The archive
86can be another file on the disk, a magnetic tape, or a pipe.
87
88GNU cpio supports the following archive formats: binary, old ASCII, new
89ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1 tar. The
90tar format is provided for compatibility with the tar program. By
91default, cpio creates binary format archives, for compatibility with
92older cpio programs. When extracting from archives, cpio automatically
93recognizes which kind of archive it is reading and can read archives
94created on machines with a different byte-order.
95
96@node Tutorial, Invoking `cpio', Introduction, Top
97@comment node-name, next, previous, up
98@chapter Tutorial
99@cindex creating a cpio archive
100@cindex extracting a cpio archive
101@cindex copying directory structures
102@cindex passing directory structures
103
104
105GNU cpio performs three primary functions. Copying files to an
106archive, Extracting files from an archive, and passing files to another
107directory tree. An archive can be a file on disk, one or more floppy
108disks, or one or more tapes.
109
110When creating an archive, cpio takes the list of files to be processed
111from the standard input, and then sends the archive to the standard
112output, or to the device defined by the @samp{-F} option.
113@xref{Copy-out mode}. Usually find or ls is used to provide this list
114to the standard input. In the following example you can see the
115possibilities for archiving the contents of a single directory.
116
117
118@example
119@cartouche
120% ls | cpio -ov > directory.cpio
121@end cartouche
122@end example
123
124The @samp{-o} option creates the archive, and the @samp{-v} option
125prints the names of the files archived as they are added. Notice that
126the options can be put together after a single @samp{-} or can be placed
127separately on the command line. The @samp{>} redirects the cpio output
128to the file @samp{directory.cpio}.
129
130
131If you wanted to archive an entire directory tree, the find command can
132provide the file list to cpio:
133
134
135@example
136@cartouche
137% find . -print -depth | cpio -ov > tree.cpio
138@end cartouche
139@end example
140
141
142This will take all the files in the current directory, the directories
143below and place them in the archive tree.cpio. Again the @samp{-o}
144creates an archive, and the @samp{-v} option shows you the name of the
145files as they are archived. @xref{Copy-out mode}. Using the `.' in the
146find statement will give you more flexibility when doing restores, as it
147will save file names with a relative path vice a hard wired, absolute
148path. The @samp{-depth} option forces @samp{find} to print of the
149entries in a directory before printing the directory itself. This
150limits the effects of restrictive directory permissions by printing the
151directory entries in a directory before the directory name itself.
152
153
154
155
156Extracting an archive requires a bit more thought because cpio will not
157create directories by default. Another characteristic, is it will not
158overwrite existing files unless you tell it to.
159
160
161@example
162@cartouche
163% cpio -iv < directory.cpio
164@end cartouche
165@end example
166
167This will retrieve the files archived in the file directory.cpio and
168place them in the present directory. The @samp{-i} option extracts the
169archive and the @samp{-v} shows the file names as they are extracted.
170If you are dealing with an archived directory tree, you need to use the
171@samp{-d} option to create directories as necessary, something like:
172
173@example
174@cartouche
175% cpio -idv < tree.cpio
176@end cartouche
177@end example
178
179This will take the contents of the archive tree.cpio and extract it to
180the current directory. If you try to extract the files on top of files
181of the same name that already exist (and have the same or later
182modification time) cpio will not extract the file unless told to do so
183by the -u option. @xref{Copy-in mode}.
184
185
186In copy-pass mode, cpio copies files from one directory tree to another,
187combining the copy-out and copy-in steps without actually using an
188archive. It reads the list of files to copy from the standard input;
189the directory into which it will copy them is given as a non-option
190argument. @xref{Copy-pass mode}.
191
192@example
193@cartouche
194% find . -depth -print0 | cpio --null -pvd new-dir
195@end cartouche
196@end example
197
198
199The example shows copying the files of the present directory, and
200sub-directories to a new directory called new-dir. Some new options are
201the @samp{-print0} available with GNU find, combined with the
202@samp{--null} option of cpio. These two options act together to send
203file names between find and cpio, even if special characters are
204embedded in the file names. Another is @samp{-p}, which tells cpio to
205pass the files it finds to the directory @samp{new-dir}.
206
207@node Invoking `cpio', Media, Tutorial, Top
208@comment node-name, next, previous, up
209@chapter Invoking cpio
210@cindex invoking cpio
211@cindex command line options
212
213@menu
214* Copy-out mode::
215* Copy-in mode::
216* Copy-pass mode::
217* Options::
218@end menu
219
220@node Copy-out mode, Copy-in mode, Invoking `cpio', Invoking `cpio'
221@comment node-name, next, previous, up
222@section Copy-out mode
223
224In copy-out mode, cpio copies files into an archive. It reads a list
225of filenames, one per line, on the standard input, and writes the
226archive onto the standard output. A typical way to generate the list
227of filenames is with the find command; you should give find the -depth
228option to minimize problems with permissions on directories that are
229unreadable.
230@xref{Options}.
231
232@example
233cpio @{-o|--create@} [-0acvABLV] [-C bytes] [-H format]
234[-M message] [-O [[user@@]host:]archive] [-F [[user@@]host:]archive]
235[--file=[[user@@]host:]archive] [--format=format]
236[--message=message][--null] [--reset-access-time] [--verbose]
237[--dot] [--append] [--block-size=blocks] [--dereference]
238[--io-size=bytes] [--rsh-command=command] [--help] [--version]
239< name-list [> archive]
240@end example
241
242@node Copy-in mode, Copy-pass mode, Copy-out mode, Invoking `cpio'
243@comment node-name, next, previous, up
244@section Copy-in mode
245
246In copy-in mode, cpio copies files out of an archive or lists the
247archive contents. It reads the archive from the standard input. Any
248non-option command line arguments are shell globbing patterns; only
249files in the archive whose names match one or more of those patterns are
250copied from the archive. Unlike in the shell, an initial `.' in a
251filename does match a wildcard at the start of a pattern, and a `/' in a
252filename can match wildcards. If no patterns are given, all files are
253extracted. @xref{Options}.
254
255@example
256cpio @{-i|--extract@} [-bcdfmnrtsuvBSV] [-C bytes] [-E file]
257[-H format] [-M message] [-R [user][:.][group]]
258[-I [[user@@]host:]archive] [-F [[user@@]host:]archive]
259[--file=[[user@@]host:]archive] [--make-directories]
260[--nonmatching] [--preserve-modification-time]
261[--numeric-uid-gid] [--rename] [--list] [--swap-bytes] [--swap]
262[--dot] [--unconditional] [--verbose] [--block-size=blocks]
263[--swap-halfwords] [--io-size=bytes] [--pattern-file=file]
264[--format=format] [--owner=[user][:.][group]]
265[--no-preserve-owner] [--message=message] [--help] [--version]
266[--no-absolute-filenames] [--sparse] [-only-verify-crc] [-quiet]
267[--rsh-command=command] [pattern...] [< archive]
268@end example
269
270@node Copy-pass mode, Options, Copy-in mode, Invoking `cpio'
271@comment node-name, next, previous, up
272@section Copy-pass mode
273
274In copy-pass mode, cpio copies files from one directory tree to
275another, combining the copy-out and copy-in steps without actually
276using an archive. It reads the list of files to copy from the
277standard input; the directory into which it will copy them is given as
278a non-option argument.
279@xref{Options}.
280
281@example
282cpio @{-p|--pass-through@} [-0adlmuvLV] [-R [user][:.][group]]
283[--null] [--reset-access-time] [--make-directories] [--link]
284[--preserve-modification-time] [--unconditional] [--verbose]
285[--dot] [--dereference] [--owner=[user][:.][group]] [--sparse]
286[--no-preserve-owner] [--help] [--version] destination-directory
287< name-list
288@end example
289
290
291
292@node Options, , Copy-pass mode, Invoking `cpio'
293@comment node-name, next, previous, up
294@section Options
295
296
297@table @code
298
299
300@item -0, --null
301Read a list of filenames terminated by a null character, instead of a
302newline, so that files whose names contain newlines can be archived.
303GNU find is one way to produce a list of null-terminated filenames.
304This option may be used in copy-out and copy-pass modes.
305
306@item -a, --reset-access-time
307Reset the access times of files after reading them, so
308that it does not look like they have just been read.
309
310@item -A, --append
311Append to an existing archive. Only works in copy-out
312mode. The archive must be a disk file specified with
313the -O or -F (--file) option.
314
315@item -b, --swap
316Swap both halfwords of words and bytes of halfwords in the data.
317Equivalent to -sS. This option may be used in copy-in mode. Use this
318option to convert 32-bit integers between big-endian and little-endian
319machines.
320
321@item -B
322Set the I/O block size to 5120 bytes. Initially the
323block size is 512 bytes.
324
325@item --block-size=BLOCK-SIZE
326Set the I/O block size to BLOCK-SIZE * 512 bytes.
327
328@item -c
329Use the old portable (ASCII) archive format.
330
331@item -C IO-SIZE, --io-size=IO-SIZE
332Set the I/O block size to IO-SIZE bytes.
333
334@item -d, --make-directories
335Create leading directories where needed.
336
337@item -E FILE, --pattern-file=FILE
338Read additional patterns specifying filenames to extract or list from
339FILE. The lines of FILE are treated as if they had been non-option
340arguments to cpio. This option is used in copy-in mode,
341
342@item -f, --nonmatching
343Only copy files that do not match any of the given
344patterns.
345
346@item -F, --file=archive
347Archive filename to use instead of standard input or output. To use a
348tape drive on another machine as the archive, use a filename that starts
349with `HOSTNAME:'. The hostname can be preceded by a username and an
350`@@' to access the remote tape drive as that user, if you have
351permission to do so (typically an entry in that user's `~/.rhosts'
352file).
353
354@item --force-local
355With -F, -I, or -O, take the archive file name to be a
356local file even if it contains a colon, which would
357ordinarily indicate a remote host name.
358
359@item -H FORMAT, --format=FORMAT
360Use archive format FORMAT. The valid formats are listed below; the same
361names are also recognized in all-caps. The default in copy-in mode is
362to automatically detect the archive format, and in copy-out mode is
363@samp{bin}.
364
365@table @samp
366@item bin
367The obsolete binary format.
368
369@item odc
370The old (POSIX.1) portable format.
371
372@item newc
373The new (SVR4) portable format, which supports file systems having more
374than 65536 i-nodes.
375
376@item crc
377The new (SVR4) portable format with a checksum added.
378
379@item tar
380The old tar format.
381
382@item ustar
383The POSIX.1 tar format. Also recognizes GNU tar archives, which are
384similar but not identical.
385
386@item hpbin
387The obsolete binary format used by HPUX's cpio (which stores device
388files differently).
389
390@item hpodc
391The portable format used by HPUX's cpio (which stores device files
392differently).
393@end table
394
395@item -i, --extract
396Run in copy-in mode.
397@xref{Copy-in mode}.
398
399@item -I archive
400Archive filename to use instead of standard input. To use a tape drive
401on another machine as the archive, use a filename that starts with
402`HOSTNAME:'. The hostname can be preceded by a username and an `@@' to
403access the remote tape drive as that user, if you have permission to do
404so (typically an entry in that user's `~/.rhosts' file).
405
406@item -k
407Ignored; for compatibility with other versions of cpio.
408
409@item -l, --link
410Link files instead of copying them, when possible.
411
412@item -L, --dereference
413Copy the file that a symbolic link points to, rather than the symbolic
414link itself.
415
416@item -m, --preserve-modification-time
417Retain previous file modification times when creating files.
418
419@item -M MESSAGE, --message=MESSAGE
420Print MESSAGE when the end of a volume of the backup media (such as a
421tape or a floppy disk) is reached, to prompt the user to insert a new
422volume. If MESSAGE contains the string "%d", it is replaced by the
423current volume number (starting at 1).
424
425@item -n, --numeric-uid-gid
426Show numeric UID and GID instead of translating them into names when using the
427@samp{--verbose option}.
428
429@item --no-absolute-filenames
430Create all files relative to the current directory in copy-in mode, even
431if they have an absolute file name in the archive.
432
433@item --no-preserve-owner
434Do not change the ownership of the files; leave them owned by the user
435extracting them. This is the default for non-root users, so that users
436on System V don't inadvertantly give away files. This option can be
437used in copy-in mode and copy-pass mode
438
439@item -o, --create
440Run in copy-out mode.
441@xref{Copy-out mode}.
442
443@item -O archive
444Archive filename to use instead of standard output. To use a tape drive
445on another machine as the archive, use a filename that starts with
446`HOSTNAME:'. The hostname can be preceded by a username and an `@@' to
447access the remote tape drive as that user, if you have permission to do
448so (typically an entry in that user's `~/.rhosts' file).
449
450@item --only-verify-crc
451Verify the CRC's of each file in the archive, when reading a CRC format
452archive. Don't actually extract the files.
453
454@item -p, --pass-through
455Run in copy-pass mode.
456@xref{Copy-pass mode}.
457
458@item --quiet
459Do not print the number of blocks copied.
460
461@item -r, --rename
462Interactively rename files.
463
464@item -R [user][:.][group], --owner [user][:.][group]
465Set the ownership of all files created to the specified user and/or
466group in copy-out and copy-pass modes. Either the user, the group, or
467both, must be present. If the group is omitted but the ":" or "."
468separator is given, use the given user's login group. Only the
469super-user can change files' ownership.
470
471@item --rsh-command=COMMAND
472Notifies cpio that is should use COMMAND to communicate with remote
473devices.
474
475@item -s, --swap-bytes
476Swap the bytes of each halfword (pair of bytes) in the files.This option
477can be used in copy-in mode.
478
479@item -S, --swap-halfwords
480Swap the halfwords of each word (4 bytes) in the files. This option may
481be used in copy-in mode.
482
483@item --sparse
484Write files with large blocks of zeros as sparse files. This option is
485used in copy-in and copy-pass modes.
486
487@item -t, --list
488Print a table of contents of the input.
489
490@item -u, --unconditional
491Replace all files, without asking whether to replace
492existing newer files with older files.
493
494@item -v, --verbose
495List the files processed, or with @samp{-t}, give an @samp{ls -l} style
496table of contents listing. In a verbose table of contents of a ustar
497archive, user and group names in the archive that do not exist on the
498local system are replaced by the names that correspond locally to the
499numeric UID and GID stored in the archive.
500
501@item -V --dot
502Print a @kbd{.} for each file processed.
503
504@item --version
505Print the cpio program version number and exit.
506@end table
507
508
509@node Media, Reports, Invoking `cpio', Top
510@comment node-name, next, previous, up
511@chapter Magnetic Media
512@cindex magnetic media
513
514Archives are usually written on removable media--tape cartridges, mag
515tapes, or floppy disks.
516
517The amount of data a tape or disk holds depends not only on its size,
518but also on how it is formatted. A 2400 foot long reel of mag tape
519holds 40 megabytes of data when formated at 1600 bits per inch. The
520physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
521
522Magnetic media are re-usable--once the archive on a tape is no longer
523needed, the archive can be erased and the tape or disk used over. Media
524quality does deteriorate with use, however. Most tapes or disks should
525be disgarded when they begin to produce data errors.
526
527Magnetic media are written and erased using magnetic fields, and should
528be protected from such fields to avoid damage to stored data. Sticking
529a floppy disk to a filing cabinet using a magnet is probably not a good
530idea.
531
532@node Reports, Concept Index, Media, Top
533@chapter Reporting bugs or suggestions
534
535It is possible you will encounter a bug in @command{cpio}.
536If this happens, we would like to hear about it. As the purpose of bug
537reporting is to improve software, please be sure to include maximum
538information when reporting a bug. The information needed is:
539
540@itemize @bullet
541@item Version of the package you are using.
542@item Compilation options used when configuring the package.
543@item Conditions under which the bug appears.
544@end itemize
545
546Send your report to <bug-cpio@@gnu.org>. Allow us a couple of
547days to answer.
548
549@node Concept Index, , Reports, Top
550@comment node-name, next, previous, up
551@unnumbered Concept Index
552@printindex cp
553@contents
554@bye
Note: See TracBrowser for help on using the repository browser.