Imported Upstream version 3.3.0
[platform/upstream/libarchive.git] / doc / text / bsdtar.1.txt
1 TAR(1)                    BSD General Commands Manual                   TAR(1)
2
3 NAME
4      tar — manipulate tape archives
5
6 SYNOPSIS
7      tar [bundled-flags ⟨args⟩] [⟨file⟩ | ⟨pattern⟩ ...]
8      tar {-c} [options] [files | directories]
9      tar {-r | -u} -f archive-file [options] [files | directories]
10      tar {-t | -x} [options] [patterns]
11
12 DESCRIPTION
13      tar creates and manipulates streaming archive files.  This implementation
14      can extract from tar, pax, cpio, zip, jar, ar, xar, rpm, 7-zip, and ISO
15      9660 cdrom images and can create tar, pax, cpio, ar, zip, 7-zip, and shar
16      archives.
17
18      The first synopsis form shows a “bundled” option word.  This usage is
19      provided for compatibility with historical implementations.  See COMPATI‐
20      BILITY below for details.
21
22      The other synopsis forms show the preferred usage.  The first option to
23      tar is a mode indicator from the following list:
24      -c      Create a new archive containing the specified items.  The long
25              option form is --create.
26      -r      Like -c, but new entries are appended to the archive.  Note that
27              this only works on uncompressed archives stored in regular files.
28              The -f option is required.  The long option form is --append.
29      -t      List archive contents to stdout.  The long option form is --list.
30      -u      Like -r, but new entries are added only if they have a modifica‐
31              tion date newer than the corresponding entry in the archive.
32              Note that this only works on uncompressed archives stored in reg‐
33              ular files.  The -f option is required.  The long form is
34              --update.
35      -x      Extract to disk from the archive.  If a file with the same name
36              appears more than once in the archive, each copy will be
37              extracted, with later copies overwriting (replacing) earlier
38              copies.  The long option form is --extract.
39
40      In -c, -r, or -u mode, each specified file or directory is added to the
41      archive in the order specified on the command line.  By default, the con‐
42      tents of each directory are also archived.
43
44      In extract or list mode, the entire command line is read and parsed
45      before the archive is opened.  The pathnames or patterns on the command
46      line indicate which items in the archive should be processed.  Patterns
47      are shell-style globbing patterns as documented in tcsh(1).
48
49 OPTIONS
50      Unless specifically stated otherwise, options are applicable in all oper‐
51      ating modes.
52
53      @archive
54              (c and r mode only) The specified archive is opened and the
55              entries in it will be appended to the current archive.  As a sim‐
56              ple example,
57                    tar -c -f - newfile @original.tar
58              writes a new archive to standard output containing a file newfile
59              and all of the entries from original.tar.  In contrast,
60                    tar -c -f - newfile original.tar
61              creates a new archive with only two entries.  Similarly,
62                    tar -czf - --format pax @-
63              reads an archive from standard input (whose format will be deter‐
64              mined automatically) and converts it into a gzip-compressed pax-
65              format archive on stdout.  In this way, tar can be used to con‐
66              vert archives from one format to another.
67
68      -a, --auto-compress
69              (c mode only) Use the archive suffix to decide a set of the for‐
70              mat and the compressions.  As a simple example,
71                    tar -a -cf archive.tgz source.c source.h
72              creates a new archive with restricted pax format and gzip com‐
73              pression,
74                    tar -a -cf archive.tar.bz2.uu source.c source.h
75              creates a new archive with restricted pax format and bzip2 com‐
76              pression and uuencode compression,
77                    tar -a -cf archive.zip source.c source.h
78              creates a new archive with zip format,
79                    tar -a -jcf archive.tgz source.c source.h
80              ignores the “-j” option, and creates a new archive with
81              restricted pax format and gzip compression,
82                    tar -a -jcf archive.xxx source.c source.h
83              if it is unknown suffix or no suffix, creates a new archive with
84              restricted pax format and bzip2 compression.
85
86      -B, --read-full-blocks
87              Ignored for compatibility with other tar(1) implementations.
88
89      -b blocksize, --block-size blocksize
90              Specify the block size, in 512-byte records, for tape drive I/O.
91              As a rule, this argument is only needed when reading from or
92              writing to tape drives, and usually not even then as the default
93              block size of 20 records (10240 bytes) is very common.
94
95      -C directory, --cd directory, --directory directory
96              In c and r mode, this changes the directory before adding the
97              following files.  In x mode, change directories after opening the
98              archive but before extracting entries from the archive.
99
100      --chroot
101              (x mode only) chroot() to the current directory after processing
102              any -C options and before extracting any files.
103
104      --clear-nochange-fflags
105              (x mode only) Before removing file system objects to replace
106              them, clear platform-specific file flags that might prevent
107              removal.
108
109      --disable-copyfile
110              Mac OS X specific.  Disable the use of copyfile(3).
111
112      --exclude pattern
113              Do not process files or directories that match the specified pat‐
114              tern.  Note that exclusions take precedence over patterns or
115              filenames specified on the command line.
116
117      --format format
118              (c, r, u mode only) Use the specified format for the created ar‐
119              chive.  Supported formats include “cpio”, “pax”, “shar”, and
120              “ustar”.  Other formats may also be supported; see
121              libarchive-formats(5) for more information about currently-sup‐
122              ported formats.  In r and u modes, when extending an existing ar‐
123              chive, the format specified here must be compatible with the for‐
124              mat of the existing archive on disk.
125
126      -f file, --file file
127              Read the archive from or write the archive to the specified file.
128              The filename can be - for standard input or standard output.  The
129              default varies by system; on FreeBSD, the default is /dev/sa0; on
130              Linux, the default is /dev/st0.
131
132      --gid id
133              Use the provided group id number.  On extract, this overrides the
134              group id in the archive; the group name in the archive will be
135              ignored.  On create, this overrides the group id read from disk;
136              if --gname is not also specified, the group name will be set to
137              match the group id.
138
139      --gname name
140              Use the provided group name.  On extract, this overrides the
141              group name in the archive; if the provided group name does not
142              exist on the system, the group id (from the archive or from the
143              --gid option) will be used instead.  On create, this sets the
144              group name that will be stored in the archive; the name will not
145              be verified against the system group database.
146
147      -H      (c and r mode only) Symbolic links named on the command line will
148              be followed; the target of the link will be archived, not the
149              link itself.
150
151      -h      (c and r mode only) Synonym for -L.
152
153      -I      Synonym for -T.
154
155      --help  Show usage.
156
157      --hfsCompression
158              (x mode only) Mac OS X specific(v10.6 or later). Compress
159              extracted regular files with HFS+ compression.
160
161      --ignore-zeros
162              An alias of --options read_concatenated_archives for compatibil‐
163              ity with GNU tar.
164
165      --include pattern
166              Process only files or directories that match the specified pat‐
167              tern.  Note that exclusions specified with --exclude take prece‐
168              dence over inclusions.  If no inclusions are explicitly speci‐
169              fied, all entries are processed by default.  The --include option
170              is especially useful when filtering archives.  For example, the
171              command
172                    tar -c -f new.tar --include='*foo*' @old.tgz
173              creates a new archive new.tar containing only the entries from
174              old.tgz containing the string ‘foo’.
175
176      -J, --xz
177              (c mode only) Compress the resulting archive with xz(1).  In
178              extract or list modes, this option is ignored.  Note that, unlike
179              other tar implementations, this implementation recognizes XZ com‐
180              pression automatically when reading archives.
181
182      -j, --bzip, --bzip2, --bunzip2
183              (c mode only) Compress the resulting archive with bzip2(1).  In
184              extract or list modes, this option is ignored.  Note that, unlike
185              other tar implementations, this implementation recognizes bzip2
186              compression automatically when reading archives.
187
188      -k, --keep-old-files
189              (x mode only) Do not overwrite existing files.  In particular, if
190              a file appears more than once in an archive, later copies will
191              not overwrite earlier copies.
192
193      --keep-newer-files
194              (x mode only) Do not overwrite existing files that are newer than
195              the versions appearing in the archive being extracted.
196
197      -L, --dereference
198              (c and r mode only) All symbolic links will be followed.  Nor‐
199              mally, symbolic links are archived as such.  With this option,
200              the target of the link will be archived instead.
201
202      -l, --check-links
203              (c and r modes only) Issue a warning message unless all links to
204              each file are archived.
205
206      --lrzip
207              (c mode only) Compress the resulting archive with lrzip(1).  In
208              extract or list modes, this option is ignored.
209
210      --lz4   (c mode only) Compress the archive with lz4-compatible compres‐
211              sion before writing it.  In input mode, this option is ignored;
212              lz4 compression is recognized automatically on input.
213
214      --lzma  (c mode only) Compress the resulting archive with the original
215              LZMA algorithm.  Use of this option is discouraged and new ar‐
216              chives should be created with --xz instead.  Note that, unlike
217              other tar implementations, this implementation recognizes LZMA
218              compression automatically when reading archives.
219
220      --lzop  (c mode only) Compress the resulting archive with lzop(1).  In
221              extract or list modes, this option is ignored.
222
223      -m, --modification-time
224              (x mode only) Do not extract modification time.  By default, the
225              modification time is set to the time stored in the archive.
226
227      -n, --norecurse, --no-recursion
228              (c, r, u modes only) Do not recursively archive the contents of
229              directories.
230
231      --newer date
232              (c, r, u modes only) Only include files and directories newer
233              than the specified date.  This compares ctime entries.
234
235      --newer-mtime date
236              (c, r, u modes only) Like --newer, except it compares mtime
237              entries instead of ctime entries.
238
239      --newer-than file
240              (c, r, u modes only) Only include files and directories newer
241              than the specified file.  This compares ctime entries.
242
243      --newer-mtime-than file
244              (c, r, u modes only) Like --newer-than, except it compares mtime
245              entries instead of ctime entries.
246
247      --nodump
248              (c and r modes only) Honor the nodump file flag by skipping this
249              file.
250
251      --nopreserveHFSCompression
252              (x mode only) Mac OS X specific(v10.6 or later). Do not compress
253              extracted regular files which were compressed with HFS+ compres‐
254              sion before archived.  By default, compress the regular files
255              again with HFS+ compression.
256
257      --null  (use with -I or -T) Filenames or patterns are separated by null
258              characters, not by newlines.  This is often used to read file‐
259              names output by the -print0 option to find(1).
260
261      --no-same-owner
262              (x mode only) Do not extract owner and group IDs.  This is the
263              reverse of --same-owner and the default behavior if tar is run as
264              non-root.
265
266      --no-same-permissions
267              (x mode only) Do not extract full permissions (SGID, SUID, sticky
268              bit, ACLs, extended attributes or extended file flags).  This is
269              the reverse of -p and the default behavior if tar is run as non-
270              root.
271
272      --numeric-owner
273              This is equivalent to --uname "" --gname "".  On extract, it
274              causes user and group names in the archive to be ignored in favor
275              of the numeric user and group ids.  On create, it causes user and
276              group names to not be stored in the archive.
277
278      -O, --to-stdout
279              (x, t modes only) In extract (-x) mode, files will be written to
280              standard out rather than being extracted to disk.  In list (-t)
281              mode, the file listing will be written to stderr rather than the
282              usual stdout.
283
284      -o      (x mode) Use the user and group of the user running the program
285              rather than those specified in the archive.  Note that this has
286              no significance unless -p is specified, and the program is being
287              run by the root user.  In this case, the file modes and flags
288              from the archive will be restored, but ACLs or owner information
289              in the archive will be discarded.
290
291      -o      (c, r, u mode) A synonym for --format ustar
292
293      --older date
294              (c, r, u modes only) Only include files and directories older
295              than the specified date.  This compares ctime entries.
296
297      --older-mtime date
298              (c, r, u modes only) Like --older, except it compares mtime
299              entries instead of ctime entries.
300
301      --older-than file
302              (c, r, u modes only) Only include files and directories older
303              than the specified file.  This compares ctime entries.
304
305      --older-mtime-than file
306              (c, r, u modes only) Like --older-than, except it compares mtime
307              entries instead of ctime entries.
308
309      --one-file-system
310              (c, r, and u modes) Do not cross mount points.
311
312      --options options
313              Select optional behaviors for particular modules.  The argument
314              is a text string containing comma-separated keywords and values.
315              These are passed to the modules that handle particular formats to
316              control how those formats will behave.  Each option has one of
317              the following forms:
318              key=value
319                      The key will be set to the specified value in every mod‐
320                      ule that supports it.  Modules that do not support this
321                      key will ignore it.
322              key     The key will be enabled in every module that supports it.
323                      This is equivalent to key=1.
324              !key    The key will be disabled in every module that supports
325                      it.
326              module:key=value, module:key, module:!key
327                      As above, but the corresponding key and value will be
328                      provided only to modules whose name matches module.
329              The currently supported modules and keys are:
330              iso9660:joliet
331                      Support Joliet extensions.  This is enabled by default,
332                      use !joliet or iso9660:!joliet to disable.
333              iso9660:rockridge
334                      Support Rock Ridge extensions.  This is enabled by
335                      default, use !rockridge or iso9660:!rockridge to disable.
336              gzip:compression-level
337                      A decimal integer from 1 to 9 specifying the gzip com‐
338                      pression level.
339              gzip:timestamp
340                      Store timestamp. This is enabled by default, use
341                      !timestamp or gzip:!timestamp to disable.
342              lrzip:compression=type
343                      Use type as compression method.  Supported values are
344                      bzip2, gzip, lzo (ultra fast), and zpaq (best, extremely
345                      slow).
346              lrzip:compression-level
347                      A decimal integer from 1 to 9 specifying the lrzip com‐
348                      pression level.
349              lz4:compression-level
350                      A decimal integer from 1 to 9 specifying the lzop com‐
351                      pression level.
352              lz4:stream-checksum
353                      Enable stream checksum. This is by default, use
354                      lz4:!stream-checksum to disable.
355              lz4:block-checksum
356                      Enable block checksum (Disabled by default).
357              lz4:block-size
358                      A decimal integer from 4 to 7 specifying the lz4 compres‐
359                      sion block size (7 is set by default).
360              lz4:block-dependence
361                      Use the previous block of the block being compressed for
362                      a compression dictionary to improve compression ratio.
363              lzop:compression-level
364                      A decimal integer from 1 to 9 specifying the lzop com‐
365                      pression level.
366              xz:compression-level
367                      A decimal integer from 0 to 9 specifying the xz compres‐
368                      sion level.
369              mtree:keyword
370                      The mtree writer module allows you to specify which mtree
371                      keywords will be included in the output.  Supported key‐
372                      words include: cksum, device, flags, gid, gname, indent,
373                      link, md5, mode, nlink, rmd160, sha1, sha256, sha384,
374                      sha512, size, time, uid, uname.  The default is equiva‐
375                      lent to: “device, flags, gid, gname, link, mode, nlink,
376                      size, time, type, uid, uname”.
377              mtree:all
378                      Enables all of the above keywords.  You can also use
379                      mtree:!all to disable all keywords.
380              mtree:use-set
381                      Enable generation of /set lines in the output.
382              mtree:indent
383                      Produce human-readable output by indenting options and
384                      splitting lines to fit into 80 columns.
385              zip:compression=type
386                      Use type as compression method.  Supported values are
387                      store (uncompressed) and deflate (gzip algorithm).
388              zip:encryption
389                      Enable encryption using traditional zip encryption.
390              zip:encryption=type
391                      Use type as encryption type.  Supported values are
392                      zipcrypt (traditional zip encryption), aes128 (WinZip
393                      AES-128 encryption) and aes256 (WinZip AES-256 encryp‐
394                      tion).
395              read_concatenated_archives
396                      Ignore zeroed blocks in the archive, which occurs when
397                      multiple tar archives have been concatenated together.
398                      Without this option, only the contents of the first con‐
399                      catenated archive would be read.  This option is compara‐
400                      ble to the -i, --ignore-zeros option of GNU tar.
401              If a provided option is not supported by any module, that is a
402              fatal error.
403
404      -P, --absolute-paths
405              Preserve pathnames.  By default, absolute pathnames (those that
406              begin with a / character) have the leading slash removed both
407              when creating archives and extracting from them.  Also, tar will
408              refuse to extract archive entries whose pathnames contain .. or
409              whose target directory would be altered by a symlink.  This
410              option suppresses these behaviors.
411
412      -p, --insecure, --preserve-permissions
413              (x mode only) Preserve file permissions.  Attempt to restore the
414              full permissions, including owner, file modes, file flags and
415              ACLs, if available, for each item extracted from the archive.
416              This is the default, if tar is being run by root and can be over‐
417              ridden by also specifying --no-same-owner and
418              --no-same-permissions.
419
420      --passphrase passphrase
421              The passphrase is used to extract or create an encrypted archive.
422              Currently, zip is the only supported format that supports encryp‐
423              tion.  You shouldn't use this option unless you realize how inse‐
424              cure use of this option is.
425
426      --posix
427              (c, r, u mode only) Synonym for --format pax
428
429      -q, --fast-read
430              (x and t mode only) Extract or list only the first archive entry
431              that matches each pattern or filename operand.  Exit as soon as
432              each specified pattern or filename has been matched.  By default,
433              the archive is always read to the very end, since there can be
434              multiple entries with the same name and, by convention, later
435              entries overwrite earlier entries.  This option is provided as a
436              performance optimization.
437
438      -S      (x mode only) Extract files as sparse files.  For every block on
439              disk, check first if it contains only NULL bytes and seek over it
440              otherwise.  This works similar to the conv=sparse option of dd.
441
442      -s pattern
443              Modify file or archive member names according to pattern.  The
444              pattern has the format /old/new/[ghHprRsS] where old is a basic
445              regular expression, new is the replacement string of the matched
446              part, and the optional trailing letters modify how the replace‐
447              ment is handled.  If old is not matched, the pattern is skipped.
448              Within new, ~ is substituted with the match, \1 to \9 with the
449              content of the corresponding captured group.  The optional trail‐
450              ing g specifies that matching should continue after the matched
451              part and stop on the first unmatched pattern.  The optional
452              trailing s specifies that the pattern applies to the value of
453              symbolic links.  The optional trailing p specifies that after a
454              successful substitution the original path name and the new path
455              name should be printed to standard error.  Optional trailing H,
456              R, or S characters suppress substitutions for hardlink targets,
457              regular filenames, or symlink targets, respectively.  Optional
458              trailing h, r, or s characters enable substitutions for hardlink
459              targets, regular filenames, or symlink targets, respectively.
460              The default is hrs which applies substitutions to all names.  In
461              particular, it is never necessary to specify h, r, or s.
462
463      --same-owner
464              (x mode only) Extract owner and group IDs.  This is the reverse
465              of --no-same-owner and the default behavior if tar is run as
466              root.
467
468      --strip-components count
469              Remove the specified number of leading path elements.  Pathnames
470              with fewer elements will be silently skipped.  Note that the
471              pathname is edited after checking inclusion/exclusion patterns
472              but before security checks.
473
474      -T filename, --files-from filename
475              In x or t mode, tar will read the list of names to be extracted
476              from filename.  In c mode, tar will read names to be archived
477              from filename.  The special name “-C” on a line by itself will
478              cause the current directory to be changed to the directory speci‐
479              fied on the following line.  Names are terminated by newlines
480              unless --null is specified.  Note that --null also disables the
481              special handling of lines containing “-C”.  Note:      If you are
482              generating lists of files using find(1), you probably want to use
483              -n as well.
484
485      --totals
486              (c, r, u mode only) After archiving all files, print a summary to
487              stderr.
488
489      -U, --unlink, --unlink-first
490              (x mode only) Unlink files before creating them.  This can be a
491              minor performance optimization if most files already exist, but
492              can make things slower if most files do not already exist.  This
493              flag also causes tar to remove intervening directory symlinks
494              instead of reporting an error.  See the SECURITY section below
495              for more details.
496
497      --uid id
498              Use the provided user id number and ignore the user name from the
499              archive.  On create, if --uname is not also specified, the user
500              name will be set to match the user id.
501
502      --uname name
503              Use the provided user name.  On extract, this overrides the user
504              name in the archive; if the provided user name does not exist on
505              the system, it will be ignored and the user id (from the archive
506              or from the --uid option) will be used instead.  On create, this
507              sets the user name that will be stored in the archive; the name
508              is not verified against the system user database.
509
510      --use-compress-program program
511              Pipe the input (in x or t mode) or the output (in c mode) through
512              program instead of using the builtin compression support.
513
514      -v, --verbose
515              Produce verbose output.  In create and extract modes, tar will
516              list each file name as it is read from or written to the archive.
517              In list mode, tar will produce output similar to that of ls(1).
518              An additional -v option will also provide ls-like details in cre‐
519              ate and extract mode.
520
521      --version
522              Print version of tar and libarchive, and exit.
523
524      -w, --confirmation, --interactive
525              Ask for confirmation for every action.
526
527      -X filename, --exclude-from filename
528              Read a list of exclusion patterns from the specified file.  See
529              --exclude for more information about the handling of exclusions.
530
531      -y      (c mode only) Compress the resulting archive with bzip2(1).  In
532              extract or list modes, this option is ignored.  Note that, unlike
533              other tar implementations, this implementation recognizes bzip2
534              compression automatically when reading archives.
535
536      -Z, --compress, --uncompress
537              (c mode only) Compress the resulting archive with compress(1).
538              In extract or list modes, this option is ignored.  Note that,
539              unlike other tar implementations, this implementation recognizes
540              compress compression automatically when reading archives.
541
542      -z, --gunzip, --gzip
543              (c mode only) Compress the resulting archive with gzip(1).  In
544              extract or list modes, this option is ignored.  Note that, unlike
545              other tar implementations, this implementation recognizes gzip
546              compression automatically when reading archives.
547
548 ENVIRONMENT
549      The following environment variables affect the execution of tar:
550
551      TAR_READER_OPTIONS
552                 The default options for format readers and compression read‐
553                 ers.  The --options option overrides this.
554
555      TAR_WRITER_OPTIONS
556                 The default options for format writers and compression writ‐
557                 ers.  The --options option overrides this.
558
559      LANG       The locale to use.  See environ(7) for more information.
560
561      TAPE       The default device.  The -f option overrides this.  Please see
562                 the description of the -f option above for more details.
563
564      TZ         The timezone to use when displaying dates.  See environ(7) for
565                 more information.
566
567 EXIT STATUS
568      The tar utility exits 0 on success, and >0 if an error occurs.
569
570 EXAMPLES
571      The following creates a new archive called file.tar.gz that contains two
572      files source.c and source.h:
573            tar -czf file.tar.gz source.c source.h
574
575      To view a detailed table of contents for this archive:
576            tar -tvf file.tar.gz
577
578      To extract all entries from the archive on the default tape drive:
579            tar -x
580
581      To examine the contents of an ISO 9660 cdrom image:
582            tar -tf image.iso
583
584      To move file hierarchies, invoke tar as
585            tar -cf - -C srcdir . | tar -xpf - -C destdir
586      or more traditionally
587            cd srcdir ; tar -cf - . | (cd destdir ; tar -xpf -)
588
589      In create mode, the list of files and directories to be archived can also
590      include directory change instructions of the form -Cfoo/baz and archive
591      inclusions of the form @archive-file.  For example, the command line
592            tar -c -f new.tar foo1 @old.tgz -C/tmp foo2
593      will create a new archive new.tar.  tar will read the file foo1 from the
594      current directory and add it to the output archive.  It will then read
595      each entry from old.tgz and add those entries to the output archive.
596      Finally, it will switch to the /tmp directory and add foo2 to the output
597      archive.
598
599      An input file in mtree(5) format can be used to create an output archive
600      with arbitrary ownership, permissions, or names that differ from existing
601      data on disk:
602
603            $ cat input.mtree
604            #mtree
605            usr/bin uid=0 gid=0 mode=0755 type=dir
606            usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
607            $ tar -cvf output.tar @input.mtree
608
609      The --newer and --newer-mtime switches accept a variety of common date
610      and time specifications, including “12 Mar 2005 7:14:29pm”, “2005-03-12
611      19:14”, “5 minutes ago”, and “19:14 PST May 1”.
612
613      The --options argument can be used to control various details of archive
614      generation or reading.  For example, you can generate mtree output which
615      only contains type, time, and uid keywords:
616            tar -cf file.tar --format=mtree --options='!all,type,time,uid' dir
617      or you can set the compression level used by gzip or xz compression:
618            tar -czf file.tar --options='compression-level=9'.
619      For more details, see the explanation of the archive_read_set_options()
620      and archive_write_set_options() API calls that are described in
621      archive_read(3) and archive_write(3).
622
623 COMPATIBILITY
624      The bundled-arguments format is supported for compatibility with historic
625      implementations.  It consists of an initial word (with no leading - char‐
626      acter) in which each character indicates an option.  Arguments follow as
627      separate words.  The order of the arguments must match the order of the
628      corresponding characters in the bundled command word.  For example,
629            tar tbf 32 file.tar
630      specifies three flags t, b, and f.  The b and f flags both require argu‐
631      ments, so there must be two additional items on the command line.  The 32
632      is the argument to the b flag, and file.tar is the argument to the f
633      flag.
634
635      The mode options c, r, t, u, and x and the options b, f, l, m, o, v, and
636      w comply with SUSv2.
637
638      For maximum portability, scripts that invoke tar should use the bundled-
639      argument format above, should limit themselves to the c, t, and x modes,
640      and the b, f, m, v, and w options.
641
642      Additional long options are provided to improve compatibility with other
643      tar implementations.
644
645 SECURITY
646      Certain security issues are common to many archiving programs, including
647      tar.  In particular, carefully-crafted archives can request that tar
648      extract files to locations outside of the target directory.  This can
649      potentially be used to cause unwitting users to overwrite files they did
650      not intend to overwrite.  If the archive is being extracted by the supe‐
651      ruser, any file on the system can potentially be overwritten.  There are
652      three ways this can happen.  Although tar has mechanisms to protect
653      against each one, savvy users should be aware of the implications:
654
655      ·      Archive entries can have absolute pathnames.  By default, tar
656              removes the leading / character from filenames before restoring
657              them to guard against this problem.
658
659      ·      Archive entries can have pathnames that include .. components.
660              By default, tar will not extract files containing .. components
661              in their pathname.
662
663      ·      Archive entries can exploit symbolic links to restore files to
664              other directories.  An archive can restore a symbolic link to
665              another directory, then use that link to restore a file into that
666              directory.  To guard against this, tar checks each extracted path
667              for symlinks.  If the final path element is a symlink, it will be
668              removed and replaced with the archive entry.  If -U is specified,
669              any intermediate symlink will also be unconditionally removed.
670              If neither -U nor -P is specified, tar will refuse to extract the
671              entry.
672      To protect yourself, you should be wary of any archives that come from
673      untrusted sources.  You should examine the contents of an archive with
674            tar -tf filename
675      before extraction.  You should use the -k option to ensure that tar will
676      not overwrite any existing files or the -U option to remove any pre-
677      existing files.  You should generally not extract archives while running
678      with super-user privileges.  Note that the -P option to tar disables the
679      security checks above and allows you to extract an archive while preserv‐
680      ing any absolute pathnames, .. components, or symlinks to other directo‐
681      ries.
682
683 SEE ALSO
684      bzip2(1), compress(1), cpio(1), gzip(1), mt(1), pax(1), shar(1), xz(1),
685      libarchive(3), libarchive-formats(5), tar(5)
686
687 STANDARDS
688      There is no current POSIX standard for the tar command; it appeared in
689      ISO/IEC 9945-1:1996 (“POSIX.1”) but was dropped from IEEE Std 1003.1-2001
690      (“POSIX.1”).  The options supported by this implementation were developed
691      by surveying a number of existing tar implementations as well as the old
692      POSIX specification for tar and the current POSIX specification for pax.
693
694      The ustar and pax interchange file formats are defined by IEEE Std
695      1003.1-2001 (“POSIX.1”) for the pax command.
696
697 HISTORY
698      A tar command appeared in Seventh Edition Unix, which was released in
699      January, 1979.  There have been numerous other implementations, many of
700      which extended the file format.  John Gilmore's pdtar public-domain
701      implementation (circa November, 1987) was quite influential, and formed
702      the basis of GNU tar.  GNU tar was included as the standard system tar in
703      FreeBSD beginning with FreeBSD 1.0.
704
705      This is a complete re-implementation based on the libarchive(3) library.
706      It was first released with FreeBSD 5.4 in May, 2005.
707
708 BUGS
709      This program follows ISO/IEC 9945-1:1996 (“POSIX.1”) for the definition
710      of the -l option.  Note that GNU tar prior to version 1.15 treated -l as
711      a synonym for the --one-file-system option.
712
713      The -C dir option may differ from historic implementations.
714
715      All archive output is written in correctly-sized blocks, even if the out‐
716      put is being compressed.  Whether or not the last output block is padded
717      to a full block size varies depending on the format and the output
718      device.  For tar and cpio formats, the last block of output is padded to
719      a full block size if the output is being written to standard output or to
720      a character or block device such as a tape drive.  If the output is being
721      written to a regular file, the last block will not be padded.  Many com‐
722      pressors, including gzip(1) and bzip2(1), complain about the null padding
723      when decompressing an archive created by tar, although they still extract
724      it correctly.
725
726      The compression and decompression is implemented internally, so there may
727      be insignificant differences between the compressed output generated by
728            tar -czf - file
729      and that generated by
730            tar -cf - file | gzip
731
732      The default should be to read and write archives to the standard I/O
733      paths, but tradition (and POSIX) dictates otherwise.
734
735      The r and u modes require that the archive be uncompressed and located in
736      a regular file on disk.  Other archives can be modified using c mode with
737      the @archive-file extension.
738
739      To archive a file called @foo or -foo you must specify it as ./@foo or
740      ./-foo, respectively.
741
742      In create mode, a leading ./ is always removed.  A leading / is stripped
743      unless the -P option is specified.
744
745      There needs to be better support for file selection on both create and
746      extract.
747
748      There is not yet any support for multi-volume archives.
749
750      Converting between dissimilar archive formats (such as tar and cpio)
751      using the @- convention can cause hard link information to be lost.
752      (This is a consequence of the incompatible ways that different archive
753      formats store hardlink information.)
754
755 BSD                           September 16, 2014                           BSD