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