1CPIO(1L)                                                              CPIO(1L)
2
3
4

NAME

6       cpio - copy files to and from archives
7

SYNOPSIS

9       Copy-out mode
10
11       In  copy-out  mode, cpio copies files into an archive.  It reads a list
12       of filenames, one per line, on the standard input, and writes  the  ar‐
13       chive  onto the standard output.  A typical way to generate the list of
14       filenames is with the find command; you should  give  find  the  -depth
15       option  to  minimize  problems with permissions on directories that are
16       unreadable.  see Options.
17
18       cpio {-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M message]  [-O
19       [[user@]host:]archive]            [-F            [[user@]host:]archive]
20       [--file=[[user@]host:]archive]    [--format=format]     [--message=mes‐
21       sage][--null]   [--reset-access-time]  [--verbose]  [--dot]  [--append]
22       [--block-size=blocks]  [--dereference]  [--io-size=bytes]   [--rsh-com‐
23       mand=command] [--help] [--version] < name-list [> archive]
24
25       Copy-in mode
26
27       In  copy-in  mode, cpio copies files out of an archive or lists the ar‐
28       chive contents.  It reads the archive from  the  standard  input.   Any
29       non-option  command  line  arguments  are shell globbing patterns; only
30       files in the archive whose names match one or more  of  those  patterns
31       are  copied from the archive.  Unlike in the shell, an initial `.' in a
32       filename does match a wildcard at the start of a pattern, and a `/'  in
33       a  filename  can  match wildcards.  If no patterns are given, all files
34       are extracted.  see Options.
35
36       cpio {-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H  format]
37       [-M  message]  [-R  [user][:.][group]]  [-I  [[user@]host:]archive] [-F
38       [[user@]host:]archive] [--file=[[user@]host:]archive]  [--make-directo‐
39       ries]           [--nonmatching]          [--preserve-modification-time]
40       [--numeric-uid-gid] [--rename] [--list] [--swap-bytes] [--swap] [--dot]
41       [--unconditional]  [--verbose] [--block-size=blocks] [--swap-halfwords]
42       [--io-size=bytes]        [--pattern-file=file]        [--format=format]
43       [--owner=[user][:.][group]]  [--no-preserve-owner]  [--message=message]
44       [--help]  [--version]  [--absolute-filenames]  [--sparse]   [-only-ver‐
45       ify-crc] [-quiet] [--rsh-command=command] [pattern...] [< archive]
46
47       Copy-pass mode
48
49       In  copy-pass  mode,  cpio  copies  files  from  one  directory tree to
50       another, combining the copy-out  and  copy-in  steps  without  actually
51       using an archive.  It reads the list of files to copy from the standard
52       input; the directory into which it will copy them is given  as  a  non-
53       option argument.  see Options.
54
55       cpio  {-p|--pass-through}  [-0adlmuvLV] [-R [user][:.][group]] [--null]
56       [--reset-access-time] [--make-directories] [--link] [--preserve-modifi‐
57       cation-time]   [--unconditional]  [--verbose]  [--dot]  [--dereference]
58       [--owner=[user][:.][group]] [--sparse]  [--no-preserve-owner]  [--help]
59       [--version] destination-directory < name-list
60

DESCRIPTION

62       GNU  cpio  is  a  tool for creating and extracting archives, or copying
63       files from one place to another.  It handles a number of  cpio  formats
64       as well as reading and writing tar files.
65
66       Following  archive formats are supported: binary, old ASCII, new ASCII,
67       crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1  tar.   The  tar
68       format  is provided for compatability with the tar program. By default,
69       cpio creates binary format archives, for compatibility with older  cpio
70       programs.  When extracting from archives, cpio automatically recognizes
71       which kind of archive it is reading and can read  archives  created  on
72       machines with a different byte-order.
73

OPTIONS

75       `-0,  --null'  Read a list of filenames terminated by a null character,
76       instead of a newline, so that files whose names contain newlines can be
77       archived.   GNU  find  is  one way to produce a list of null-terminated
78       filenames.  This option may be used in copy-out and copy-pass modes.
79
80       `-a, --reset-access-time' Reset the access times of files after reading
81       them, so that it does not look like they have just been read.
82
83       `-A,  --append'  Append to an existing archive.  Only works in copy-out
84       mode.  The archive must be a disk file specified  with  the  -O  or  -F
85       (-file) option.
86
87       `-b, --swap' Swap both halfwords of words and bytes of halfwords in the
88       data.  Equivalent to -sS.  This option may be  used  in  copy-in  mode.
89       Use  this option to convert 32-bit integers between big-endian and lit‐
90       tle-endian machines.
91
92       `-B' Set the I/O block size to 5120 bytes.  Initially the block size is
93       512 bytes.
94
95       `--block-size=BLOCK-SIZE'  Set  the  I/O block size to BLOCK-SIZE * 512
96       bytes.
97
98       `-c' Identical to -H newc, use the new (SVR4) portable format.  If  you
99       wish the old portable (ASCII) archive format, use -H odc instead.
100
101       `-C  IO-SIZE,  --io-size=IO-SIZE'  Set  the  I/O  block size to IO-SIZE
102       bytes.
103
104       `-d, --make-directories' Create leading directories where needed.
105
106       `-E FILE,  --pattern-file=FILE'  Read  additional  patterns  specifying
107       filenames  to extract or list from FILE.  The lines of FILE are treated
108       as if they had been non-option arguments to cpio.  This option is  used
109       in copy-in mode,
110
111       `-f,  --nonmatching' Only copy files that do not match any of the given
112       patterns.
113
114       `-F, --file=archive' Archive filename to use instead of standard  input
115       or  output.  To use a tape drive on another machine as the archive, use
116       a filename that starts with `HOSTNAME:'.  The hostname can be  preceded
117       by  a username and an `@' to access the remote tape drive as that user,
118       if you have permission to do so (typically  an  entry  in  that  user's
119       `~/.rhosts' file).
120
121       `--force-local'  With -F, -I, or -O, take the archive file name to be a
122       local file even if it contains a colon, which would ordinarily indicate
123       a remote host name.
124
125       `-H FORMAT, --format=FORMAT' Use archive format FORMAT.  The valid for‐
126       mats are listed below; the same names are also recognized in  all-caps.
127       The default in copy-in mode is to automatically detect the archive for‐
128       mat, and in copy-out mode is `bin'.
129
130       `bin' The obsolete binary format.
131
132       `odc' The old (POSIX.1) portable format.
133
134       `newc' The new (SVR4) portable format, which supports file systems hav‐
135       ing more than 65536 i-nodes.
136
137       `crc' The new (SVR4) portable format with a checksum added.
138
139       `tar' The old tar format.
140
141       `ustar'  The  POSIX.1  tar  format.   Also recognizes GNU tar archives,
142       which are similar but not identical.
143
144       `hpbin' The obsolete binary format used by HPUX's  cpio  (which  stores
145       device files differently).
146
147       `hpodc'  The  portable  format used by HPUX's cpio (which stores device
148       files differently).
149
150       `-i, --extract' Run in copy-in mode.  see Copy-in mode.
151
152       `-I archive' Archive filename to use instead of standard input.  To use
153       a  tape  drive  on  another machine as the archive, use a filename that
154       starts with `HOSTNAME:'.  The hostname can be preceded  by  a  username
155       and  an  `@'  to access the remote tape drive as that user, if you have
156       permission to do so (typically an  entry  in  that  user's  `~/.rhosts'
157       file).
158
159       `-k' Ignored; for compatibility with other versions of cpio.
160
161       `-l, --link' Link files instead of copying them, when possible.
162
163       `-L,  --dereference'  Copy  the  file  that  a symbolic link points to,
164       rather than the symbolic link itself.
165
166       `-m, --preserve-modification-time' Retain  previous  file  modification
167       times when creating files.
168
169       `-M  MESSAGE, --message=MESSAGE' Print MESSAGE when the end of a volume
170       of the backup media (such as a tape or a floppy disk)  is  reached,  to
171       prompt the user to insert a new volume.  If MESSAGE contains the string
172       %d, it is replaced by the current volume number (starting at 1).
173
174       `-n, --numeric-uid-gid' Show numeric UID and GID instead of translating
175       them into names when using the `--verbose option'.
176
177       `--absolute-filenames'  Do  not strip leading file name components that
178       contain ..  and leading slashes from file names in copy-in mode
179
180       `--no-preserve-owner' Do not change the ownership of the  files;  leave
181       them  owned  by the user extracting them.  This is the default for non-
182       root users, so that users on System V  don't  inadvertantly  give  away
183       files.  This option can be used in copy-in mode and copy-pass mode
184
185       `-o, --create' Run in copy-out mode.  see Copy-out mode.
186
187       `-O  archive'  Archive  filename to use instead of standard output.  To
188       use a tape drive on another machine as the archive, use a filename that
189       starts  with  `HOSTNAME:'.   The hostname can be preceded by a username
190       and an `@' to access the remote tape drive as that user,  if  you  have
191       permission  to  do  so  (typically  an entry in that user's `~/.rhosts'
192       file).
193
194       `--only-verify-crc' Verify the CRC's of each file in the archive,  when
195       reading a CRC format archive. Don't actually extract the files.
196
197       `-p, --pass-through' Run in copy-pass mode.  see Copy-pass mode.
198
199       `--quiet' Do not print the number of blocks copied.
200
201       `-r, --rename' Interactively rename files.
202
203       `-R  [user][:.][group], --owner [user][:.][group]' Set the ownership of
204       all files created to the specified user and/or group  in  copy-out  and
205       copy-pass modes.  Either the user, the group, or both, must be present.
206       If the group is omitted but the : or .  separator  is  given,  use  the
207       given user's login group.  Only the super-user can change files' owner‐
208       ship.
209
210       `--rsh-command=COMMAND' Notifies cpio that is  should  use  COMMAND  to
211       communicate with remote devices.
212
213       `-s,  --swap-bytes'  Swap the bytes of each halfword (pair of bytes) in
214       the files.This option can be used in copy-in mode.
215
216       `-S, --swap-halfwords' Swap the halfwords of each word (4 bytes) in the
217       files.  This option may be used in copy-in mode.
218
219       `--sparse'  Write  files  with  large  blocks of zeros as sparse files.
220       This option is used in copy-in and copy-pass modes.
221
222       `-t, --list' Print a table of contents of the input.
223
224       `-u, --unconditional' Replace all  files,  without  asking  whether  to
225       replace existing newer files with older files.
226
227       `-v, --verbose' List the files processed, or with `-t', give an `ls -l'
228       style table of contents listing.  In a verbose table of contents  of  a
229       ustar archive, user and group names in the archive that do not exist on
230       the local system are replaced by the names that correspond  locally  to
231       the numeric UID and GID stored in the archive.
232
233       `-V --dot' Print a `.' for each file processed.
234
235       `--version' Print the cpio program version number and exit.
236

EXAMPLES

238       When  creating an archive, cpio takes the list of files to be processed
239       from the standard input, and then sends the  archive  to  the  standard
240       output,  or  to the device defined by the `-F' option.  Usually find or
241       ls is used to provide this list to the standard input.  In the  follow‐
242       ing example you can see the possibilities for archiving the contents of
243       a single directory.
244
245       % ls | cpio -ov > directory.cpio
246
247       The `-o' option creates the archive, and the  `-v'  option  prints  the
248       names of the files archived as they are added.  Notice that the options
249       can be put together after a single `-' or can be placed  separately  on
250       the  command  line.   The  `>'  redirects  the  cpio output to the file
251       `directory.cpio'.
252
253       If you wanted to archive an entire directory tree, the find command can
254       provide the file list to cpio:
255
256       % find . -print -depth | cpio -ov > tree.cpio
257
258       This  will take all the files in the current directory, the directories
259       below and place them in the archive tree.cpio.  Again the `-o'  creates
260       an archive, and the `-v' option shows you the name of the files as they
261       are archived.  see Copy-out mode.  Using the `.' in the find  statement
262       will  give  you  more  flexibility when doing restores, as it will save
263       file names with a relative path vice a hard wired, absolute path.   The
264       `-depth'  option  forces  `find' to print of the entries in a directory
265       before printing the directory  itself.   This  limits  the  effects  of
266       restrictive  directory permissions by printing the directory entries in
267       a directory before the directory name itself.
268
269       Extracting an archive requires a bit more thought because cpio will not
270       create  directories by default.  Another characteristic, is it will not
271       overwrite existing files unless you tell it to.
272
273       % cpio -iv < directory.cpio
274
275       This will retrieve the files archived in the  file  directory.cpio  and
276       place  them in the present directory.  The `-i' option extracts the ar‐
277       chive and the `-v' shows the file names as they are extracted.  If  you
278       are  dealing  with an archived directory tree, you need to use the `-d'
279       option to create directories as necessary, something like:
280
281       % cpio -idv < tree.cpio
282
283       This will take the contents of the archive tree.cpio and extract it  to
284       the current directory.  If you try to extract the files on top of files
285       of the same name that already exist (and have the same or later modifi‐
286       cation time) cpio will not extract the file unless told to do so by the
287       -u option.  see Copy-in mode.
288
289       In copy-pass mode,  cpio  copies  files  from  one  directory  tree  to
290       another,  combining  the  copy-out  and  copy-in steps without actually
291       using an archive.  It reads the list of files to copy from the standard
292       input;  the  directory  into which it will copy them is given as a non-
293       option argument.  see Copy-pass mode.
294
295       % find . -depth -print0 | cpio --null -pvd new-dir
296
297       The example shows copying the files of the present directory, and  sub-
298       directories  to  a  new directory called new-dir.  Some new options are
299       the `-print0' available with  GNU  find,  combined  with  the  `--null'
300       option  of  cpio.   These  two  options act together to send file names
301       between find and cpio, even if special characters are embedded  in  the
302       file  names.   Another  is  `-p', which tells cpio to pass the files it
303       finds to the directory `new-dir'.
304
305

BUGS

307       The GNU folks, in general, abhor man pages, and create  info  documents
308       instead.  The maintainer of cpio falls into  this  category.  Thus this
309       man page may not be complete, nor current, and was included in the  Red
310       Hat CVS tree because man is a great tool :).
311

REPORTING BUGS

313       Please report bugs via https://bugzilla.redhat.com.
314

SEE ALSO

316       The  full documentation for cpio is maintained as a Texinfo manual.  If
317       the info and cpio programs are properly installed  at  your  site,  the
318       command
319
320              info cpio
321
322       should  give  you access to the complete manual. The online copy of the
323       documentation is available at the following address:
324
325       http://www.gnu.org/software/cpio/manual
326
327
328
329
330                                                                      CPIO(1L)
Impressum