bsdtar.1 40 KB

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