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