1 <!-- Creator : groff version 1.22.3 -->
2 <!-- CreationDate: Sun Feb 19 09:11:20 2017 -->
3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
4 "http://www.w3.org/TR/html4/loose.dtd">
7 <meta name="generator" content="groff -Thtml, see www.gnu.org">
8 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
9 <meta name="Content-Style" content="text/css">
10 <style type="text/css">
11 p { margin-top: 0; margin-bottom: 0; vertical-align: top }
12 pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
13 table { margin-top: 0; margin-bottom: 0; vertical-align: top }
14 h1 { text-align: center }
23 <p>TAR(1) BSD General Commands Manual TAR(1)</p>
25 <p style="margin-top: 1em"><b>NAME</b></p>
27 <p style="margin-left:6%;"><b>tar</b> — manipulate
30 <p style="margin-top: 1em"><b>SYNOPSIS</b></p>
32 <p style="margin-left:12%;"><b>tar</b>
33 [<i>bundled-flags </i>⟨</p>
35 <p>args ⟩ ] [⟨ <i><br>
36 file</i> ⟩ | ⟨ <i><br>
37 pattern</i> ⟩ ...]</p>
39 <p style="margin-left:12%;"><b>tar</b> {<b>-c</b>}
41 [<i>files </i>| <i>directories</i>] <b><br>
42 tar</b> {<b>-r </b>| <b>-u</b>} <b>-f</b>
43 <i>archive-file</i> [<i>options</i>]
44 [<i>files </i>| <i>directories</i>] <b><br>
45 tar</b> {<b>-t </b>| <b>-x</b>} [<i>options</i>]
48 <p style="margin-top: 1em"><b>DESCRIPTION</b></p>
50 <p style="margin-left:6%;"><b>tar</b> creates and
51 manipulates streaming archive files. This implementation can
52 extract from tar, pax, cpio, zip, jar, ar, xar, rpm, 7-zip,
53 and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
54 zip, 7-zip, and shar archives.</p>
56 <p style="margin-left:6%; margin-top: 1em">The first
57 synopsis form shows a ’’bundled’’
58 option word. This usage is provided for compatibility with
59 historical implementations. See COMPATIBILITY below for
62 <p style="margin-left:6%; margin-top: 1em">The other
63 synopsis forms show the preferred usage. The first option to
64 <b>tar</b> is a mode indicator from the following list:</p>
68 <p style="margin-left:17%; margin-top: 1em">Create a new
69 archive containing the specified items. The long option form
70 is <b>--create</b>.</p>
74 <p style="margin-left:17%; margin-top: 1em">Like <b>-c</b>,
75 but new entries are appended to the archive. Note that this
76 only works on uncompressed archives stored in regular files.
77 The <b>-f</b> option is required. The long option form is
82 <p style="margin-left:17%; margin-top: 1em">List archive
83 contents to stdout. The long option form is
88 <p style="margin-left:17%; margin-top: 1em">Like <b>-r</b>,
89 but new entries are added only if they have a modification
90 date newer than the corresponding entry in the archive. Note
91 that this only works on uncompressed archives stored in
92 regular files. The <b>-f</b> option is required. The long
93 form is <b>--update</b>.</p>
97 <p style="margin-left:17%; margin-top: 1em">Extract to disk
98 from the archive. If a file with the same name appears more
99 than once in the archive, each copy will be extracted, with
100 later copies overwriting (replacing) earlier copies. The
101 long option form is <b>--extract</b>.</p>
103 <p style="margin-left:6%; margin-top: 1em">In <b>-c</b>,
104 <b>-r</b>, or <b>-u</b> mode, each specified file or
105 directory is added to the archive in the order specified on
106 the command line. By default, the contents of each directory
107 are also archived.</p>
109 <p style="margin-left:6%; margin-top: 1em">In extract or
110 list mode, the entire command line is read and parsed before
111 the archive is opened. The pathnames or patterns on the
112 command line indicate which items in the archive should be
113 processed. Patterns are shell-style globbing patterns as
114 documented in tcsh(1).</p>
116 <p style="margin-top: 1em"><b>OPTIONS</b></p>
118 <p style="margin-left:6%;">Unless specifically stated
119 otherwise, options are applicable in all operating
122 <p style="margin-top: 1em"><b>@</b><i>archive</i></p>
124 <p style="margin-left:17%;">(c and r mode only) The
125 specified archive is opened and the entries in it will be
126 appended to the current archive. As a simple example,</p>
128 <p style="margin-left:24%;"><b>tar -c -f</b> <i>-
129 newfile</i> <b>@</b><i>original.tar</i></p>
131 <p style="margin-left:17%;">writes a new archive to
132 standard output containing a file <i>newfile</i> and all of
133 the entries from <i>original.tar</i>. In contrast,</p>
135 <p style="margin-left:24%;"><b>tar -c -f</b> <i>- newfile
138 <p style="margin-left:17%;">creates a new archive with only
139 two entries. Similarly,</p>
141 <p style="margin-left:24%;"><b>tar -czf</b> <i>-</i>
142 <b>--format pax @</b><i>-</i></p>
144 <p style="margin-left:17%;">reads an archive from standard
145 input (whose format will be determined automatically) and
146 converts it into a gzip-compressed pax-format archive on
147 stdout. In this way, <b>tar</b> can be used to convert
148 archives from one format to another.</p>
150 <p style="margin-top: 1em"><b>-a</b>,
151 <b>--auto-compress</b></p>
153 <p style="margin-left:17%;">(c mode only) Use the archive
154 suffix to decide a set of the format and the compressions.
155 As a simple example,</p>
157 <p style="margin-left:24%;"><b>tar -a -cf</b>
158 <i>archive.tgz source.c source.h</i></p>
160 <p style="margin-left:17%;">creates a new archive with
161 restricted pax format and gzip compression,</p>
163 <p style="margin-left:24%;"><b>tar -a -cf</b>
164 <i>archive.tar.bz2.uu source.c source.h</i></p>
166 <p style="margin-left:17%;">creates a new archive with
167 restricted pax format and bzip2 compression and uuencode
170 <p style="margin-left:24%;"><b>tar -a -cf</b>
171 <i>archive.zip source.c source.h</i></p>
173 <p style="margin-left:17%;">creates a new archive with zip
176 <p style="margin-left:24%;"><b>tar -a -jcf</b>
177 <i>archive.tgz source.c source.h</i></p>
179 <p style="margin-left:17%;">ignores the
180 ’’-j’’ option, and creates a new
181 archive with restricted pax format and gzip compression,</p>
183 <p style="margin-left:24%;"><b>tar -a -jcf</b>
184 <i>archive.xxx source.c source.h</i></p>
186 <p style="margin-left:17%;">if it is unknown suffix or no
187 suffix, creates a new archive with restricted pax format and
188 bzip2 compression.</p>
190 <p style="margin-top: 1em"><b>-B</b>,
191 <b>--read-full-blocks</b></p>
193 <p style="margin-left:17%;">Ignored for compatibility with
194 other tar(1) implementations.</p>
196 <p style="margin-top: 1em"><b>-b</b> <i>blocksize</i>,
197 <b>--block-size</b> <i>blocksize</i></p>
199 <p style="margin-left:17%;">Specify the block size, in
200 512-byte records, for tape drive I/O. As a rule, this
201 argument is only needed when reading from or writing to tape
202 drives, and usually not even then as the default block size
203 of 20 records (10240 bytes) is very common.</p>
205 <p style="margin-top: 1em"><b>-C</b> <i>directory</i>,
206 <b>--cd</b> <i>directory</i>, <b>--directory</b>
209 <p style="margin-left:17%;">In c and r mode, this changes
210 the directory before adding the following files. In x mode,
211 change directories after opening the archive but before
212 extracting entries from the archive.</p>
214 <p style="margin-top: 1em"><b>--chroot</b></p>
216 <p style="margin-left:17%;">(x mode only) <b>chroot</b>()
217 to the current directory after processing any <b>-C</b>
218 options and before extracting any files.</p>
221 <p style="margin-top: 1em"><b>--clear-nochange-fflags</b></p>
223 <p style="margin-left:17%;">(x mode only) Before removing
224 file system objects to replace them, clear platform-specific
225 file flags that might prevent removal.</p>
227 <p style="margin-top: 1em"><b>--disable-copyfile</b></p>
229 <p style="margin-left:17%;">Mac OS X specific. Disable the
230 use of copyfile(3).</p>
232 <p style="margin-top: 1em"><b>--exclude</b>
235 <p style="margin-left:17%;">Do not process files or
236 directories that match the specified pattern. Note that
237 exclusions take precedence over patterns or filenames
238 specified on the command line.</p>
240 <p style="margin-top: 1em"><b>--format</b>
243 <p style="margin-left:17%;">(c, r, u mode only) Use the
244 specified format for the created archive. Supported formats
245 include ’’cpio’’,
246 ’’pax’’,
247 ’’shar’’, and
248 ’’ustar’’. Other formats may also be
249 supported; see libarchive-formats(5) for more information
250 about currently-supported formats. In r and u modes, when
251 extending an existing archive, the format specified here
252 must be compatible with the format of the existing archive
255 <p style="margin-top: 1em"><b>-f</b> <i>file</i>,
256 <b>--file</b> <i>file</i></p>
258 <p style="margin-left:17%;">Read the archive from or write
259 the archive to the specified file. The filename can be
260 <i>-</i> for standard input or standard output. The default
261 varies by system; on FreeBSD, the default is
262 <i>/dev/sa0</i>; on Linux, the default is
265 <p style="margin-top: 1em"><b>--gid</b> <i>id</i></p>
267 <p style="margin-left:17%;">Use the provided group id
268 number. On extract, this overrides the group id in the
269 archive; the group name in the archive will be ignored. On
270 create, this overrides the group id read from disk; if
271 <b>--gname</b> is not also specified, the group name will be
272 set to match the group id.</p>
274 <p style="margin-top: 1em"><b>--gname</b> <i>name</i></p>
276 <p style="margin-left:17%;">Use the provided group name. On
277 extract, this overrides the group name in the archive; if
278 the provided group name does not exist on the system, the
279 group id (from the archive or from the <b>--gid</b> option)
280 will be used instead. On create, this sets the group name
281 that will be stored in the archive; the name will not be
282 verified against the system group database.</p>
284 <p style="margin-top: 1em"><b>-H</b></p>
286 <p style="margin-left:17%; margin-top: 1em">(c and r mode
287 only) Symbolic links named on the command line will be
288 followed; the target of the link will be archived, not the
291 <p style="margin-top: 1em"><b>-h</b></p>
293 <p style="margin-left:17%; margin-top: 1em">(c and r mode
294 only) Synonym for <b>-L</b>.</p>
296 <p style="margin-top: 1em"><b>-I</b></p>
298 <p style="margin-left:17%; margin-top: 1em">Synonym for
301 <p style="margin-top: 1em"><b>--help</b></p>
303 <p style="margin-left:17%; margin-top: 1em">Show usage.</p>
305 <p style="margin-top: 1em"><b>--hfsCompression</b></p>
307 <p style="margin-left:17%;">(x mode only) Mac OS X
308 specific(v10.6 or later). Compress extracted regular files
309 with HFS+ compression.</p>
311 <p style="margin-top: 1em"><b>--ignore-zeros</b></p>
313 <p style="margin-left:17%;">An alias of <b>--options
314 read_concatenated_archives</b> for compatibility with GNU
317 <p style="margin-top: 1em"><b>--include</b>
320 <p style="margin-left:17%;">Process only files or
321 directories that match the specified pattern. Note that
322 exclusions specified with <b>--exclude</b> take precedence
323 over inclusions. If no inclusions are explicitly specified,
324 all entries are processed by default. The <b>--include</b>
325 option is especially useful when filtering archives. For
326 example, the command</p>
328 <p style="margin-left:24%;"><b>tar -c -f</b> <i>new.tar</i>
329 <b>--include=’*foo*’ @</b><i>old.tgz</i></p>
331 <p style="margin-left:17%;">creates a new archive
332 <i>new.tar</i> containing only the entries from
333 <i>old.tgz</i> containing the string ’foo’.</p>
335 <p style="margin-top: 1em"><b>-J</b>, <b>--xz</b></p>
337 <p style="margin-left:17%;">(c mode only) Compress the
338 resulting archive with xz(1). In extract or list modes, this
339 option is ignored. Note that, unlike other <b>tar</b>
340 implementations, this implementation recognizes XZ
341 compression automatically when reading archives.</p>
343 <p style="margin-top: 1em"><b>-j</b>, <b>--bzip</b>,
344 <b>--bzip2</b>, <b>--bunzip2</b></p>
346 <p style="margin-left:17%;">(c mode only) Compress the
347 resulting archive with bzip2(1). In extract or list modes,
348 this option is ignored. Note that, unlike other <b>tar</b>
349 implementations, this implementation recognizes bzip2
350 compression automatically when reading archives.</p>
352 <p style="margin-top: 1em"><b>-k</b>,
353 <b>--keep-old-files</b></p>
355 <p style="margin-left:17%;">(x mode only) Do not overwrite
356 existing files. In particular, if a file appears more than
357 once in an archive, later copies will not overwrite earlier
360 <p style="margin-top: 1em"><b>--keep-newer-files</b></p>
362 <p style="margin-left:17%;">(x mode only) Do not overwrite
363 existing files that are newer than the versions appearing in
364 the archive being extracted.</p>
366 <p style="margin-top: 1em"><b>-L</b>,
367 <b>--dereference</b></p>
369 <p style="margin-left:17%;">(c and r mode only) All
370 symbolic links will be followed. Normally, symbolic links
371 are archived as such. With this option, the target of the
372 link will be archived instead.</p>
374 <p style="margin-top: 1em"><b>-l</b>,
375 <b>--check-links</b></p>
377 <p style="margin-left:17%;">(c and r modes only) Issue a
378 warning message unless all links to each file are
381 <p style="margin-top: 1em"><b>--lrzip</b></p>
383 <p style="margin-left:17%;">(c mode only) Compress the
384 resulting archive with lrzip(1). In extract or list modes,
385 this option is ignored.</p>
387 <p style="margin-top: 1em"><b>--lz4</b></p>
389 <p style="margin-left:17%; margin-top: 1em">(c mode only)
390 Compress the archive with lz4-compatible compression before
391 writing it. In input mode, this option is ignored; lz4
392 compression is recognized automatically on input.</p>
394 <p style="margin-top: 1em"><b>--lzma</b></p>
396 <p style="margin-left:17%; margin-top: 1em">(c mode only)
397 Compress the resulting archive with the original LZMA
398 algorithm. Use of this option is discouraged and new
399 archives should be created with <b>--xz</b> instead. Note
400 that, unlike other <b>tar</b> implementations, this
401 implementation recognizes LZMA compression automatically
402 when reading archives.</p>
404 <p style="margin-top: 1em"><b>--lzop</b></p>
406 <p style="margin-left:17%; margin-top: 1em">(c mode only)
407 Compress the resulting archive with lzop(1). In extract or
408 list modes, this option is ignored.</p>
410 <p style="margin-top: 1em"><b>-m</b>,
411 <b>--modification-time</b></p>
413 <p style="margin-left:17%;">(x mode only) Do not extract
414 modification time. By default, the modification time is set
415 to the time stored in the archive.</p>
417 <p style="margin-top: 1em"><b>-n</b>, <b>--norecurse</b>,
418 <b>--no-recursion</b></p>
420 <p style="margin-left:17%;">(c, r, u modes only) Do not
421 recursively archive the contents of directories.</p>
423 <p style="margin-top: 1em"><b>--newer</b> <i>date</i></p>
425 <p style="margin-left:17%;">(c, r, u modes only) Only
426 include files and directories newer than the specified date.
427 This compares ctime entries.</p>
429 <p style="margin-top: 1em"><b>--newer-mtime</b>
432 <p style="margin-left:17%;">(c, r, u modes only) Like
433 <b>--newer</b>, except it compares mtime entries instead of
436 <p style="margin-top: 1em"><b>--newer-than</b>
439 <p style="margin-left:17%;">(c, r, u modes only) Only
440 include files and directories newer than the specified file.
441 This compares ctime entries.</p>
443 <p style="margin-top: 1em"><b>--newer-mtime-than</b>
446 <p style="margin-left:17%;">(c, r, u modes only) Like
447 <b>--newer-than</b>, except it compares mtime entries
448 instead of ctime entries.</p>
450 <p style="margin-top: 1em"><b>--nodump</b></p>
452 <p style="margin-left:17%;">(c and r modes only) Honor the
453 nodump file flag by skipping this file.</p>
456 <p style="margin-top: 1em"><b>--nopreserveHFSCompression</b></p>
458 <p style="margin-left:17%;">(x mode only) Mac OS X
459 specific(v10.6 or later). Do not compress extracted regular
460 files which were compressed with HFS+ compression before
461 archived. By default, compress the regular files again with
462 HFS+ compression.</p>
464 <p style="margin-top: 1em"><b>--null</b></p>
466 <p style="margin-left:17%; margin-top: 1em">(use with
467 <b>-I</b> or <b>-T</b>) Filenames or patterns are separated
468 by null characters, not by newlines. This is often used to
469 read filenames output by the <b>-print0</b> option to
472 <p style="margin-top: 1em"><b>--no-same-owner</b></p>
474 <p style="margin-left:17%;">(x mode only) Do not extract
475 owner and group IDs. This is the reverse of
476 <b>--same-owner</b> and the default behavior if <b>tar</b>
477 is run as non-root.</p>
480 <p style="margin-top: 1em"><b>--no-same-permissions</b></p>
482 <p style="margin-left:17%;">(x mode only) Do not extract
483 full permissions (SGID, SUID, sticky bit, ACLs, extended
484 attributes or extended file flags). This is the reverse of
485 <b>-p</b> and the default behavior if <b>tar</b> is run as
488 <p style="margin-top: 1em"><b>--numeric-owner</b></p>
490 <p style="margin-left:17%;">This is equivalent to
491 <b>--uname</b> "" <b>--gname</b> "". On
492 extract, it causes user and group names in the archive to be
493 ignored in favor of the numeric user and group ids. On
494 create, it causes user and group names to not be stored in
497 <p style="margin-top: 1em"><b>-O</b>,
498 <b>--to-stdout</b></p>
500 <p style="margin-left:17%;">(x, t modes only) In extract
501 (-x) mode, files will be written to standard out rather than
502 being extracted to disk. In list (-t) mode, the file listing
503 will be written to stderr rather than the usual stdout.</p>
505 <p style="margin-top: 1em"><b>-o</b></p>
507 <p style="margin-left:17%; margin-top: 1em">(x mode) Use
508 the user and group of the user running the program rather
509 than those specified in the archive. Note that this has no
510 significance unless <b>-p</b> is specified, and the program
511 is being run by the root user. In this case, the file modes
512 and flags from the archive will be restored, but ACLs or
513 owner information in the archive will be discarded.</p>
515 <p style="margin-top: 1em"><b>-o</b></p>
517 <p style="margin-left:17%; margin-top: 1em">(c, r, u mode)
518 A synonym for <b>--format</b> <i>ustar</i></p>
520 <p style="margin-top: 1em"><b>--older</b> <i>date</i></p>
522 <p style="margin-left:17%;">(c, r, u modes only) Only
523 include files and directories older than the specified date.
524 This compares ctime entries.</p>
526 <p style="margin-top: 1em"><b>--older-mtime</b>
529 <p style="margin-left:17%;">(c, r, u modes only) Like
530 <b>--older</b>, except it compares mtime entries instead of
533 <p style="margin-top: 1em"><b>--older-than</b>
536 <p style="margin-left:17%;">(c, r, u modes only) Only
537 include files and directories older than the specified file.
538 This compares ctime entries.</p>
540 <p style="margin-top: 1em"><b>--older-mtime-than</b>
543 <p style="margin-left:17%;">(c, r, u modes only) Like
544 <b>--older-than</b>, except it compares mtime entries
545 instead of ctime entries.</p>
547 <p style="margin-top: 1em"><b>--one-file-system</b></p>
549 <p style="margin-left:17%;">(c, r, and u modes) Do not
550 cross mount points.</p>
552 <p style="margin-top: 1em"><b>--options</b>
555 <p style="margin-left:17%;">Select optional behaviors for
556 particular modules. The argument is a text string containing
557 comma-separated keywords and values. These are passed to the
558 modules that handle particular formats to control how those
559 formats will behave. Each option has one of the following
562 <p><i>key=value</i></p>
564 <p style="margin-left:27%;">The key will be set to the
565 specified value in every module that supports it. Modules
566 that do not support this key will ignore it.</p>
570 <p style="margin-left:27%; margin-top: 1em">The key will be
571 enabled in every module that supports it. This is equivalent
572 to <i>key</i><b>=1</b>.</p>
576 <p style="margin-left:27%; margin-top: 1em">The key will be
577 disabled in every module that supports it.</p>
579 <p><i>module:key=value</i>, <i>module:key</i>,
580 <i>module:!key</i></p>
582 <p style="margin-left:27%;">As above, but the corresponding
583 key and value will be provided only to modules whose name
584 matches <i>module</i>.</p>
586 <p style="margin-left:17%;">The currently supported modules
589 <p><b>iso9660:joliet</b></p>
591 <p style="margin-left:27%;">Support Joliet extensions. This
592 is enabled by default, use <b>!joliet</b> or
593 <b>iso9660:!joliet</b> to disable.</p>
595 <p><b>iso9660:rockridge</b></p>
597 <p style="margin-left:27%;">Support Rock Ridge extensions.
598 This is enabled by default, use <b>!rockridge</b> or
599 <b>iso9660:!rockridge</b> to disable.</p>
601 <p><b>gzip:compression-level</b></p>
603 <p style="margin-left:27%;">A decimal integer from 1 to 9
604 specifying the gzip compression level.</p>
606 <p><b>gzip:timestamp</b></p>
608 <p style="margin-left:27%;">Store timestamp. This is
609 enabled by default, use <b>!timestamp</b> or
610 <b>gzip:!timestamp</b> to disable.</p>
612 <p><b>lrzip:compression</b>=<i>type</i></p>
614 <p style="margin-left:27%;">Use <i>type</i> as compression
615 method. Supported values are bzip2, gzip, lzo (ultra fast),
616 and zpaq (best, extremely slow).</p>
618 <p><b>lrzip:compression-level</b></p>
620 <p style="margin-left:27%;">A decimal integer from 1 to 9
621 specifying the lrzip compression level.</p>
623 <p><b>lz4:compression-level</b></p>
625 <p style="margin-left:27%;">A decimal integer from 1 to 9
626 specifying the lzop compression level.</p>
628 <p><b>lz4:stream-checksum</b></p>
630 <p style="margin-left:27%;">Enable stream checksum. This is
631 by default, use <b>lz4:!stream-checksum</b> to disable.</p>
633 <p><b>lz4:block-checksum</b></p>
635 <p style="margin-left:27%;">Enable block checksum (Disabled
638 <p><b>lz4:block-size</b></p>
640 <p style="margin-left:27%;">A decimal integer from 4 to 7
641 specifying the lz4 compression block size (7 is set by
644 <p><b>lz4:block-dependence</b></p>
646 <p style="margin-left:27%;">Use the previous block of the
647 block being compressed for a compression dictionary to
648 improve compression ratio.</p>
650 <p><b>lzop:compression-level</b></p>
652 <p style="margin-left:27%;">A decimal integer from 1 to 9
653 specifying the lzop compression level.</p>
655 <p><b>xz:compression-level</b></p>
657 <p style="margin-left:27%;">A decimal integer from 0 to 9
658 specifying the xz compression level.</p>
660 <p><b>mtree:</b><i>keyword</i></p>
662 <p style="margin-left:27%;">The mtree writer module allows
663 you to specify which mtree keywords will be included in the
664 output. Supported keywords include: <b>cksum</b>,
665 <b>device</b>, <b>flags</b>, <b>gid</b>, <b>gname</b>,
666 <b>indent</b>, <b>link</b>, <b>md5</b>, <b>mode</b>,
667 <b>nlink</b>, <b>rmd160</b>, <b>sha1</b>, <b>sha256</b>,
668 <b>sha384</b>, <b>sha512</b>, <b>size</b>, <b>time</b>,
669 <b>uid</b>, <b>uname</b>. The default is equivalent to:
670 ’’device, flags, gid, gname, link, mode, nlink,
671 size, time, type, uid, uname’’.</p>
673 <p><b>mtree:all</b></p>
675 <p style="margin-left:27%;">Enables all of the above
676 keywords. You can also use <b>mtree:!all</b> to disable all
679 <p><b>mtree:use-set</b></p>
681 <p style="margin-left:27%;">Enable generation of
682 <b>/set</b> lines in the output.</p>
684 <p><b>mtree:indent</b></p>
686 <p style="margin-left:27%;">Produce human-readable output
687 by indenting options and splitting lines to fit into 80
690 <p><b>zip:compression</b>=<i>type</i></p>
692 <p style="margin-left:27%;">Use <i>type</i> as compression
693 method. Supported values are store (uncompressed) and
694 deflate (gzip algorithm).</p>
696 <p><b>zip:encryption</b></p>
698 <p style="margin-left:27%;">Enable encryption using
699 traditional zip encryption.</p>
701 <p><b>zip:encryption</b>=<i>type</i></p>
703 <p style="margin-left:27%;">Use <i>type</i> as encryption
704 type. Supported values are zipcrypt (traditional zip
705 encryption), aes128 (WinZip AES-128 encryption) and aes256
706 (WinZip AES-256 encryption).</p>
708 <p><b>read_concatenated_archives</b></p>
710 <p style="margin-left:27%;">Ignore zeroed blocks in the
711 archive, which occurs when multiple tar archives have been
712 concatenated together. Without this option, only the
713 contents of the first concatenated archive would be read.
714 This option is comparable to the <b>-i</b>,
715 <b>--ignore-zeros</b> option of GNU tar.</p>
717 <p style="margin-left:17%;">If a provided option is not
718 supported by any module, that is a fatal error.</p>
720 <p style="margin-top: 1em"><b>-P</b>,
721 <b>--absolute-paths</b></p>
723 <p style="margin-left:17%;">Preserve pathnames. By default,
724 absolute pathnames (those that begin with a / character)
725 have the leading slash removed both when creating archives
726 and extracting from them. Also, <b>tar</b> will refuse to
727 extract archive entries whose pathnames contain <i>..</i> or
728 whose target directory would be altered by a symlink. This
729 option suppresses these behaviors.</p>
731 <p style="margin-top: 1em"><b>-p</b>, <b>--insecure</b>,
732 <b>--preserve-permissions</b></p>
734 <p style="margin-left:17%;">(x mode only) Preserve file
735 permissions. Attempt to restore the full permissions,
736 including owner, file modes, file flags and ACLs, if
737 available, for each item extracted from the archive. This is
738 the default, if <b>tar</b> is being run by root and can be
739 overridden by also specifying <b>--no-same-owner</b> and
740 <b>--no-same-permissions</b>.</p>
742 <p style="margin-top: 1em"><b>--passphrase</b>
743 <i>passphrase</i></p>
745 <p style="margin-left:17%;">The <i>passphrase</i> is used
746 to extract or create an encrypted archive. Currently, zip is
747 the only supported format that supports encryption. You
748 shouldn’t use this option unless you realize how
749 insecure use of this option is.</p>
751 <p style="margin-top: 1em"><b>--posix</b></p>
753 <p style="margin-left:17%;">(c, r, u mode only) Synonym for
754 <b>--format</b> <i>pax</i></p>
756 <p style="margin-top: 1em"><b>-q</b>,
757 <b>--fast-read</b></p>
759 <p style="margin-left:17%;">(x and t mode only) Extract or
760 list only the first archive entry that matches each pattern
761 or filename operand. Exit as soon as each specified pattern
762 or filename has been matched. By default, the archive is
763 always read to the very end, since there can be multiple
764 entries with the same name and, by convention, later entries
765 overwrite earlier entries. This option is provided as a
766 performance optimization.</p>
768 <p style="margin-top: 1em"><b>-S</b></p>
770 <p style="margin-left:17%; margin-top: 1em">(x mode only)
771 Extract files as sparse files. For every block on disk,
772 check first if it contains only NULL bytes and seek over it
773 otherwise. This works similar to the conv=sparse option of
776 <p style="margin-top: 1em"><b>-s</b> <i>pattern</i></p>
778 <p style="margin-left:17%;">Modify file or archive member
779 names according to <i>pattern</i>. The pattern has the
780 format <i>/old/new/</i>[ghHprRsS] where <i>old</i> is a
781 basic regular expression, <i>new</i> is the replacement
782 string of the matched part, and the optional trailing
783 letters modify how the replacement is handled. If <i>old</i>
784 is not matched, the pattern is skipped. Within <i>new</i>, ~
785 is substituted with the match, \1 to \9 with the content of
786 the corresponding captured group. The optional trailing g
787 specifies that matching should continue after the matched
788 part and stop on the first unmatched pattern. The optional
789 trailing s specifies that the pattern applies to the value
790 of symbolic links. The optional trailing p specifies that
791 after a successful substitution the original path name and
792 the new path name should be printed to standard error.
793 Optional trailing H, R, or S characters suppress
794 substitutions for hardlink targets, regular filenames, or
795 symlink targets, respectively. Optional trailing h, r, or s
796 characters enable substitutions for hardlink targets,
797 regular filenames, or symlink targets, respectively. The
798 default is <i>hrs</i> which applies substitutions to all
799 names. In particular, it is never necessary to specify h, r,
802 <p style="margin-top: 1em"><b>--same-owner</b></p>
804 <p style="margin-left:17%;">(x mode only) Extract owner and
805 group IDs. This is the reverse of <b>--no-same-owner</b> and
806 the default behavior if <b>tar</b> is run as root.</p>
808 <p style="margin-top: 1em"><b>--strip-components</b>
811 <p style="margin-left:17%;">Remove the specified number of
812 leading path elements. Pathnames with fewer elements will be
813 silently skipped. Note that the pathname is edited after
814 checking inclusion/exclusion patterns but before security
817 <p style="margin-top: 1em"><b>-T</b> <i>filename</i>,
818 <b>--files-from</b> <i>filename</i></p>
820 <p style="margin-left:17%;">In x or t mode, <b>tar</b> will
821 read the list of names to be extracted from <i>filename</i>.
822 In c mode, <b>tar</b> will read names to be archived from
823 <i>filename</i>. The special name
824 ’’-C’’ on a line by itself will
825 cause the current directory to be changed to the directory
826 specified on the following line. Names are terminated by
827 newlines unless <b>--null</b> is specified. Note that
828 <b>--null</b> also disables the special handling of lines
829 containing ’’-C’’. Note: If you are
830 generating lists of files using find(1), you probably want
831 to use <b>-n</b> as well.</p>
833 <p style="margin-top: 1em"><b>--totals</b></p>
835 <p style="margin-left:17%;">(c, r, u mode only) After
836 archiving all files, print a summary to stderr.</p>
838 <p style="margin-top: 1em"><b>-U</b>, <b>--unlink</b>,
839 <b>--unlink-first</b></p>
841 <p style="margin-left:17%;">(x mode only) Unlink files
842 before creating them. This can be a minor performance
843 optimization if most files already exist, but can make
844 things slower if most files do not already exist. This flag
845 also causes <b>tar</b> to remove intervening directory
846 symlinks instead of reporting an error. See the SECURITY
847 section below for more details.</p>
849 <p style="margin-top: 1em"><b>--uid</b> <i>id</i></p>
851 <p style="margin-left:17%;">Use the provided user id number
852 and ignore the user name from the archive. On create, if
853 <b>--uname</b> is not also specified, the user name will be
854 set to match the user id.</p>
856 <p style="margin-top: 1em"><b>--uname</b> <i>name</i></p>
858 <p style="margin-left:17%;">Use the provided user name. On
859 extract, this overrides the user name in the archive; if the
860 provided user name does not exist on the system, it will be
861 ignored and the user id (from the archive or from the
862 <b>--uid</b> option) will be used instead. On create, this
863 sets the user name that will be stored in the archive; the
864 name is not verified against the system user database.</p>
866 <p style="margin-top: 1em"><b>--use-compress-program</b>
869 <p style="margin-left:17%;">Pipe the input (in x or t mode)
870 or the output (in c mode) through <i>program</i> instead of
871 using the builtin compression support.</p>
873 <p style="margin-top: 1em"><b>-v</b>, <b>--verbose</b></p>
875 <p style="margin-left:17%;">Produce verbose output. In
876 create and extract modes, <b>tar</b> will list each file
877 name as it is read from or written to the archive. In list
878 mode, <b>tar</b> will produce output similar to that of
879 ls(1). An additional <b>-v</b> option will also provide
880 ls-like details in create and extract mode.</p>
882 <p style="margin-top: 1em"><b>--version</b></p>
884 <p style="margin-left:17%;">Print version of <b>tar</b> and
885 <b>libarchive</b>, and exit.</p>
887 <p style="margin-top: 1em"><b>-w</b>,
888 <b>--confirmation</b>, <b>--interactive</b></p>
890 <p style="margin-left:17%;">Ask for confirmation for every
893 <p style="margin-top: 1em"><b>-X</b> <i>filename</i>,
894 <b>--exclude-from</b> <i>filename</i></p>
896 <p style="margin-left:17%;">Read a list of exclusion
897 patterns from the specified file. See <b>--exclude</b> for
898 more information about the handling of exclusions.</p>
900 <p style="margin-top: 1em"><b>-y</b></p>
902 <p style="margin-left:17%; margin-top: 1em">(c mode only)
903 Compress the resulting archive with bzip2(1). In extract or
904 list modes, this option is ignored. Note that, unlike other
905 <b>tar</b> implementations, this implementation recognizes
906 bzip2 compression automatically when reading archives.</p>
908 <p style="margin-top: 1em"><b>-Z</b>, <b>--compress</b>,
909 <b>--uncompress</b></p>
911 <p style="margin-left:17%;">(c mode only) Compress the
912 resulting archive with compress(1). In extract or list
913 modes, this option is ignored. Note that, unlike other
914 <b>tar</b> implementations, this implementation recognizes
915 compress compression automatically when reading
918 <p style="margin-top: 1em"><b>-z</b>, <b>--gunzip</b>,
921 <p style="margin-left:17%;">(c mode only) Compress the
922 resulting archive with gzip(1). In extract or list modes,
923 this option is ignored. Note that, unlike other <b>tar</b>
924 implementations, this implementation recognizes gzip
925 compression automatically when reading archives.</p>
927 <p style="margin-top: 1em"><b>ENVIRONMENT</b></p>
929 <p style="margin-left:6%;">The following environment
930 variables affect the execution of <b>tar</b>:</p>
932 <p style="margin-top: 1em">TAR_READER_OPTIONS</p>
934 <p style="margin-left:21%;">The default options for format
935 readers and compression readers. The <b>--options</b> option
938 <p style="margin-top: 1em">TAR_WRITER_OPTIONS</p>
940 <p style="margin-left:21%;">The default options for format
941 writers and compression writers. The <b>--options</b> option
944 <p style="margin-top: 1em">LANG</p>
946 <p style="margin-left:21%; margin-top: 1em">The locale to
947 use. See environ(7) for more information.</p>
949 <p style="margin-top: 1em">TAPE</p>
951 <p style="margin-left:21%; margin-top: 1em">The default
952 device. The <b>-f</b> option overrides this. Please see the
953 description of the <b>-f</b> option above for more
956 <p style="margin-top: 1em">TZ</p>
958 <p style="margin-left:21%; margin-top: 1em">The timezone to
959 use when displaying dates. See environ(7) for more
962 <p style="margin-top: 1em"><b>EXIT STATUS</b></p>
964 <p style="margin-left:6%;">The <b>tar</b> utility
965 exits 0 on success, and >0 if an error
968 <p style="margin-top: 1em"><b>EXAMPLES</b></p>
970 <p style="margin-left:6%;">The following creates a new
971 archive called <i>file.tar.gz</i> that contains two files
972 <i>source.c</i> and <i>source.h</i>:</p>
974 <p style="margin-left:14%;"><b>tar -czf</b> <i>file.tar.gz
975 source.c source.h</i></p>
977 <p style="margin-left:6%; margin-top: 1em">To view a
978 detailed table of contents for this archive:</p>
980 <p style="margin-left:14%;"><b>tar -tvf</b>
981 <i>file.tar.gz</i></p>
983 <p style="margin-left:6%; margin-top: 1em">To extract all
984 entries from the archive on the default tape drive:</p>
986 <p style="margin-left:14%;"><b>tar -x</b></p>
988 <p style="margin-left:6%; margin-top: 1em">To examine the
989 contents of an ISO 9660 cdrom image:</p>
991 <p style="margin-left:14%;"><b>tar -tf</b>
994 <p style="margin-left:6%; margin-top: 1em">To move file
995 hierarchies, invoke <b>tar</b> as</p>
997 <p style="margin-left:14%;"><b>tar -cf</b> <i>-</i>
998 <b>-C</b> <i>srcdir .</i> | <b>tar -xpf</b> <i>-</i>
999 <b>-C</b> <i>destdir</i></p>
1001 <p style="margin-left:6%;">or more traditionally</p>
1003 <p style="margin-left:14%;">cd srcdir ; <b>tar -cf</b>
1004 <i>- .</i> | (<i>cd destdir ;</i> <b>tar -xpf</b>
1007 <p style="margin-left:6%; margin-top: 1em">In create mode,
1008 the list of files and directories to be archived can also
1009 include directory change instructions of the form
1010 <b>-C</b><i>foo/baz</i> and archive inclusions of the form
1011 <b>@</b><i>archive-file</i>. For example, the command
1014 <p style="margin-left:14%;"><b>tar -c -f</b> <i>new.tar
1015 foo1</i> <b>@</b><i>old.tgz</i> <b>-C</b><i>/tmp
1018 <p style="margin-left:6%;">will create a new archive
1019 <i>new.tar</i>. <b>tar</b> will read the file <i>foo1</i>
1020 from the current directory and add it to the output archive.
1021 It will then read each entry from <i>old.tgz</i> and add
1022 those entries to the output archive. Finally, it will switch
1023 to the <i>/tmp</i> directory and add <i>foo2</i> to the
1026 <p style="margin-left:6%; margin-top: 1em">An input file in
1027 mtree(5) format can be used to create an output archive with
1028 arbitrary ownership, permissions, or names that differ from
1029 existing data on disk:</p>
1031 <p style="margin-left:14%; margin-top: 1em">$ cat
1034 usr/bin uid=0 gid=0 mode=0755 type=dir <br>
1035 usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls <br>
1036 $ tar -cvf output.tar @input.mtree</p>
1038 <p style="margin-left:6%; margin-top: 1em">The
1039 <b>--newer</b> and <b>--newer-mtime</b> switches accept a
1040 variety of common date and time specifications, including
1041 ’’12 Mar 2005 7:14:29pm’’,
1042 ’’2005-03-12 19:14’’,
1043 ’’5 minutes ago’’, and
1044 ’’19:14 PST May 1’’.</p>
1046 <p style="margin-left:6%; margin-top: 1em">The
1047 <b>--options</b> argument can be used to control various
1048 details of archive generation or reading. For example, you
1049 can generate mtree output which only contains <b>type</b>,
1050 <b>time</b>, and <b>uid</b> keywords:</p>
1052 <p style="margin-left:14%;"><b>tar -cf</b> <i>file.tar</i>
1054 --options=’!all,type,time,uid’</b>
1057 <p style="margin-left:6%;">or you can set the compression
1058 level used by gzip or xz compression:</p>
1060 <p style="margin-left:14%;"><b>tar -czf</b> <i>file.tar</i>
1061 <b>--options=’compression-level=9’</b>.</p>
1063 <p style="margin-left:6%;">For more details, see the
1064 explanation of the <b>archive_read_set_options</b>() and
1065 <b>archive_write_set_options</b>() API calls that are
1066 described in archive_read(3) and archive_write(3).</p>
1068 <p style="margin-top: 1em"><b>COMPATIBILITY</b></p>
1070 <p style="margin-left:6%;">The bundled-arguments format is
1071 supported for compatibility with historic implementations.
1072 It consists of an initial word (with no leading - character)
1073 in which each character indicates an option. Arguments
1074 follow as separate words. The order of the arguments must
1075 match the order of the corresponding characters in the
1076 bundled command word. For example,</p>
1078 <p style="margin-left:14%;"><b>tar tbf 32</b>
1081 <p style="margin-left:6%;">specifies three flags <b>t</b>,
1082 <b>b</b>, and <b>f</b>. The <b>b</b> and <b>f</b> flags both
1083 require arguments, so there must be two additional items on
1084 the command line. The <i>32</i> is the argument to the
1085 <b>b</b> flag, and <i>file.tar</i> is the argument to the
1088 <p style="margin-left:6%; margin-top: 1em">The mode options
1089 c, r, t, u, and x and the options b, f, l, m, o, v, and w
1090 comply with SUSv2.</p>
1092 <p style="margin-left:6%; margin-top: 1em">For maximum
1093 portability, scripts that invoke <b>tar</b> should use the
1094 bundled-argument format above, should limit themselves to
1095 the <b>c</b>, <b>t</b>, and <b>x</b> modes, and the
1096 <b>b</b>, <b>f</b>, <b>m</b>, <b>v</b>, and <b>w</b>
1099 <p style="margin-left:6%; margin-top: 1em">Additional long
1100 options are provided to improve compatibility with other tar
1101 implementations.</p>
1103 <p style="margin-top: 1em"><b>SECURITY</b></p>
1105 <p style="margin-left:6%;">Certain security issues are
1106 common to many archiving programs, including <b>tar</b>. In
1107 particular, carefully-crafted archives can request that
1108 <b>tar</b> extract files to locations outside of the target
1109 directory. This can potentially be used to cause unwitting
1110 users to overwrite files they did not intend to overwrite.
1111 If the archive is being extracted by the superuser, any file
1112 on the system can potentially be overwritten. There are
1113 three ways this can happen. Although <b>tar</b> has
1114 mechanisms to protect against each one, savvy users should
1115 be aware of the implications:</p>
1117 <p style="margin-top: 1em"><b>•</b></p>
1119 <p style="margin-left:17%;">Archive entries can have
1120 absolute pathnames. By default, <b>tar</b> removes the
1121 leading <i>/</i> character from filenames before restoring
1122 them to guard against this problem.</p>
1124 <p style="margin-top: 1em"><b>•</b></p>
1126 <p style="margin-left:17%;">Archive entries can have
1127 pathnames that include <i>..</i> components. By default,
1128 <b>tar</b> will not extract files containing <i>..</i>
1129 components in their pathname.</p>
1131 <p style="margin-top: 1em"><b>•</b></p>
1133 <p style="margin-left:17%;">Archive entries can exploit
1134 symbolic links to restore files to other directories. An
1135 archive can restore a symbolic link to another directory,
1136 then use that link to restore a file into that directory. To
1137 guard against this, <b>tar</b> checks each extracted path
1138 for symlinks. If the final path element is a symlink, it
1139 will be removed and replaced with the archive entry. If
1140 <b>-U</b> is specified, any intermediate symlink will also
1141 be unconditionally removed. If neither <b>-U</b> nor
1142 <b>-P</b> is specified, <b>tar</b> will refuse to extract
1145 <p style="margin-left:6%;">To protect yourself, you should
1146 be wary of any archives that come from untrusted sources.
1147 You should examine the contents of an archive with</p>
1149 <p style="margin-left:14%;"><b>tar -tf</b>
1152 <p style="margin-left:6%;">before extraction. You should
1153 use the <b>-k</b> option to ensure that <b>tar</b> will not
1154 overwrite any existing files or the <b>-U</b> option to
1155 remove any pre-existing files. You should generally not
1156 extract archives while running with super-user privileges.
1157 Note that the <b>-P</b> option to <b>tar</b> disables the
1158 security checks above and allows you to extract an archive
1159 while preserving any absolute pathnames, <i>..</i>
1160 components, or symlinks to other directories.</p>
1162 <p style="margin-top: 1em"><b>SEE ALSO</b></p>
1164 <p style="margin-left:6%;">bzip2(1), compress(1), cpio(1),
1165 gzip(1), mt(1), pax(1), shar(1), xz(1), libarchive(3),
1166 libarchive-formats(5), tar(5)</p>
1168 <p style="margin-top: 1em"><b>STANDARDS</b></p>
1170 <p style="margin-left:6%;">There is no current POSIX
1171 standard for the tar command; it appeared in ISO/IEC
1172 9945-1:1996 (’’POSIX.1’’) but was
1173 dropped from IEEE Std 1003.1-2001
1174 (’’POSIX.1’’). The options supported
1175 by this implementation were developed by surveying a number
1176 of existing tar implementations as well as the old POSIX
1177 specification for tar and the current POSIX specification
1180 <p style="margin-left:6%; margin-top: 1em">The ustar and
1181 pax interchange file formats are defined by IEEE Std
1182 1003.1-2001 (’’POSIX.1’’) for the
1185 <p style="margin-top: 1em"><b>HISTORY</b></p>
1187 <p style="margin-left:6%;">A <b>tar</b> command appeared in
1188 Seventh Edition Unix, which was released in January, 1979.
1189 There have been numerous other implementations, many of
1190 which extended the file format. John Gilmore’s
1191 <b>pdtar</b> public-domain implementation (circa November,
1192 1987) was quite influential, and formed the basis of GNU
1193 tar. GNU tar was included as the standard system tar in
1194 FreeBSD beginning with FreeBSD 1.0.</p>
1196 <p style="margin-left:6%; margin-top: 1em">This is a
1197 complete re-implementation based on the libarchive(3)
1198 library. It was first released with FreeBSD 5.4 in May,
1201 <p style="margin-top: 1em"><b>BUGS</b></p>
1203 <p style="margin-left:6%;">This program follows ISO/IEC
1204 9945-1:1996 (’’POSIX.1’’) for the
1205 definition of the <b>-l</b> option. Note that GNU tar prior
1206 to version 1.15 treated <b>-l</b> as a synonym for the
1207 <b>--one-file-system</b> option.</p>
1209 <p style="margin-left:6%; margin-top: 1em">The <b>-C</b>
1210 <i>dir</i> option may differ from historic
1211 implementations.</p>
1213 <p style="margin-left:6%; margin-top: 1em">All archive
1214 output is written in correctly-sized blocks, even if the
1215 output is being compressed. Whether or not the last output
1216 block is padded to a full block size varies depending on the
1217 format and the output device. For tar and cpio formats, the
1218 last block of output is padded to a full block size if the
1219 output is being written to standard output or to a character
1220 or block device such as a tape drive. If the output is being
1221 written to a regular file, the last block will not be
1222 padded. Many compressors, including gzip(1) and bzip2(1),
1223 complain about the null padding when decompressing an
1224 archive created by <b>tar</b>, although they still extract
1227 <p style="margin-left:6%; margin-top: 1em">The compression
1228 and decompression is implemented internally, so there may be
1229 insignificant differences between the compressed output
1232 <p style="margin-left:14%;"><b>tar -czf</b> <i>-
1235 <p style="margin-left:6%;">and that generated by</p>
1237 <p style="margin-left:14%;"><b>tar -cf</b> <i>- file</i> |
1240 <p style="margin-left:6%; margin-top: 1em">The default
1241 should be to read and write archives to the standard I/O
1242 paths, but tradition (and POSIX) dictates otherwise.</p>
1244 <p style="margin-left:6%; margin-top: 1em">The <b>r</b> and
1245 <b>u</b> modes require that the archive be uncompressed and
1246 located in a regular file on disk. Other archives can be
1247 modified using <b>c</b> mode with the <i>@archive-file</i>
1250 <p style="margin-left:6%; margin-top: 1em">To archive a
1251 file called <i>@foo</i> or <i>-foo</i> you must specify it
1252 as <i>./@foo</i> or <i>./-foo</i>, respectively.</p>
1254 <p style="margin-left:6%; margin-top: 1em">In create mode,
1255 a leading <i>./</i> is always removed. A leading <i>/</i> is
1256 stripped unless the <b>-P</b> option is specified.</p>
1258 <p style="margin-left:6%; margin-top: 1em">There needs to
1259 be better support for file selection on both create and
1262 <p style="margin-left:6%; margin-top: 1em">There is not yet
1263 any support for multi-volume archives.</p>
1265 <p style="margin-left:6%; margin-top: 1em">Converting
1266 between dissimilar archive formats (such as tar and cpio)
1267 using the <b>@</b><i>-</i> convention can cause hard link
1268 information to be lost. (This is a consequence of the
1269 incompatible ways that different archive formats store
1270 hardlink information.)</p>
1272 <p style="margin-left:6%; margin-top: 1em">BSD
1273 September 16, 2014 BSD</p>