bsdcpio.1 12 KB

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