bsdtar.1 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. .\" Copyright (c) 2003-2007 Tim Kientzle
  2. .\" Copyright (c) 2017 Martin Matuska
  3. .\" All rights reserved.
  4. .\"
  5. .\" Redistribution and use in source and binary forms, with or without
  6. .\" modification, are permitted provided that the following conditions
  7. .\" are met:
  8. .\" 1. Redistributions of source code must retain the above copyright
  9. .\" notice, this list of conditions and the following disclaimer.
  10. .\" 2. Redistributions in binary form must reproduce the above copyright
  11. .\" notice, this list of conditions and the following disclaimer in the
  12. .\" documentation and/or other materials provided with the distribution.
  13. .\"
  14. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. .\" SUCH DAMAGE.
  25. .\"
  26. .\" $FreeBSD$
  27. .\"
  28. .Dd January 31, 2020
  29. .Dt TAR 1
  30. .Os
  31. .Sh NAME
  32. .Nm tar
  33. .Nd manipulate tape archives
  34. .Sh SYNOPSIS
  35. .Nm
  36. .Op Ar bundled-flags Ao args Ac
  37. .Op Ao Ar file Ac | Ao Ar pattern Ac ...
  38. .Nm
  39. .Brq Fl c
  40. .Op Ar options
  41. .Op Ar files | Ar directories
  42. .Nm
  43. .Brq Fl r | Fl u
  44. .Fl f Ar archive-file
  45. .Op Ar options
  46. .Op Ar files | Ar directories
  47. .Nm
  48. .Brq Fl t | Fl x
  49. .Op Ar options
  50. .Op Ar patterns
  51. .Sh DESCRIPTION
  52. .Nm
  53. creates and manipulates streaming archive files.
  54. This implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
  55. rpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
  56. 7-zip, and shar archives.
  57. .Pp
  58. The first synopsis form shows a
  59. .Dq bundled
  60. option word.
  61. This usage is provided for compatibility with historical implementations.
  62. See COMPATIBILITY below for details.
  63. .Pp
  64. The other synopsis forms show the preferred usage.
  65. The first option to
  66. .Nm
  67. is a mode indicator from the following list:
  68. .Bl -tag -compact -width indent
  69. .It Fl c
  70. Create a new archive containing the specified items.
  71. The long option form is
  72. .Fl Fl create .
  73. .It Fl r
  74. Like
  75. .Fl c ,
  76. but new entries are appended to the archive.
  77. Note that this only works on uncompressed archives stored in regular files.
  78. The
  79. .Fl f
  80. option is required.
  81. The long option form is
  82. .Fl Fl append .
  83. .It Fl t
  84. List archive contents to stdout.
  85. The long option form is
  86. .Fl Fl list .
  87. .It Fl u
  88. Like
  89. .Fl r ,
  90. but new entries are added only if they have a modification date
  91. newer than the corresponding entry in the archive.
  92. Note that this only works on uncompressed archives stored in regular files.
  93. The
  94. .Fl f
  95. option is required.
  96. The long form is
  97. .Fl Fl update .
  98. .It Fl x
  99. Extract to disk from the archive.
  100. If a file with the same name appears more than once in the archive,
  101. each copy will be extracted, with later copies overwriting (replacing)
  102. earlier copies.
  103. The long option form is
  104. .Fl Fl extract .
  105. .El
  106. .Pp
  107. In
  108. .Fl c ,
  109. .Fl r ,
  110. or
  111. .Fl u
  112. mode, each specified file or directory is added to the
  113. archive in the order specified on the command line.
  114. By default, the contents of each directory are also archived.
  115. .Pp
  116. In extract or list mode, the entire command line
  117. is read and parsed before the archive is opened.
  118. The pathnames or patterns on the command line indicate
  119. which items in the archive should be processed.
  120. Patterns are shell-style globbing patterns as
  121. documented in
  122. .Xr tcsh 1 .
  123. .Sh OPTIONS
  124. Unless specifically stated otherwise, options are applicable in
  125. all operating modes.
  126. .Bl -tag -width indent
  127. .It Cm @ Ns Pa archive
  128. (c and r modes only)
  129. The specified archive is opened and the entries
  130. in it will be appended to the current archive.
  131. As a simple example,
  132. .Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
  133. writes a new archive to standard output containing a file
  134. .Pa newfile
  135. and all of the entries from
  136. .Pa original.tar .
  137. In contrast,
  138. .Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
  139. creates a new archive with only two entries.
  140. Similarly,
  141. .Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
  142. reads an archive from standard input (whose format will be determined
  143. automatically) and converts it into a gzip-compressed
  144. pax-format archive on stdout.
  145. In this way,
  146. .Nm
  147. can be used to convert archives from one format to another.
  148. .It Fl a , Fl Fl auto-compress
  149. (c mode only)
  150. Use the archive suffix to decide a set of the format and
  151. the compressions.
  152. As a simple example,
  153. .Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h
  154. creates a new archive with restricted pax format and gzip compression,
  155. .Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h
  156. creates a new archive with restricted pax format and bzip2 compression
  157. and uuencode compression,
  158. .Dl Nm Fl a Fl cf Pa archive.zip source.c source.h
  159. creates a new archive with zip format,
  160. .Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h
  161. ignores the
  162. .Dq -j
  163. option, and creates a new archive with restricted pax format
  164. and gzip compression,
  165. .Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h
  166. if it is unknown suffix or no suffix, creates a new archive with
  167. restricted pax format and bzip2 compression.
  168. .It Fl Fl acls
  169. (c, r, u, x modes only)
  170. Archive or extract POSIX.1e or NFSv4 ACLs.
  171. This is the reverse of
  172. .Fl Fl no-acls
  173. and the default behavior in c, r, and u modes (except on Mac OS X) or if
  174. .Nm
  175. is run in x mode as root.
  176. On Mac OS X this option translates extended ACLs to NFSv4 ACLs.
  177. To store extended ACLs the
  178. .Fl Fl mac-metadata
  179. option is preferred.
  180. .It Fl B , Fl Fl read-full-blocks
  181. Ignored for compatibility with other
  182. .Xr tar 1
  183. implementations.
  184. .It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
  185. Specify the block size, in 512-byte records, for tape drive I/O.
  186. As a rule, this argument is only needed when reading from or writing
  187. to tape drives, and usually not even then as the default block size of
  188. 20 records (10240 bytes) is very common.
  189. .It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
  190. In c and r mode, this changes the directory before adding
  191. the following files.
  192. In x mode, change directories after opening the archive
  193. but before extracting entries from the archive.
  194. .It Fl Fl chroot
  195. (x mode only)
  196. .Fn chroot
  197. to the current directory after processing any
  198. .Fl C
  199. options and before extracting any files.
  200. .It Fl Fl clear-nochange-fflags
  201. (x mode only)
  202. Before removing file system objects to replace them, clear platform-specific
  203. file attributes or file flags that might prevent removal.
  204. .It Fl Fl exclude Ar pattern
  205. Do not process files or directories that match the
  206. specified pattern.
  207. Note that exclusions take precedence over patterns or filenames
  208. specified on the command line.
  209. .It Fl Fl exclude-vcs
  210. Do not process files or directories internally used by the
  211. version control systems
  212. .Sq Arch ,
  213. .Sq Bazaar ,
  214. .Sq CVS ,
  215. .Sq Darcs ,
  216. .Sq Mercurial ,
  217. .Sq RCS ,
  218. .Sq SCCS ,
  219. .Sq SVN
  220. and
  221. .Sq git .
  222. .It Fl Fl fflags
  223. (c, r, u, x modes only)
  224. Archive or extract platform-specific file attributes or file flags.
  225. This is the reverse of
  226. .Fl Fl no-fflags
  227. and the default behavior in c, r, and u modes or if
  228. .Nm
  229. is run in x mode as root.
  230. .It Fl Fl format Ar format
  231. (c, r, u mode only)
  232. Use the specified format for the created archive.
  233. Supported formats include
  234. .Dq cpio ,
  235. .Dq pax ,
  236. .Dq shar ,
  237. and
  238. .Dq ustar .
  239. Other formats may also be supported; see
  240. .Xr libarchive-formats 5
  241. for more information about currently-supported formats.
  242. In r and u modes, when extending an existing archive, the format specified
  243. here must be compatible with the format of the existing archive on disk.
  244. .It Fl f Ar file , Fl Fl file Ar file
  245. Read the archive from or write the archive to the specified file.
  246. The filename can be
  247. .Pa -
  248. for standard input or standard output.
  249. The default varies by system;
  250. on
  251. .Fx ,
  252. the default is
  253. .Pa /dev/sa0 ;
  254. on Linux, the default is
  255. .Pa /dev/st0 .
  256. .It Fl Fl gid Ar id
  257. Use the provided group id number.
  258. On extract, this overrides the group id in the archive;
  259. the group name in the archive will be ignored.
  260. On create, this overrides the group id read from disk;
  261. if
  262. .Fl Fl gname
  263. is not also specified, the group name will be set to
  264. match the group id.
  265. .It Fl Fl gname Ar name
  266. Use the provided group name.
  267. On extract, this overrides the group name in the archive;
  268. if the provided group name does not exist on the system,
  269. the group id
  270. (from the archive or from the
  271. .Fl Fl gid
  272. option)
  273. will be used instead.
  274. On create, this sets the group name that will be stored
  275. in the archive;
  276. the name will not be verified against the system group database.
  277. .It Fl H
  278. (c and r modes only)
  279. Symbolic links named on the command line will be followed; the
  280. target of the link will be archived, not the link itself.
  281. .It Fl h
  282. (c and r modes only)
  283. Synonym for
  284. .Fl L .
  285. .It Fl I
  286. Synonym for
  287. .Fl T .
  288. .It Fl Fl help
  289. Show usage.
  290. .It Fl Fl hfsCompression
  291. (x mode only)
  292. Mac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
  293. compression.
  294. .It Fl Fl ignore-zeros
  295. An alias of
  296. .Fl Fl options Cm read_concatenated_archives
  297. for compatibility with GNU tar.
  298. .It Fl Fl include Ar pattern
  299. Process only files or directories that match the specified pattern.
  300. Note that exclusions specified with
  301. .Fl Fl exclude
  302. take precedence over inclusions.
  303. If no inclusions are explicitly specified, all entries are processed by
  304. default.
  305. The
  306. .Fl Fl include
  307. option is especially useful when filtering archives.
  308. For example, the command
  309. .Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
  310. creates a new archive
  311. .Pa new.tar
  312. containing only the entries from
  313. .Pa old.tgz
  314. containing the string
  315. .Sq foo .
  316. .It Fl J , Fl Fl xz
  317. (c mode only)
  318. Compress the resulting archive with
  319. .Xr xz 1 .
  320. In extract or list modes, this option is ignored.
  321. Note that this
  322. .Nm tar
  323. implementation recognizes XZ compression automatically when reading archives.
  324. .It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
  325. (c mode only)
  326. Compress the resulting archive with
  327. .Xr bzip2 1 .
  328. In extract or list modes, this option is ignored.
  329. Note that this
  330. .Nm tar
  331. implementation recognizes bzip2 compression automatically when reading
  332. archives.
  333. .It Fl k , Fl Fl keep-old-files
  334. (x mode only)
  335. Do not overwrite existing files.
  336. In particular, if a file appears more than once in an archive,
  337. later copies will not overwrite earlier copies.
  338. .It Fl Fl keep-newer-files
  339. (x mode only)
  340. Do not overwrite existing files that are newer than the
  341. versions appearing in the archive being extracted.
  342. .It Fl L , Fl Fl dereference
  343. (c and r modes only)
  344. All symbolic links will be followed.
  345. Normally, symbolic links are archived as such.
  346. With this option, the target of the link will be archived instead.
  347. .It Fl l , Fl Fl check-links
  348. (c and r modes only)
  349. Issue a warning message unless all links to each file are archived.
  350. .It Fl Fl lrzip
  351. (c mode only)
  352. Compress the resulting archive with
  353. .Xr lrzip 1 .
  354. In extract or list modes, this option is ignored.
  355. Note that this
  356. .Nm tar
  357. implementation recognizes lrzip compression automatically when reading
  358. archives.
  359. .It Fl Fl lz4
  360. (c mode only)
  361. Compress the archive with lz4-compatible compression before writing it.
  362. In extract or list modes, this option is ignored.
  363. Note that this
  364. .Nm tar
  365. implementation recognizes lz4 compression automatically when reading archives.
  366. .It Fl Fl zstd
  367. (c mode only)
  368. Compress the archive with zstd-compatible compression before writing it.
  369. In extract or list modes, this option is ignored.
  370. Note that this
  371. .Nm tar
  372. implementation recognizes zstd compression automatically when reading archives.
  373. .It Fl Fl lzma
  374. (c mode only) Compress the resulting archive with the original LZMA algorithm.
  375. In extract or list modes, this option is ignored.
  376. Use of this option is discouraged and new archives should be created with
  377. .Fl Fl xz
  378. instead.
  379. Note that this
  380. .Nm tar
  381. implementation recognizes LZMA compression automatically when reading archives.
  382. .It Fl Fl lzop
  383. (c mode only)
  384. Compress the resulting archive with
  385. .Xr lzop 1 .
  386. In extract or list modes, this option is ignored.
  387. Note that this
  388. .Nm tar
  389. implementation recognizes LZO compression automatically when reading archives.
  390. .It Fl m , Fl Fl modification-time
  391. (x mode only)
  392. Do not extract modification time.
  393. By default, the modification time is set to the time stored in the archive.
  394. .It Fl Fl mac-metadata
  395. (c, r, u and x mode only)
  396. Mac OS X specific.
  397. Archive or extract extended ACLs and extended file
  398. attributes using
  399. .Xr copyfile 3
  400. in AppleDouble format.
  401. This is the reverse of
  402. .Fl Fl no-mac-metadata .
  403. and the default behavior in c, r, and u modes or if
  404. .Nm
  405. is run in x mode as root.
  406. .It Fl n , Fl Fl norecurse , Fl Fl no-recursion
  407. Do not operate recursively on the content of directories.
  408. .It Fl Fl newer Ar date
  409. (c, r, u modes only)
  410. Only include files and directories newer than the specified date.
  411. This compares ctime entries.
  412. .It Fl Fl newer-mtime Ar date
  413. (c, r, u modes only)
  414. Like
  415. .Fl Fl newer ,
  416. except it compares mtime entries instead of ctime entries.
  417. .It Fl Fl newer-than Pa file
  418. (c, r, u modes only)
  419. Only include files and directories newer than the specified file.
  420. This compares ctime entries.
  421. .It Fl Fl newer-mtime-than Pa file
  422. (c, r, u modes only)
  423. Like
  424. .Fl Fl newer-than ,
  425. except it compares mtime entries instead of ctime entries.
  426. .It Fl Fl nodump
  427. (c and r modes only)
  428. Honor the nodump file flag by skipping this file.
  429. .It Fl Fl nopreserveHFSCompression
  430. (x mode only)
  431. Mac OS X specific (v10.6 or later). Do not compress extracted regular files
  432. which were compressed with HFS+ compression before archived.
  433. By default, compress the regular files again with HFS+ compression.
  434. .It Fl Fl null
  435. (use with
  436. .Fl I
  437. or
  438. .Fl T )
  439. Filenames or patterns are separated by null characters,
  440. not by newlines.
  441. This is often used to read filenames output by the
  442. .Fl print0
  443. option to
  444. .Xr find 1 .
  445. .It Fl Fl no-acls
  446. (c, r, u, x modes only)
  447. Do not archive or extract POSIX.1e or NFSv4 ACLs.
  448. This is the reverse of
  449. .Fl Fl acls
  450. and the default behavior if
  451. .Nm
  452. is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
  453. .It Fl Fl no-fflags
  454. (c, r, u, x modes only)
  455. Do not archive or extract file attributes or file flags.
  456. This is the reverse of
  457. .Fl Fl fflags
  458. and the default behavior if
  459. .Nm
  460. is run as non-root in x mode.
  461. .It Fl Fl no-mac-metadata
  462. (x mode only)
  463. Mac OS X specific.
  464. Do not archive or extract ACLs and extended file attributes
  465. using
  466. .Xr copyfile 3
  467. in AppleDouble format.
  468. This is the reverse of
  469. .Fl Fl mac-metadata .
  470. and the default behavior if
  471. .Nm
  472. is run as non-root in x mode.
  473. .It Fl Fl no-read-sparse
  474. (c, r, u modes only)
  475. Do not read sparse file information from disk.
  476. This is the reverse of
  477. .Fl Fl read-sparse .
  478. .It Fl Fl no-safe-writes
  479. (x mode only)
  480. Do not create temporary files and use
  481. .Xr rename 2
  482. to replace the original ones.
  483. This is the reverse of
  484. .Fl Fl safe-writes .
  485. .It Fl Fl no-same-owner
  486. (x mode only)
  487. Do not extract owner and group IDs.
  488. This is the reverse of
  489. .Fl Fl same-owner
  490. and the default behavior if
  491. .Nm
  492. is run as non-root.
  493. .It Fl Fl no-same-permissions
  494. (x mode only)
  495. Do not extract full permissions (SGID, SUID, sticky bit,
  496. file attributes or file flags, extended file attributes and ACLs).
  497. This is the reverse of
  498. .Fl p
  499. and the default behavior if
  500. .Nm
  501. is run as non-root.
  502. .It Fl Fl no-xattrs
  503. (c, r, u, x modes only)
  504. Do not archive or extract extended file attributes.
  505. This is the reverse of
  506. .Fl Fl xattrs
  507. and the default behavior if
  508. .Nm
  509. is run as non-root in x mode.
  510. .It Fl Fl numeric-owner
  511. This is equivalent to
  512. .Fl Fl uname
  513. .Qq
  514. .Fl Fl gname
  515. .Qq .
  516. On extract, it causes user and group names in the archive
  517. to be ignored in favor of the numeric user and group ids.
  518. On create, it causes user and group names to not be stored
  519. in the archive.
  520. .It Fl O , Fl Fl to-stdout
  521. (x, t modes only)
  522. In extract (-x) mode, files will be written to standard out rather than
  523. being extracted to disk.
  524. In list (-t) mode, the file listing will be written to stderr rather than
  525. the usual stdout.
  526. .It Fl o
  527. (x mode)
  528. Use the user and group of the user running the program rather
  529. than those specified in the archive.
  530. Note that this has no significance unless
  531. .Fl p
  532. is specified, and the program is being run by the root user.
  533. In this case, the file modes and flags from
  534. the archive will be restored, but ACLs or owner information in
  535. the archive will be discarded.
  536. .It Fl o
  537. (c, r, u mode)
  538. A synonym for
  539. .Fl Fl format Ar ustar
  540. .It Fl Fl older Ar date
  541. (c, r, u modes only)
  542. Only include files and directories older than the specified date.
  543. This compares ctime entries.
  544. .It Fl Fl older-mtime Ar date
  545. (c, r, u modes only)
  546. Like
  547. .Fl Fl older ,
  548. except it compares mtime entries instead of ctime entries.
  549. .It Fl Fl older-than Pa file
  550. (c, r, u modes only)
  551. Only include files and directories older than the specified file.
  552. This compares ctime entries.
  553. .It Fl Fl older-mtime-than Pa file
  554. (c, r, u modes only)
  555. Like
  556. .Fl Fl older-than ,
  557. except it compares mtime entries instead of ctime entries.
  558. .It Fl Fl one-file-system
  559. (c, r, and u modes)
  560. Do not cross mount points.
  561. .It Fl Fl options Ar options
  562. Select optional behaviors for particular modules.
  563. The argument is a text string containing comma-separated
  564. keywords and values.
  565. These are passed to the modules that handle particular
  566. formats to control how those formats will behave.
  567. Each option has one of the following forms:
  568. .Bl -tag -compact -width indent
  569. .It Ar key=value
  570. The key will be set to the specified value in every module that supports it.
  571. Modules that do not support this key will ignore it.
  572. .It Ar key
  573. The key will be enabled in every module that supports it.
  574. This is equivalent to
  575. .Ar key Ns Cm =1 .
  576. .It Ar !key
  577. The key will be disabled in every module that supports it.
  578. .It Ar module:key=value , Ar module:key , Ar module:!key
  579. As above, but the corresponding key and value will be provided
  580. only to modules whose name matches
  581. .Ar module .
  582. .El
  583. .Pp
  584. The complete list of supported modules and keys
  585. for create and append modes is in
  586. .Xr archive_write_set_options 3
  587. and for extract and list modes in
  588. .Xr archive_read_set_options 3 .
  589. .Pp
  590. Examples of supported options:
  591. .Bl -tag -compact -width indent
  592. .It Cm iso9660:joliet
  593. Support Joliet extensions.
  594. This is enabled by default, use
  595. .Cm !joliet
  596. or
  597. .Cm iso9660:!joliet
  598. to disable.
  599. .It Cm iso9660:rockridge
  600. Support Rock Ridge extensions.
  601. This is enabled by default, use
  602. .Cm !rockridge
  603. or
  604. .Cm iso9660:!rockridge
  605. to disable.
  606. .It Cm gzip:compression-level
  607. A decimal integer from 1 to 9 specifying the gzip compression level.
  608. .It Cm gzip:timestamp
  609. Store timestamp.
  610. This is enabled by default, use
  611. .Cm !timestamp
  612. or
  613. .Cm gzip:!timestamp
  614. to disable.
  615. .It Cm lrzip:compression Ns = Ns Ar type
  616. Use
  617. .Ar type
  618. as compression method.
  619. Supported values are bzip2, gzip, lzo (ultra fast),
  620. and zpaq (best, extremely slow).
  621. .It Cm lrzip:compression-level
  622. A decimal integer from 1 to 9 specifying the lrzip compression level.
  623. .It Cm lz4:compression-level
  624. A decimal integer from 1 to 9 specifying the lzop compression level.
  625. .It Cm lz4:stream-checksum
  626. Enable stream checksum.
  627. This is by default, use
  628. .Cm lz4:!stream-checksum
  629. to disable.
  630. .It Cm lz4:block-checksum
  631. Enable block checksum (Disabled by default).
  632. .It Cm lz4:block-size
  633. A decimal integer from 4 to 7 specifying the lz4 compression block size
  634. (7 is set by default).
  635. .It Cm lz4:block-dependence
  636. Use the previous block of the block being compressed for
  637. a compression dictionary to improve compression ratio.
  638. .It Cm zstd:compression-level
  639. A decimal integer specifying the zstd compression level. Supported values depend
  640. on the library version, common values are from 1 to 22.
  641. .It Cm zstd:threads
  642. Specify the number of worker threads to use.
  643. Setting threads to a special value 0 makes
  644. .Xr zstd 1
  645. use as many threads as there are CPU cores on the system.
  646. .It Cm lzop:compression-level
  647. A decimal integer from 1 to 9 specifying the lzop compression level.
  648. .It Cm xz:compression-level
  649. A decimal integer from 0 to 9 specifying the xz compression level.
  650. .It Cm xz:threads
  651. Specify the number of worker threads to use.
  652. Setting threads to a special value 0 makes
  653. .Xr xz 1
  654. use as many threads as there are CPU cores on the system.
  655. .It Cm mtree: Ns Ar keyword
  656. The mtree writer module allows you to specify which mtree keywords
  657. will be included in the output.
  658. Supported keywords include:
  659. .Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
  660. .Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
  661. .Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
  662. The default is equivalent to:
  663. .Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
  664. .It Cm mtree:all
  665. Enables all of the above keywords.
  666. You can also use
  667. .Cm mtree:!all
  668. to disable all keywords.
  669. .It Cm mtree:use-set
  670. Enable generation of
  671. .Cm /set
  672. lines in the output.
  673. .It Cm mtree:indent
  674. Produce human-readable output by indenting options and splitting lines
  675. to fit into 80 columns.
  676. .It Cm zip:compression Ns = Ns Ar type
  677. Use
  678. .Ar type
  679. as compression method.
  680. Supported values are store (uncompressed) and deflate (gzip algorithm).
  681. .It Cm zip:encryption
  682. Enable encryption using traditional zip encryption.
  683. .It Cm zip:encryption Ns = Ns Ar type
  684. Use
  685. .Ar type
  686. as encryption type.
  687. Supported values are zipcrypt (traditional zip encryption),
  688. aes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
  689. .It Cm read_concatenated_archives
  690. Ignore zeroed blocks in the archive, which occurs when multiple tar archives
  691. have been concatenated together.
  692. Without this option, only the contents of
  693. the first concatenated archive would be read.
  694. This option is comparable to the
  695. .Fl i , Fl Fl ignore-zeros
  696. option of GNU tar.
  697. .El
  698. If a provided option is not supported by any module, that
  699. is a fatal error.
  700. .It Fl P , Fl Fl absolute-paths
  701. Preserve pathnames.
  702. By default, absolute pathnames (those that begin with a /
  703. character) have the leading slash removed both when creating archives
  704. and extracting from them.
  705. Also,
  706. .Nm
  707. will refuse to extract archive entries whose pathnames contain
  708. .Pa ..
  709. or whose target directory would be altered by a symlink.
  710. This option suppresses these behaviors.
  711. .It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
  712. (x mode only)
  713. Preserve file permissions.
  714. Attempt to restore the full permissions, including file modes, file attributes
  715. or file flags, extended file attributes and ACLs, if available, for each item
  716. extracted from the archive.
  717. This is the reverse of
  718. .Fl Fl no-same-permissions
  719. and the default if
  720. .Nm
  721. is being run as root.
  722. It can be partially overridden by also specifying
  723. .Fl Fl no-acls ,
  724. .Fl Fl no-fflags ,
  725. .Fl Fl no-mac-metadata
  726. or
  727. .Fl Fl no-xattrs .
  728. .It Fl Fl passphrase Ar passphrase
  729. The
  730. .Pa passphrase
  731. is used to extract or create an encrypted archive.
  732. Currently, zip is the only supported format that supports encryption.
  733. You shouldn't use this option unless you realize how insecure
  734. use of this option is.
  735. .It Fl Fl posix
  736. (c, r, u mode only)
  737. Synonym for
  738. .Fl Fl format Ar pax
  739. .It Fl q , Fl Fl fast-read
  740. (x and t mode only)
  741. Extract or list only the first archive entry that matches each pattern
  742. or filename operand.
  743. Exit as soon as each specified pattern or filename has been matched.
  744. By default, the archive is always read to the very end, since
  745. there can be multiple entries with the same name and, by convention,
  746. later entries overwrite earlier entries.
  747. This option is provided as a performance optimization.
  748. .It Fl Fl read-sparse
  749. (c, r, u modes only)
  750. Read sparse file information from disk.
  751. This is the reverse of
  752. .Fl Fl no-read-sparse
  753. and the default behavior.
  754. .It Fl S
  755. (x mode only)
  756. Extract files as sparse files.
  757. For every block on disk, check first if it contains only NULL bytes and seek
  758. over it otherwise.
  759. This works similar to the conv=sparse option of dd.
  760. .It Fl s Ar pattern
  761. Modify file or archive member names according to
  762. .Pa pattern .
  763. The pattern has the format
  764. .Ar /old/new/ Ns Op ghHprRsS
  765. where
  766. .Ar old
  767. is a basic regular expression,
  768. .Ar new
  769. is the replacement string of the matched part,
  770. and the optional trailing letters modify
  771. how the replacement is handled.
  772. If
  773. .Ar old
  774. is not matched, the pattern is skipped.
  775. Within
  776. .Ar new ,
  777. ~ is substituted with the match, \e1 to \e9 with the content of
  778. the corresponding captured group.
  779. The optional trailing g specifies that matching should continue
  780. after the matched part and stop on the first unmatched pattern.
  781. The optional trailing s specifies that the pattern applies to the value
  782. of symbolic links.
  783. The optional trailing p specifies that after a successful substitution
  784. the original path name and the new path name should be printed to
  785. standard error.
  786. Optional trailing H, R, or S characters suppress substitutions
  787. for hardlink targets, regular filenames, or symlink targets,
  788. respectively.
  789. Optional trailing h, r, or s characters enable substitutions
  790. for hardlink targets, regular filenames, or symlink targets,
  791. respectively.
  792. The default is
  793. .Ar hrs
  794. which applies substitutions to all names.
  795. In particular, it is never necessary to specify h, r, or s.
  796. .It Fl Fl safe-writes
  797. (x mode only)
  798. Extract files atomically.
  799. By default
  800. .Nm
  801. unlinks the original file with the same name as the extracted file (if it
  802. exists), and then creates it immediately under the same name and writes to
  803. it.
  804. For a short period of time, applications trying to access the file might
  805. not find it, or see incomplete results.
  806. If
  807. .Fl Fl safe-writes
  808. is enabled,
  809. .Nm
  810. first creates a unique temporary file, then writes the new contents to
  811. the temporary file, and finally renames the temporary file to its final
  812. name atomically using
  813. .Xr rename 2 .
  814. This guarantees that an application accessing the file, will either see
  815. the old contents or the new contents at all times.
  816. .It Fl Fl same-owner
  817. (x mode only)
  818. Extract owner and group IDs.
  819. This is the reverse of
  820. .Fl Fl no-same-owner
  821. and the default behavior if
  822. .Nm
  823. is run as root.
  824. .It Fl Fl strip-components Ar count
  825. Remove the specified number of leading path elements.
  826. Pathnames with fewer elements will be silently skipped.
  827. Note that the pathname is edited after checking inclusion/exclusion patterns
  828. but before security checks.
  829. .It Fl T Ar filename , Fl Fl files-from Ar filename
  830. In x or t mode,
  831. .Nm
  832. will read the list of names to be extracted from
  833. .Pa filename .
  834. In c mode,
  835. .Nm
  836. will read names to be archived from
  837. .Pa filename .
  838. The special name
  839. .Dq -C
  840. on a line by itself will cause the current directory to be changed to
  841. the directory specified on the following line.
  842. Names are terminated by newlines unless
  843. .Fl Fl null
  844. is specified.
  845. Note that
  846. .Fl Fl null
  847. also disables the special handling of lines containing
  848. .Dq -C .
  849. Note: If you are generating lists of files using
  850. .Xr find 1 ,
  851. you probably want to use
  852. .Fl n
  853. as well.
  854. .It Fl Fl totals
  855. (c, r, u modes only)
  856. After archiving all files, print a summary to stderr.
  857. .It Fl U , Fl Fl unlink , Fl Fl unlink-first
  858. (x mode only)
  859. Unlink files before creating them.
  860. This can be a minor performance optimization if most files
  861. already exist, but can make things slower if most files
  862. do not already exist.
  863. This flag also causes
  864. .Nm
  865. to remove intervening directory symlinks instead of
  866. reporting an error.
  867. See the SECURITY section below for more details.
  868. .It Fl Fl uid Ar id
  869. Use the provided user id number and ignore the user
  870. name from the archive.
  871. On create, if
  872. .Fl Fl uname
  873. is not also specified, the user name will be set to
  874. match the user id.
  875. .It Fl Fl uname Ar name
  876. Use the provided user name.
  877. On extract, this overrides the user name in the archive;
  878. if the provided user name does not exist on the system,
  879. it will be ignored and the user id
  880. (from the archive or from the
  881. .Fl Fl uid
  882. option)
  883. will be used instead.
  884. On create, this sets the user name that will be stored
  885. in the archive;
  886. the name is not verified against the system user database.
  887. .It Fl Fl use-compress-program Ar program
  888. Pipe the input (in x or t mode) or the output (in c mode) through
  889. .Pa program
  890. instead of using the builtin compression support.
  891. .It Fl v , Fl Fl verbose
  892. Produce verbose output.
  893. In create and extract modes,
  894. .Nm
  895. will list each file name as it is read from or written to
  896. the archive.
  897. In list mode,
  898. .Nm
  899. will produce output similar to that of
  900. .Xr ls 1 .
  901. An additional
  902. .Fl v
  903. option will also provide ls-like details in create and extract mode.
  904. .It Fl Fl version
  905. Print version of
  906. .Nm
  907. and
  908. .Nm libarchive ,
  909. and exit.
  910. .It Fl w , Fl Fl confirmation , Fl Fl interactive
  911. Ask for confirmation for every action.
  912. .It Fl X Ar filename , Fl Fl exclude-from Ar filename
  913. Read a list of exclusion patterns from the specified file.
  914. See
  915. .Fl Fl exclude
  916. for more information about the handling of exclusions.
  917. .It Fl Fl xattrs
  918. (c, r, u, x modes only)
  919. Archive or extract extended file attributes.
  920. This is the reverse of
  921. .Fl Fl no-xattrs
  922. and the default behavior in c, r, and u modes or if
  923. .Nm
  924. is run in x mode as root.
  925. .It Fl y
  926. (c mode only)
  927. Compress the resulting archive with
  928. .Xr bzip2 1 .
  929. In extract or list modes, this option is ignored.
  930. Note that this
  931. .Nm tar
  932. implementation recognizes bzip2 compression automatically when reading
  933. archives.
  934. .It Fl Z , Fl Fl compress , Fl Fl uncompress
  935. (c mode only)
  936. Compress the resulting archive with
  937. .Xr compress 1 .
  938. In extract or list modes, this option is ignored.
  939. Note that this
  940. .Nm tar
  941. implementation recognizes compress compression automatically when reading
  942. archives.
  943. .It Fl z , Fl Fl gunzip , Fl Fl gzip
  944. (c mode only)
  945. Compress the resulting archive with
  946. .Xr gzip 1 .
  947. In extract or list modes, this option is ignored.
  948. Note that this
  949. .Nm tar
  950. implementation recognizes gzip compression automatically when reading
  951. archives.
  952. .El
  953. .Sh ENVIRONMENT
  954. The following environment variables affect the execution of
  955. .Nm :
  956. .Bl -tag -width indent
  957. .It Ev TAR_READER_OPTIONS
  958. The default options for format readers and compression readers.
  959. The
  960. .Fl Fl options
  961. option overrides this.
  962. .It Ev TAR_WRITER_OPTIONS
  963. The default options for format writers and compression writers.
  964. The
  965. .Fl Fl options
  966. option overrides this.
  967. .It Ev LANG
  968. The locale to use.
  969. See
  970. .Xr environ 7
  971. for more information.
  972. .It Ev TAPE
  973. The default device.
  974. The
  975. .Fl f
  976. option overrides this.
  977. Please see the description of the
  978. .Fl f
  979. option above for more details.
  980. .It Ev TZ
  981. The timezone to use when displaying dates.
  982. See
  983. .Xr environ 7
  984. for more information.
  985. .El
  986. .Sh EXIT STATUS
  987. .Ex -std
  988. .Sh EXAMPLES
  989. The following creates a new archive
  990. called
  991. .Ar file.tar.gz
  992. that contains two files
  993. .Ar source.c
  994. and
  995. .Ar source.h :
  996. .Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
  997. .Pp
  998. To view a detailed table of contents for this
  999. archive:
  1000. .Dl Nm Fl tvf Pa file.tar.gz
  1001. .Pp
  1002. To extract all entries from the archive on
  1003. the default tape drive:
  1004. .Dl Nm Fl x
  1005. .Pp
  1006. To examine the contents of an ISO 9660 cdrom image:
  1007. .Dl Nm Fl tf Pa image.iso
  1008. .Pp
  1009. To move file hierarchies, invoke
  1010. .Nm
  1011. as
  1012. .Dl Nm Fl cf Pa - Fl C Pa srcdir \&. | Nm Fl xpf Pa - Fl C Pa destdir
  1013. or more traditionally
  1014. .Dl cd srcdir \&; Nm Fl cf Pa - \&. | ( cd destdir \&; Nm Fl xpf Pa - )
  1015. .Pp
  1016. In create mode, the list of files and directories to be archived
  1017. can also include directory change instructions of the form
  1018. .Cm -C Ns Pa foo/baz
  1019. and archive inclusions of the form
  1020. .Cm @ Ns Pa archive-file .
  1021. For example, the command line
  1022. .Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
  1023. will create a new archive
  1024. .Pa new.tar .
  1025. .Nm
  1026. will read the file
  1027. .Pa foo1
  1028. from the current directory and add it to the output archive.
  1029. It will then read each entry from
  1030. .Pa old.tgz
  1031. and add those entries to the output archive.
  1032. Finally, it will switch to the
  1033. .Pa /tmp
  1034. directory and add
  1035. .Pa foo2
  1036. to the output archive.
  1037. .Pp
  1038. An input file in
  1039. .Xr mtree 5
  1040. format can be used to create an output archive with arbitrary ownership,
  1041. permissions, or names that differ from existing data on disk:
  1042. .Bd -literal -offset indent
  1043. $ cat input.mtree
  1044. #mtree
  1045. usr/bin uid=0 gid=0 mode=0755 type=dir
  1046. usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
  1047. $ tar -cvf output.tar @input.mtree
  1048. .Ed
  1049. .Pp
  1050. The
  1051. .Fl Fl newer
  1052. and
  1053. .Fl Fl newer-mtime
  1054. switches accept a variety of common date and time specifications, including
  1055. .Dq 12 Mar 2005 7:14:29pm ,
  1056. .Dq 2005-03-12 19:14 ,
  1057. .Dq 5 minutes ago ,
  1058. and
  1059. .Dq 19:14 PST May 1 .
  1060. .Pp
  1061. The
  1062. .Fl Fl options
  1063. argument can be used to control various details of archive generation
  1064. or reading.
  1065. For example, you can generate mtree output which only contains
  1066. .Cm type , Cm time ,
  1067. and
  1068. .Cm uid
  1069. keywords:
  1070. .Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
  1071. or you can set the compression level used by gzip or xz compression:
  1072. .Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
  1073. For more details, see the explanation of the
  1074. .Fn archive_read_set_options
  1075. and
  1076. .Fn archive_write_set_options
  1077. API calls that are described in
  1078. .Xr archive_read 3
  1079. and
  1080. .Xr archive_write 3 .
  1081. .Sh COMPATIBILITY
  1082. The bundled-arguments format is supported for compatibility
  1083. with historic implementations.
  1084. It consists of an initial word (with no leading - character) in which
  1085. each character indicates an option.
  1086. Arguments follow as separate words.
  1087. The order of the arguments must match the order
  1088. of the corresponding characters in the bundled command word.
  1089. For example,
  1090. .Dl Nm Cm tbf 32 Pa file.tar
  1091. specifies three flags
  1092. .Cm t ,
  1093. .Cm b ,
  1094. and
  1095. .Cm f .
  1096. The
  1097. .Cm b
  1098. and
  1099. .Cm f
  1100. flags both require arguments,
  1101. so there must be two additional items
  1102. on the command line.
  1103. The
  1104. .Ar 32
  1105. is the argument to the
  1106. .Cm b
  1107. flag, and
  1108. .Ar file.tar
  1109. is the argument to the
  1110. .Cm f
  1111. flag.
  1112. .Pp
  1113. The mode options c, r, t, u, and x and the options
  1114. b, f, l, m, o, v, and w comply with SUSv2.
  1115. .Pp
  1116. For maximum portability, scripts that invoke
  1117. .Nm tar
  1118. should use the bundled-argument format above, should limit
  1119. themselves to the
  1120. .Cm c ,
  1121. .Cm t ,
  1122. and
  1123. .Cm x
  1124. modes, and the
  1125. .Cm b ,
  1126. .Cm f ,
  1127. .Cm m ,
  1128. .Cm v ,
  1129. and
  1130. .Cm w
  1131. options.
  1132. .Pp
  1133. Additional long options are provided to improve compatibility with other
  1134. tar implementations.
  1135. .Sh SECURITY
  1136. Certain security issues are common to many archiving programs, including
  1137. .Nm .
  1138. In particular, carefully-crafted archives can request that
  1139. .Nm
  1140. extract files to locations outside of the target directory.
  1141. This can potentially be used to cause unwitting users to overwrite
  1142. files they did not intend to overwrite.
  1143. If the archive is being extracted by the superuser, any file
  1144. on the system can potentially be overwritten.
  1145. There are three ways this can happen.
  1146. Although
  1147. .Nm
  1148. has mechanisms to protect against each one,
  1149. savvy users should be aware of the implications:
  1150. .Bl -bullet -width indent
  1151. .It
  1152. Archive entries can have absolute pathnames.
  1153. By default,
  1154. .Nm
  1155. removes the leading
  1156. .Pa /
  1157. character from filenames before restoring them to guard against this problem.
  1158. .It
  1159. Archive entries can have pathnames that include
  1160. .Pa ..
  1161. components.
  1162. By default,
  1163. .Nm
  1164. will not extract files containing
  1165. .Pa ..
  1166. components in their pathname.
  1167. .It
  1168. Archive entries can exploit symbolic links to restore
  1169. files to other directories.
  1170. An archive can restore a symbolic link to another directory,
  1171. then use that link to restore a file into that directory.
  1172. To guard against this,
  1173. .Nm
  1174. checks each extracted path for symlinks.
  1175. If the final path element is a symlink, it will be removed
  1176. and replaced with the archive entry.
  1177. If
  1178. .Fl U
  1179. is specified, any intermediate symlink will also be unconditionally removed.
  1180. If neither
  1181. .Fl U
  1182. nor
  1183. .Fl P
  1184. is specified,
  1185. .Nm
  1186. will refuse to extract the entry.
  1187. .El
  1188. To protect yourself, you should be wary of any archives that
  1189. come from untrusted sources.
  1190. You should examine the contents of an archive with
  1191. .Dl Nm Fl tf Pa filename
  1192. before extraction.
  1193. You should use the
  1194. .Fl k
  1195. option to ensure that
  1196. .Nm
  1197. will not overwrite any existing files or the
  1198. .Fl U
  1199. option to remove any pre-existing files.
  1200. You should generally not extract archives while running with super-user
  1201. privileges.
  1202. Note that the
  1203. .Fl P
  1204. option to
  1205. .Nm
  1206. disables the security checks above and allows you to extract
  1207. an archive while preserving any absolute pathnames,
  1208. .Pa ..
  1209. components, or symlinks to other directories.
  1210. .Sh SEE ALSO
  1211. .Xr bzip2 1 ,
  1212. .Xr compress 1 ,
  1213. .Xr cpio 1 ,
  1214. .Xr gzip 1 ,
  1215. .Xr mt 1 ,
  1216. .Xr pax 1 ,
  1217. .Xr shar 1 ,
  1218. .Xr xz 1 ,
  1219. .Xr libarchive 3 ,
  1220. .Xr libarchive-formats 5 ,
  1221. .Xr tar 5
  1222. .Sh STANDARDS
  1223. There is no current POSIX standard for the tar command; it appeared
  1224. in
  1225. .St -p1003.1-96
  1226. but was dropped from
  1227. .St -p1003.1-2001 .
  1228. The options supported by this implementation were developed by surveying a
  1229. number of existing tar implementations as well as the old POSIX specification
  1230. for tar and the current POSIX specification for pax.
  1231. .Pp
  1232. The ustar and pax interchange file formats are defined by
  1233. .St -p1003.1-2001
  1234. for the pax command.
  1235. .Sh HISTORY
  1236. A
  1237. .Nm tar
  1238. command appeared in Seventh Edition Unix, which was released in January, 1979.
  1239. There have been numerous other implementations,
  1240. many of which extended the file format.
  1241. John Gilmore's
  1242. .Nm pdtar
  1243. public-domain implementation (circa November, 1987)
  1244. was quite influential, and formed the basis of GNU tar.
  1245. GNU tar was included as the standard system tar
  1246. in
  1247. .Fx
  1248. beginning with
  1249. .Fx 1.0 .
  1250. .Pp
  1251. This is a complete re-implementation based on the
  1252. .Xr libarchive 3
  1253. library.
  1254. It was first released with
  1255. .Fx 5.4
  1256. in May, 2005.
  1257. .Sh BUGS
  1258. This program follows
  1259. .St -p1003.1-96
  1260. for the definition of the
  1261. .Fl l
  1262. option.
  1263. Note that GNU tar prior to version 1.15 treated
  1264. .Fl l
  1265. as a synonym for the
  1266. .Fl Fl one-file-system
  1267. option.
  1268. .Pp
  1269. The
  1270. .Fl C Pa dir
  1271. option may differ from historic implementations.
  1272. .Pp
  1273. All archive output is written in correctly-sized blocks, even
  1274. if the output is being compressed.
  1275. Whether or not the last output block is padded to a full
  1276. block size varies depending on the format and the
  1277. output device.
  1278. For tar and cpio formats, the last block of output is padded
  1279. to a full block size if the output is being
  1280. written to standard output or to a character or block device such as
  1281. a tape drive.
  1282. If the output is being written to a regular file, the last block
  1283. will not be padded.
  1284. Many compressors, including
  1285. .Xr gzip 1
  1286. and
  1287. .Xr bzip2 1 ,
  1288. complain about the null padding when decompressing an archive created by
  1289. .Nm ,
  1290. although they still extract it correctly.
  1291. .Pp
  1292. The compression and decompression is implemented internally, so
  1293. there may be insignificant differences between the compressed output
  1294. generated by
  1295. .Dl Nm Fl czf Pa - file
  1296. and that generated by
  1297. .Dl Nm Fl cf Pa - file | Nm gzip
  1298. .Pp
  1299. The default should be to read and write archives to the standard I/O paths,
  1300. but tradition (and POSIX) dictates otherwise.
  1301. .Pp
  1302. The
  1303. .Cm r
  1304. and
  1305. .Cm u
  1306. modes require that the archive be uncompressed
  1307. and located in a regular file on disk.
  1308. Other archives can be modified using
  1309. .Cm c
  1310. mode with the
  1311. .Pa @archive-file
  1312. extension.
  1313. .Pp
  1314. To archive a file called
  1315. .Pa @foo
  1316. or
  1317. .Pa -foo
  1318. you must specify it as
  1319. .Pa ./@foo
  1320. or
  1321. .Pa ./-foo ,
  1322. respectively.
  1323. .Pp
  1324. In create mode, a leading
  1325. .Pa ./
  1326. is always removed.
  1327. A leading
  1328. .Pa /
  1329. is stripped unless the
  1330. .Fl P
  1331. option is specified.
  1332. .Pp
  1333. There needs to be better support for file selection on both create
  1334. and extract.
  1335. .Pp
  1336. There is not yet any support for multi-volume archives.
  1337. .Pp
  1338. Converting between dissimilar archive formats (such as tar and cpio) using the
  1339. .Cm @ Ns Pa -
  1340. convention can cause hard link information to be lost.
  1341. (This is a consequence of the incompatible ways that different archive
  1342. formats store hardlink information.)