ManPageBsdtar1.wiki 42 KB

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