1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
|
<!-- Creator : groff version 1.23.0 -->
<!-- CreationDate: Mon Jan 5 10:42:46 2026 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title></title>
</head>
<body>
<hr>
<p><i>CPIO</i>(1) General Commands Manual
<i>CPIO</i>(1)</p>
<p style="margin-top: 1em"><b>NAME</b></p>
<p style="margin-left:9%;">cpio — copy files to and
from archives</p>
<p style="margin-top: 1em"><b>SYNOPSIS</b></p>
<p style="margin-left:15%;"><b>cpio -i</b> [<i>options</i>]
[<i>pattern ...</i>] [<i>< archive</i>] <b><br>
cpio -o</b> [<i>options</i>] <i>< name-list</i>
[<i>> archive</i>] <b><br>
cpio -p</b> [<i>options</i>] <i>dest-dir <
name-list</i></p>
<p style="margin-top: 1em"><b>DESCRIPTION</b></p>
<p style="margin-left:9%;"><b>cpio</b> copies files between
archives and directories. This implementation can extract
from tar, pax, cpio, zip, jar, ar, and ISO 9660 cdrom images
and can create tar, pax, cpio, ar, and shar archives.</p>
<p style="margin-left:9%; margin-top: 1em">The first option
to <b>cpio</b> is a mode indicator from the following
list:</p>
<p><b>-i</b></p>
<p style="margin-left:19%; margin-top: 1em">Input. Read an
archive from standard input (unless overridden) and extract
the contents to disk or (if the <b>-t</b> option is
specified) list the contents to standard output. If one or
more file patterns are specified, only files matching one of
the patterns will be extracted.</p>
<p><b>-o</b></p>
<p style="margin-left:19%; margin-top: 1em">Output. Read a
list of filenames from standard input and produce a new
archive on standard output (unless overridden) containing
the specified items.</p>
<p><b>-p</b></p>
<p style="margin-left:19%; margin-top: 1em">Pass-through.
Read a list of filenames from standard input and copy the
files to the specified directory.</p>
<p style="margin-top: 1em"><b>OPTIONS</b></p>
<p style="margin-left:9%;">Unless specifically stated
otherwise, options are applicable in all operating
modes.</p>
<p style="margin-top: 1em"><b>-0</b>, <b>--null</b></p>
<p style="margin-left:19%;">Read filenames separated by NUL
characters instead of newlines. This is necessary if any of
the filenames being read might contain newlines.</p>
<p style="margin-top: 1em"><b>-6</b>, <b>--pwb</b></p>
<p style="margin-left:19%;">When reading a binary format
archive, assume it’s the earlier one, from the PWB
variant of 6th Edition UNIX. When writing a cpio archive,
use the PWB format.</p>
<p style="margin-top: 1em"><b>-7</b>, <b>--binary</b></p>
<p style="margin-left:19%;">(o mode only) When writing a
cpio archive, use the (newer, non-PWB) binary format.</p>
<p style="margin-top: 1em"><b>-A</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Append to the specified archive. (Not yet implemented.)</p>
<p style="margin-top: 1em"><b>-a</b></p>
<p style="margin-left:19%; margin-top: 1em">(o and p modes)
Reset access times on files after they are read.</p>
<p style="margin-top: 1em"><b>-B</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Block output to records of 5120 bytes.</p>
<p style="margin-top: 1em"><b>-C</b> <i>size</i></p>
<p style="margin-left:19%;">(o mode only) Block output to
records of <i>size</i> bytes.</p>
<p style="margin-top: 1em"><b>-c</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Use the old POSIX portable character format. Equivalent to
<b>--format</b> <i>odc</i>.</p>
<p style="margin-top: 1em"><b>-d</b>,
<b>--make-directories</b></p>
<p style="margin-left:19%;">(i and p modes) Create
directories as necessary.</p>
<p style="margin-top: 1em"><b>-E</b> <i>file</i></p>
<p style="margin-left:19%;">(i mode only) Read list of file
name patterns from <i>file</i> to list and extract.</p>
<p style="margin-top: 1em"><b>-F</b> <i>file</i>,
<b>--file</b> <i>file</i></p>
<p style="margin-left:19%;">Read archive from or write
archive to <i>file</i>.</p>
<p style="margin-top: 1em"><b>-f</b> <i>pattern</i></p>
<p style="margin-left:19%;">(i mode only) Ignore files that
match <i>pattern</i>.</p>
<p style="margin-top: 1em"><b>-H</b> <i>format</i>,
<b>--format</b> <i>format</i></p>
<p style="margin-left:19%;">(o mode only) Produce the
output archive in the specified format. Supported formats
include:</p>
<p style="margin-top: 1em"><i>cpio</i></p>
<p style="margin-left:31%; margin-top: 1em">Synonym for
<i>odc</i>.</p>
<p><i>newc</i></p>
<p style="margin-left:31%; margin-top: 1em">The SVR4
portable cpio format.</p>
<p><i>odc</i></p>
<p style="margin-left:31%; margin-top: 1em">The old POSIX.1
portable octet-oriented cpio format.</p>
<p><i>pax</i></p>
<p style="margin-left:31%; margin-top: 1em">The POSIX.1 pax
format, an extension of the ustar format.</p>
<p><i>ustar</i></p>
<p style="margin-left:31%; margin-top: 1em">The POSIX.1 tar
format.</p>
<p style="margin-left:19%; margin-top: 1em">The default
format is <i>odc</i>. See <i>libarchive-formats</i>(5) for
more complete information about the formats currently
supported by the underlying <i>libarchive</i>(3)
library.</p>
<p style="margin-top: 1em"><b>-h</b>, <b>--help</b></p>
<p style="margin-left:19%;">Print usage information.</p>
<p style="margin-top: 1em"><b>-I</b> <i>file</i></p>
<p style="margin-left:19%;">Read archive from
<i>file</i>.</p>
<p style="margin-top: 1em"><b>-i</b>, <b>--extract</b></p>
<p style="margin-left:19%;">Input mode. See above for
description.</p>
<p style="margin-top: 1em"><b>--insecure</b></p>
<p style="margin-left:19%;">(i and p mode only) Disable
security checks during extraction or copying. This allows
extraction via symbolic links, absolute paths, and path
names containing ‘..’ in the name.</p>
<p style="margin-top: 1em"><b>-J</b>, <b>--xz</b></p>
<p style="margin-left:19%;">(o mode only) Compress the file
with xz-compatible compression before writing it. In input
mode, this option is ignored; xz compression is recognized
automatically on input.</p>
<p style="margin-top: 1em"><b>-j</b></p>
<p style="margin-left:19%; margin-top: 1em">Synonym for
<b>-y</b>.</p>
<p style="margin-top: 1em"><b>-L</b></p>
<p style="margin-left:19%; margin-top: 1em">(o and p modes)
All symbolic links will be followed. Normally, symbolic
links are archived and copied as symbolic links. With this
option, the target of the link will be archived or copied
instead.</p>
<p style="margin-top: 1em"><b>-l</b>, <b>--link</b></p>
<p style="margin-left:19%;">(p mode only) Create links from
the target directory to the original files, instead of
copying.</p>
<p style="margin-top: 1em"><b>--lrzip</b></p>
<p style="margin-left:19%;">(o mode only) Compress the
resulting archive with <i>lrzip</i>(1). In input mode, this
option is ignored.</p>
<p style="margin-top: 1em"><b>--lz4</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the archive with lz4-compatible compression before
writing it. In input mode, this option is ignored; lz4
compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>--zstd</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the archive with zstd-compatible compression before
writing it. In input mode, this option is ignored; zstd
compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>--lzma</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the file with lzma-compatible compression before
writing it. In input mode, this option is ignored; lzma
compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>--lzop</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the resulting archive with <i>lzop</i>(1). In input
mode, this option is ignored.</p>
<p style="margin-top: 1em"><b>--passphrase</b>
<i>passphrase</i></p>
<p style="margin-left:19%;">The <i>passphrase</i> is used
to extract or create an encrypted archive. Currently, zip is
only a format that <b>cpio</b> can handle encrypted
archives. You shouldn’t use this option unless you
realize how insecure use of this option is.</p>
<p style="margin-top: 1em"><b>-m</b>,
<b>--preserve-modification-time</b></p>
<p style="margin-left:19%;">(i and p modes) Set file
modification time on created files to match those in the
source.</p>
<p style="margin-top: 1em"><b>-n</b>,
<b>--numeric-uid-gid</b></p>
<p style="margin-left:19%;">(i mode, only with <b>-t</b>)
Display numeric uid and gid. By default, <b>cpio</b>
displays the user and group names when they are provided in
the archive, or looks up the user and group names in the
system password database.</p>
<p style="margin-top: 1em"><b>--no-preserve-owner</b></p>
<p style="margin-left:19%;">(i mode only) Do not attempt to
restore file ownership. This is the default when run by
non-root users.</p>
<p style="margin-top: 1em"><b>-O</b> <i>file</i></p>
<p style="margin-left:19%;">Write archive to
<i>file</i>.</p>
<p style="margin-top: 1em"><b>-o</b>, <b>--create</b></p>
<p style="margin-left:19%;">Output mode. See above for
description.</p>
<p style="margin-top: 1em"><b>-p</b>,
<b>--pass-through</b></p>
<p style="margin-left:19%;">Pass-through mode. See above
for description.</p>
<p style="margin-top: 1em"><b>--preserve-owner</b></p>
<p style="margin-left:19%;">(i mode only) Restore file
ownership. This is the default when run by the root
user.</p>
<p style="margin-top: 1em"><b>--quiet</b></p>
<p style="margin-left:19%;">Suppress unnecessary
messages.</p>
<p style="margin-top: 1em"><b>-R</b> [ <br>
user][ <br>
:][ <br>
group], <b>--owner</b> [ <br>
user][ <br>
:][ <br>
group]</p>
<p style="margin-left:19%;">Set the owner and/or group on
files in the output. If group is specified with no user (for
example, <b>-R</b> <i>:wheel</i>) then the group will be set
but not the user. If the user is specified with a trailing
colon and no group (for example, <b>-R</b> <i>root:</i>)
then the group will be set to the user’s default
group. If the user is specified with no trailing colon, then
the user will be set but not the group. In <b>-i</b> and
<b>-p</b> modes, this option can only be used by the
super-user. (For compatibility, a period can be used in
place of the colon.)</p>
<p style="margin-top: 1em"><b>-r</b></p>
<p style="margin-left:19%; margin-top: 1em">(All modes.)
Rename files interactively. For each file, a prompt is
written to <i>/dev/tty</i> containing the name of the file
and a line is read from <i>/dev/tty</i>. If the line read is
blank, the file is skipped. If the line contains a single
period, the file is processed normally. Otherwise, the line
is taken to be the new name of the file.</p>
<p style="margin-top: 1em"><b>-t</b>, <b>--list</b></p>
<p style="margin-left:19%;">(i mode only) List the contents
of the archive to stdout; do not restore the contents to
disk.</p>
<p style="margin-top: 1em"><b>-u</b>,
<b>--unconditional</b></p>
<p style="margin-left:19%;">(i and p modes) Unconditionally
overwrite existing files. Ordinarily, an older file will not
overwrite a newer file on disk.</p>
<p style="margin-top: 1em"><b>-V</b>, <b>--dot</b></p>
<p style="margin-left:19%;">Print a dot to stderr for each
file as it is processed. Superseded by <b>-v</b>.</p>
<p style="margin-top: 1em"><b>-v</b>, <b>--verbose</b></p>
<p style="margin-left:19%;">Print the name of each file to
stderr as it is processed. With <b>-t</b>, provide a
detailed listing of each file.</p>
<p style="margin-top: 1em"><b>--version</b></p>
<p style="margin-left:19%;">Print the program version
information and exit.</p>
<p style="margin-top: 1em"><b>-y</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the archive with bzip2-compatible compression
before writing it. In input mode, this option is ignored;
bzip2 compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>-Z</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the archive with compress-compatible compression
before writing it. In input mode, this option is ignored;
compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>-z</b></p>
<p style="margin-left:19%; margin-top: 1em">(o mode only)
Compress the archive with gzip-compatible compression before
writing it. In input mode, this option is ignored; gzip
compression is recognized automatically on input.</p>
<p style="margin-top: 1em"><b>EXIT STATUS</b></p>
<p style="margin-left:9%;">The <b>cpio</b> utility
exits 0 on success, and >0 if an error
occurs.</p>
<p style="margin-top: 1em"><b>ENVIRONMENT</b></p>
<p style="margin-left:9%;">The following environment
variables affect the execution of <b>cpio</b>:</p>
<p style="margin-top: 1em">LANG</p>
<p style="margin-left:23%; margin-top: 1em">The locale to
use. See <i>environ</i>(7) for more information.</p>
<p style="margin-top: 1em">TZ</p>
<p style="margin-left:23%; margin-top: 1em">The timezone to
use when displaying dates. See <i>environ</i>(7) for more
information.</p>
<p style="margin-top: 1em"><b>EXAMPLES</b></p>
<p style="margin-left:9%;">The <b>cpio</b> command is
traditionally used to copy file hierarchies in conjunction
with the <i>find</i>(1) command. The first example here
simply copies all files from <i>src</i> to <i>dest</i>:</p>
<p style="margin-left:17%;"><b>find</b> <i>src</i> |
<b>cpio -pmud</b> <i>dest</i></p>
<p style="margin-left:9%; margin-top: 1em">By carefully
selecting options to the <i>find</i>(1) command and
combining it with other standard utilities, it is possible
to exercise very fine control over which files are copied.
This next example copies files from <i>src</i> to
<i>dest</i> that are more than 2 days old and whose names
match a particular pattern:</p>
<p style="margin-left:17%;"><b>find</b> <i>src</i>
<b>-mtime</b> <i>+2</i> | <b>grep foo[bar]</b> | <b>cpio
-pdmu</b> <i>dest</i></p>
<p style="margin-left:9%; margin-top: 1em">This example
copies files from <i>src</i> to <i>dest</i> that are more
than 2 days old and which contain the word “</p>
<p>foobar ”:</p>
<p style="margin-left:17%;"><b>find</b> <i>src</i>
<b>-mtime</b> <i>+2</i> | <b>xargs grep -l foobar</b> |
<b>cpio -pdmu</b> <i>dest</i></p>
<p style="margin-top: 1em"><b>COMPATIBILITY</b></p>
<p style="margin-left:9%;">The mode options i, o, and p and
the options a, B, c, d, f, l, m, r, t, u, and v comply with
SUSv2.</p>
<p style="margin-left:9%; margin-top: 1em">The old POSIX.1
standard specified that only <b>-i</b>, <b>-o</b>, and
<b>-p</b> were interpreted as command-line options. Each
took a single argument of a list of modifier characters. For
example, the standard syntax allows <b>-imu</b> but does not
support <b>-miu</b> or <b>-i -m -u</b>, since <i>m</i> and
<i>u</i> are only modifiers to <b>-i</b>, they are not
command-line options in their own right. The syntax
supported by this implementation is backwards-compatible
with the standard. For best compatibility, scripts should
limit themselves to the standard syntax.</p>
<p style="margin-top: 1em"><b>SEE ALSO</b></p>
<p style="margin-left:9%;"><i>bzip2</i>(1), <i>gzip</i>(1),
<i>mt</i>(1), <i>pax</i>(1), <i>tar</i>(1),
<i>libarchive</i>(3), <i>cpio</i>(5),
<i>libarchive-formats</i>(5), <i>tar</i>(5)</p>
<p style="margin-top: 1em"><b>STANDARDS</b></p>
<p style="margin-left:9%;">There is no current POSIX
standard for the cpio command; it appeared in ISO/IEC
9945-1:1996 (“POSIX.1”) but was dropped from
IEEE Std 1003.1-2001 (“POSIX.1”).</p>
<p style="margin-left:9%; margin-top: 1em">The cpio, ustar,
and pax interchange file formats are defined by IEEE Std
1003.1-2001 (“POSIX.1”) for the pax command.</p>
<p style="margin-top: 1em"><b>HISTORY</b></p>
<p style="margin-left:9%;">The original <b>cpio</b> and
<b>find</b> utilities were written by Dick Haight while
working in AT&T’s Unix Support Group. They first
appeared in 1977 in PWB/UNIX 1.0, the
“Programmer’s Work Bench” system developed
for use within AT&T. They were first released outside of
AT&T as part of System III Unix in 1981. As a result,
<b>cpio</b> actually predates <b>tar</b>, even though it was
not well-known outside of AT&T until some time
later.</p>
<p style="margin-left:9%; margin-top: 1em">This is a
complete re-implementation based on the <i>libarchive</i>(3)
library.</p>
<p style="margin-top: 1em"><b>BUGS</b></p>
<p style="margin-left:9%;">The cpio archive format has
several basic limitations: It does not store user and group
names, only numbers. As a result, it cannot be reliably used
to transfer files between systems with dissimilar user and
group numbering. Older cpio formats limit the user and group
numbers to 16 or 18 bits, which is insufficient for modern
systems. The cpio archive formats cannot support files over
4 gigabytes, except for the “odc” variant, which
can support files up to 8 gigabytes. Debian September 16,
2014 <i>CPIO</i>(1)</p>
<hr>
</body>
</html>
|