]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - usr.bin/tar/bsdtar.1
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / usr.bin / tar / bsdtar.1
1 .\" Copyright (c) 2003-2007 Tim Kientzle
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd May 15, 2008
28 .Dt BSDTAR 1
29 .Os
30 .Sh NAME
31 .Nm tar
32 .Nd manipulate tape archives
33 .Sh SYNOPSIS
34 .Nm
35 .Op Ar bundled-flags Ao args Ac
36 .Op Ao Ar file Ac | Ao Ar pattern Ac ...
37 .Nm
38 .Brq Fl c
39 .Op Ar options
40 .Op Ar files | directories
41 .Nm
42 .Brq Fl r | Fl u
43 .Fl f Ar archive-file
44 .Op Ar options
45 .Op Ar files | directories
46 .Nm
47 .Brq Fl t | Fl x
48 .Op Ar options
49 .Op Ar patterns
50 .Sh DESCRIPTION
51 .Nm
52 creates and manipulates streaming archive files.
53 This implementation can extract from tar, pax, cpio, zip, jar, ar,
54 and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
55 and shar archives.
56 .Pp
57 The first synopsis form shows a
58 .Dq bundled
59 option word.
60 This usage is provided for compatibility with historical implementations.
61 See COMPATIBILITY below for details.
62 .Pp
63 The other synopsis forms show the preferred usage.
64 The first option to
65 .Nm
66 is a mode indicator from the following list:
67 .Bl -tag -compact -width indent
68 .It Fl c
69 Create a new archive containing the specified items.
70 .It Fl r
71 Like
72 .Fl c ,
73 but new entries are appended to the archive.
74 Note that this only works on uncompressed archives stored in regular files.
75 The
76 .Fl f
77 option is required.
78 .It Fl t
79 List archive contents to stdout.
80 .It Fl u
81 Like
82 .Fl r ,
83 but new entries are added only if they have a modification date
84 newer than the corresponding entry in the archive.
85 Note that this only works on uncompressed archives stored in regular files.
86 The
87 .Fl f
88 option is required.
89 .It Fl x
90 Extract to disk from the archive.
91 If a file with the same name appears more than once in the archive,
92 each copy will be extracted, with later copies overwriting (replacing)
93 earlier copies.
94 .El
95 .Pp
96 In
97 .Fl c ,
98 .Fl r ,
99 or
100 .Fl u
101 mode, each specified file or directory is added to the
102 archive in the order specified on the command line.
103 By default, the contents of each directory are also archived.
104 .Pp
105 In extract or list mode, the entire command line
106 is read and parsed before the archive is opened.
107 The pathnames or patterns on the command line indicate
108 which items in the archive should be processed.
109 Patterns are shell-style globbing patterns as
110 documented in
111 .Xr tcsh 1 .
112 .Sh OPTIONS
113 Unless specifically stated otherwise, options are applicable in
114 all operating modes.
115 .Bl -tag -width indent
116 .It Cm @ Ns Pa archive
117 (c and r mode only)
118 The specified archive is opened and the entries
119 in it will be appended to the current archive.
120 As a simple example,
121 .Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
122 writes a new archive to standard output containing a file
123 .Pa newfile
124 and all of the entries from
125 .Pa original.tar .
126 In contrast,
127 .Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
128 creates a new archive with only two entries.
129 Similarly,
130 .Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa -
131 reads an archive from standard input (whose format will be determined
132 automatically) and converts it into a gzip-compressed
133 pax-format archive on stdout.
134 In this way,
135 .Nm
136 can be used to convert archives from one format to another.
137 .It Fl b Ar blocksize
138 Specify the block size, in 512-byte records, for tape drive I/O.
139 As a rule, this argument is only needed when reading from or writing
140 to tape drives, and usually not even then as the default block size of
141 20 records (10240 bytes) is very common.
142 .It Fl C Ar directory
143 In c and r mode, this changes the directory before adding
144 the following files.
145 In x mode, change directories after opening the archive
146 but before extracting entries from the archive.
147 .It Fl -check-links ( Fl W Cm check-links )
148 (c and r modes only)
149 Issue a warning message unless all links to each file are archived.
150 .It Fl -chroot ( Fl W Cm chroot )
151 (x mode only)
152 .Fn chroot
153 to the current directory after processing any
154 .Fl C
155 options and before extracting any files.
156 .It Fl -exclude Ar pattern ( Fl W Cm exclude Ns = Ns Ar pattern )
157 Do not process files or directories that match the
158 specified pattern.
159 Note that exclusions take precedence over patterns or filenames
160 specified on the command line.
161 .It Fl -format Ar format ( Fl W Cm format Ns = Ns Ar format )
162 (c, r, u mode only)
163 Use the specified format for the created archive.
164 Supported formats include
165 .Dq cpio ,
166 .Dq pax ,
167 .Dq shar ,
168 and
169 .Dq ustar .
170 Other formats may also be supported; see
171 .Xr libarchive-formats 5
172 for more information about currently-supported formats.
173 In r and u modes, when extending an existing archive, the format specified
174 here must be compatible with the format of the existing archive on disk.
175 .It Fl f Ar file
176 Read the archive from or write the archive to the specified file.
177 The filename can be
178 .Pa -
179 for standard input or standard output.
180 If not specified, the default tape device will be used.
181 (On
182 .Fx ,
183 the default tape device is
184 .Pa /dev/sa0 . )
185 .It Fl H
186 (c and r mode only)
187 Symbolic links named on the command line will be followed; the
188 target of the link will be archived, not the link itself.
189 .It Fl h
190 (c and r mode only)
191 Synonym for
192 .Fl L .
193 .It Fl I
194 Synonym for
195 .Fl T .
196 .It Fl -include Ar pattern ( Fl W Cm include Ns = Ns Ar pattern )
197 Process only files or directories that match the specified pattern.
198 Note that exclusions specified with
199 .Fl -exclude
200 take precedence over inclusions.
201 If no inclusions are explicitly specified, all entries are processed by
202 default.
203 The
204 .Fl -include
205 option is especially useful when filtering archives.
206 For example, the command
207 .Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz
208 creates a new archive
209 .Pa new.tar
210 containing only the entries from
211 .Pa old.tgz
212 containing the string
213 .Sq foo .
214 .It Fl j
215 (c mode only)
216 Compress the resulting archive with
217 .Xr bzip2 1 .
218 In extract or list modes, this option is ignored.
219 Note that, unlike other
220 .Nm tar
221 implementations, this implementation recognizes bzip2 compression
222 automatically when reading archives.
223 .It Fl k
224 (x mode only)
225 Do not overwrite existing files.
226 In particular, if a file appears more than once in an archive,
227 later copies will not overwrite earlier copies.
228 .It Fl -keep-newer-files ( Fl W Cm keep-newer-files )
229 (x mode only)
230 Do not overwrite existing files that are newer than the
231 versions appearing in the archive being extracted.
232 .It Fl L
233 (c and r mode only)
234 All symbolic links will be followed.
235 Normally, symbolic links are archived as such.
236 With this option, the target of the link will be archived instead.
237 .It Fl l
238 This is a synonym for the
239 .Fl -check-links
240 option.
241 .It Fl m
242 (x mode only)
243 Do not extract modification time.
244 By default, the modification time is set to the time stored in the archive.
245 .It Fl n
246 (c, r, u modes only)
247 Do not recursively archive the contents of directories.
248 .It Fl -newer Ar date ( Fl W Cm newer Ns = Ns Ar date )
249 (c, r, u modes only)
250 Only include files and directories newer than the specified date.
251 This compares ctime entries.
252 .It Fl -newer-mtime Ar date ( Fl W Cm newer-mtime Ns = Ns Ar date )
253 (c, r, u modes only)
254 Like
255 .Fl -newer ,
256 except it compares mtime entries instead of ctime entries.
257 .It Fl -newer-than Pa file ( Fl W Cm newer-than Ns = Ns Pa file )
258 (c, r, u modes only)
259 Only include files and directories newer than the specified file.
260 This compares ctime entries.
261 .It Fl -newer-mtime-than Pa file ( Fl W Cm newer-mtime-than Ns = Ns Pa file )
262 (c, r, u modes only)
263 Like
264 .Fl -newer-than ,
265 except it compares mtime entries instead of ctime entries.
266 .It Fl -nodump ( Fl W Cm nodump )
267 (c and r modes only)
268 Honor the nodump file flag by skipping this file.
269 .It Fl -null ( Fl W Cm null )
270 (use with
271 .Fl I ,
272 .Fl T ,
273 or
274 .Fl X )
275 Filenames or patterns are separated by null characters,
276 not by newlines.
277 This is often used to read filenames output by the
278 .Fl print0
279 option to
280 .Xr find 1 .
281 .It Fl -numeric-owner
282 (x mode only)
283 Ignore symbolic user and group names when restoring archives to disk,
284 only numeric uid and gid values will be obeyed.
285 .It Fl O
286 (x, t modes only)
287 In extract (-x) mode, files will be written to standard out rather than
288 being extracted to disk.
289 In list (-t) mode, the file listing will be written to stderr rather than
290 the usual stdout.
291 .It Fl o
292 (x mode)
293 Use the user and group of the user running the program rather
294 than those specified in the archive.
295 Note that this has no significance unless
296 .Fl p
297 is specified, and the program is being run by the root user.
298 In this case, the file modes and flags from
299 the archive will be restored, but ACLs or owner information in
300 the archive will be discarded.
301 .It Fl o
302 (c, r, u mode)
303 A synonym for
304 .Fl -format Ar ustar
305 .It Fl -one-file-system ( Fl W Cm one-file-system )
306 (c, r, and u modes)
307 Do not cross mount points.
308 .It Fl P
309 Preserve pathnames.
310 By default, absolute pathnames (those that begin with a /
311 character) have the leading slash removed both when creating archives
312 and extracting from them.
313 Also,
314 .Nm
315 will refuse to extract archive entries whose pathnames contain
316 .Pa ..
317 or whose target directory would be altered by a symlink.
318 This option suppresses these behaviors.
319 .It Fl p
320 (x mode only)
321 Preserve file permissions.
322 Attempt to restore the full permissions, including owner, file modes, file
323 flags and ACLs, if available, for each item extracted from the archive.
324 By default, newly-created files are owned by the user running
325 .Nm ,
326 the file mode is restored for newly-created regular files, and
327 all other types of entries receive default permissions.
328 If
329 .Nm
330 is being run by root, the default is to restore the owner unless the
331 .Fl o
332 option is also specified.
333 .It Fl q ( Fl -fast-read )
334 (x and t mode only)
335 Extract or list only the first archive entry that matches each pattern
336 or filename operand.
337 Exit as soon as each specified pattern or filename has been matched.
338 By default, the archive is always read to the very end, since
339 there can be multiple entries with the same name and, by convention,
340 later entries overwrite earlier entries.
341 This option is provided as a performance optimization.
342 .It Fl S
343 (x mode only)
344 Extract files as sparse files.
345 For every block on disk, check first if it contains only NULL bytes and seek
346 over it otherwise.
347 This works similiar to the conv=sparse option of dd.
348 .It Fl -strip-components Ar count ( Fl W Cm strip-components Ns = Ns Ar count )
349 (x and t mode only)
350 Remove the specified number of leading path elements.
351 Pathnames with fewer elements will be silently skipped.
352 Note that the pathname is edited after checking inclusion/exclusion patterns
353 but before security checks.
354 .It Fl s Ar pattern
355 Modify file or archive member names according to
356 .Pa pattern .
357 The pattern has the format /old/new/[gps].
358 old is a basic regular expression.
359 If it doesn't apply, the pattern is skipped.
360 new is the replacement string of the matched part.
361 ~ is substituted with the match, \1 to \9 with the content of
362 the corresponding captured group.
363 The optional trailing g specifies that matching should continue
364 after the matched part and stopped on the first unmatched pattern.
365 The optional trailing s specifies that the pattern applies to the value
366 of symbolic links.
367 The optional trailing p specifies that after a successful substitution
368 the original path name and the new path name should be printed to
369 standard error.
370 .It Fl T Ar filename
371 In x or t mode,
372 .Nm
373 will read the list of names to be extracted from
374 .Pa filename .
375 In c mode,
376 .Nm
377 will read names to be archived from
378 .Pa filename .
379 The special name
380 .Dq -C
381 on a line by itself will cause the current directory to be changed to
382 the directory specified on the following line.
383 Names are terminated by newlines unless
384 .Fl -null
385 is specified.
386 Note that
387 .Fl -null
388 also disables the special handling of lines containing
389 .Dq -C .
390 .It Fl U
391 (x mode only)
392 Unlink files before creating them.
393 Without this option,
394 .Nm
395 overwrites existing files, which preserves existing hardlinks.
396 With this option, existing hardlinks will be broken, as will any
397 symlink that would affect the location of an extracted file.
398 .It Fl -use-compress-program Ar program
399 Pipe the input (in x or t mode) or the output (in c mode) through
400 .Pa program
401 instead of using the builtin compression support.
402 .It Fl v
403 Produce verbose output.
404 In create and extract modes,
405 .Nm
406 will list each file name as it is read from or written to
407 the archive.
408 In list mode,
409 .Nm
410 will produce output similar to that of
411 .Xr ls 1 .
412 Additional
413 .Fl v
414 options will provide additional detail.
415 .It Fl -version
416 Print version of
417 .Nm
418 and
419 .Nm libarchive ,
420 and exit.
421 .It Fl W Ar longopt=value
422 Long options (preceded by
423 .Fl - )
424 are only supported directly on systems that have the
425 .Xr getopt_long 3
426 function.
427 The
428 .Fl W
429 option can be used to access long options on systems that
430 do not support this function.
431 .It Fl w
432 Ask for confirmation for every action.
433 .It Fl X Ar filename
434 Read a list of exclusion patterns from the specified file.
435 See
436 .Fl -exclude
437 for more information about the handling of exclusions.
438 .It Fl y
439 (c mode only)
440 Compress the resulting archive with
441 .Xr bzip2 1 .
442 In extract or list modes, this option is ignored.
443 Note that, unlike other
444 .Nm tar
445 implementations, this implementation recognizes bzip2 compression
446 automatically when reading archives.
447 .It Fl z
448 (c mode only)
449 Compress the resulting archive with
450 .Xr gzip 1 .
451 In extract or list modes, this option is ignored.
452 Note that, unlike other
453 .Nm tar
454 implementations, this implementation recognizes gzip compression
455 automatically when reading archives.
456 .It Fl Z
457 (c mode only)
458 Compress the resulting archive with
459 .Xr compress 1 .
460 In extract or list modes, this option is ignored.
461 Note that, unlike other
462 .Nm tar
463 implementations, this implementation recognizes compress compression
464 automatically when reading archives.
465 .El
466 .Sh ENVIRONMENT
467 The following environment variables affect the execution of
468 .Nm :
469 .Bl -tag -width ".Ev BLOCKSIZE"
470 .It Ev LANG
471 The locale to use.
472 See
473 .Xr environ 7
474 for more information.
475 .It Ev TAPE
476 The default tape device.
477 The
478 .Fl f
479 option overrides this.
480 .It Ev TZ
481 The timezone to use when displaying dates.
482 See
483 .Xr environ 7
484 for more information.
485 .El
486 .Sh FILES
487 .Bl -tag -width ".Ev BLOCKSIZE"
488 .It Pa /dev/sa0
489 The default tape device, if not overridden by the
490 .Ev TAPE
491 environment variable or the
492 .Fl f
493 option.
494 .El
495 .Sh EXIT STATUS
496 .Ex -std
497 .Sh EXAMPLES
498 The following creates a new archive
499 called
500 .Ar file.tar.gz
501 that contains two files
502 .Ar source.c
503 and
504 .Ar source.h :
505 .Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
506 .Pp
507 To view a detailed table of contents for this
508 archive:
509 .Dl Nm Fl tvf Pa file.tar.gz
510 .Pp
511 To extract all entries from the archive on
512 the default tape drive:
513 .Dl Nm Fl x
514 .Pp
515 To examine the contents of an ISO 9660 cdrom image:
516 .Dl Nm Fl tf Pa image.iso
517 .Pp
518 To move file hierarchies, invoke
519 .Nm
520 as
521 .Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
522 or more traditionally
523 .Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
524 .Pp
525 In create mode, the list of files and directories to be archived
526 can also include directory change instructions of the form
527 .Cm -C Ns Pa foo/baz
528 and archive inclusions of the form
529 .Cm @ Ns Pa archive-file .
530 For example, the command line
531 .Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
532 will create a new archive
533 .Pa new.tar .
534 .Nm
535 will read the file
536 .Pa foo1
537 from the current directory and add it to the output archive.
538 It will then read each entry from
539 .Pa old.tgz
540 and add those entries to the output archive.
541 Finally, it will switch to the
542 .Pa /tmp
543 directory and add
544 .Pa foo2
545 to the output archive.
546 .Pp
547 An input file in
548 .Xr mtree 5
549 format can be used to create an output archive with arbitrary ownership,
550 permissions, or names that differ from existing data on disk:
551 .Pp
552 .Dl $ cat input.mtree
553 .Dl #mtree
554 .Dl usr/bin uid=0 gid=0 mode=0755 type=dir
555 .Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
556 .Dl $ tar -cvf output.tar @input.mtree
557 .Pp
558 The
559 .Fl -newer
560 and
561 .Fl -newer-mtime
562 switches accept a variety of common date and time specifications, including
563 .Dq 12 Mar 2005 7:14:29pm ,
564 .Dq 2005-03-12 19:14 ,
565 .Dq 5 minutes ago ,
566 and
567 .Dq 19:14 PST May 1 .
568 .Sh COMPATIBILITY
569 The bundled-arguments format is supported for compatibility
570 with historic implementations.
571 It consists of an initial word (with no leading - character) in which
572 each character indicates an option.
573 Arguments follow as separate words.
574 The order of the arguments must match the order
575 of the corresponding characters in the bundled command word.
576 For example,
577 .Dl Nm Cm tbf 32 Pa file.tar
578 specifies three flags
579 .Cm t ,
580 .Cm b ,
581 and
582 .Cm f .
583 The
584 .Cm b
585 and
586 .Cm f
587 flags both require arguments,
588 so there must be two additional items
589 on the command line.
590 The
591 .Ar 32
592 is the argument to the
593 .Cm b
594 flag, and
595 .Ar file.tar
596 is the argument to the
597 .Cm f
598 flag.
599 .Pp
600 The mode options c, r, t, u, and x and the options
601 b, f, l, m, o, v, and w comply with SUSv2.
602 .Pp
603 For maximum portability, scripts that invoke
604 .Nm tar
605 should use the bundled-argument format above, should limit
606 themselves to the
607 .Cm c ,
608 .Cm t ,
609 and
610 .Cm x
611 modes, and the
612 .Cm b ,
613 .Cm f ,
614 .Cm m ,
615 .Cm v ,
616 and
617 .Cm w
618 options.
619 .Pp
620 On systems that support getopt_long(), additional long options
621 are available to improve compatibility with other tar implementations.
622 .Sh SECURITY
623 Certain security issues are common to many archiving programs, including
624 .Nm .
625 In particular, carefully-crafted archives can request that
626 .Nm
627 extract files to locations outside of the target directory.
628 This can potentially be used to cause unwitting users to overwrite
629 files they did not intend to overwrite.
630 If the archive is being extracted by the superuser, any file
631 on the system can potentially be overwritten.
632 There are three ways this can happen.
633 Although
634 .Nm
635 has mechanisms to protect against each one,
636 savvy users should be aware of the implications:
637 .Bl -bullet -width indent
638 .It
639 Archive entries can have absolute pathnames.
640 By default,
641 .Nm
642 removes the leading
643 .Pa /
644 character from filenames before restoring them to guard against this problem.
645 .It
646 Archive entries can have pathnames that include
647 .Pa ..
648 components.
649 By default,
650 .Nm
651 will not extract files containing
652 .Pa ..
653 components in their pathname.
654 .It
655 Archive entries can exploit symbolic links to restore
656 files to other directories.
657 An archive can restore a symbolic link to another directory,
658 then use that link to restore a file into that directory.
659 To guard against this,
660 .Nm
661 checks each extracted path for symlinks.
662 If the final path element is a symlink, it will be removed
663 and replaced with the archive entry.
664 If
665 .Fl U
666 is specified, any intermediate symlink will also be unconditionally removed.
667 If neither
668 .Fl U
669 nor
670 .Fl P
671 is specified,
672 .Nm
673 will refuse to extract the entry.
674 .El
675 To protect yourself, you should be wary of any archives that
676 come from untrusted sources.
677 You should examine the contents of an archive with
678 .Dl Nm Fl tf Pa filename
679 before extraction.
680 You should use the
681 .Fl k
682 option to ensure that
683 .Nm
684 will not overwrite any existing files or the
685 .Fl U
686 option to remove any pre-existing files.
687 You should generally not extract archives while running with super-user
688 privileges.
689 Note that the
690 .Fl P
691 option to
692 .Nm
693 disables the security checks above and allows you to extract
694 an archive while preserving any absolute pathnames,
695 .Pa ..
696 components, or symlinks to other directories.
697 .Sh SEE ALSO
698 .Xr bzip2 1 ,
699 .Xr compress 1 ,
700 .Xr cpio 1 ,
701 .Xr gzip 1 ,
702 .Xr mt 1 ,
703 .Xr pax 1 ,
704 .Xr shar 1 ,
705 .Xr libarchive 3 ,
706 .Xr libarchive-formats 5 ,
707 .Xr tar 5
708 .Sh STANDARDS
709 There is no current POSIX standard for the tar command; it appeared
710 in
711 .St -p1003.1-96
712 but was dropped from
713 .St -p1003.1-2001 .
714 The options used by this implementation were developed by surveying a
715 number of existing tar implementations as well as the old POSIX specification
716 for tar and the current POSIX specification for pax.
717 .Pp
718 The ustar and pax interchange file formats are defined by
719 .St -p1003.1-2001
720 for the pax command.
721 .Sh HISTORY
722 A
723 .Nm tar
724 command appeared in Seventh Edition Unix, which was released in January, 1979.
725 There have been numerous other implementations,
726 many of which extended the file format.
727 John Gilmore's
728 .Nm pdtar
729 public-domain implementation (circa November, 1987)
730 was quite influential, and formed the basis of GNU tar.
731 GNU tar was included as the standard system tar
732 in
733 .Fx
734 beginning with
735 .Fx 1.0 .
736 .Pp
737 This is a complete re-implementation based on the
738 .Xr libarchive 3
739 library.
740 .Sh BUGS
741 This program follows
742 .St -p1003.1-96
743 for the definition of the
744 .Fl l
745 option.
746 Note that GNU tar prior to version 1.15 treated
747 .Fl l
748 as a synonym for the
749 .Fl -one-file-system
750 option.
751 .Pp
752 The
753 .Fl C Pa dir
754 option may differ from historic implementations.
755 .Pp
756 All archive output is written in correctly-sized blocks, even
757 if the output is being compressed.
758 Whether or not the last output block is padded to a full
759 block size varies depending on the format and the
760 output device.
761 For tar and cpio formats, the last block of output is padded
762 to a full block size if the output is being
763 written to standard output or to a character or block device such as
764 a tape drive.
765 If the output is being written to a regular file, the last block
766 will not be padded.
767 Many compressors, including
768 .Xr gzip 1
769 and
770 .Xr bzip2 1 ,
771 complain about the null padding when decompressing an archive created by
772 .Nm ,
773 although they still extract it correctly.
774 .Pp
775 The compression and decompression is implemented internally, so
776 there may be insignificant differences between the compressed output
777 generated by
778 .Dl Nm Fl czf Pa - file
779 and that generated by
780 .Dl Nm Fl cf Pa - file | Nm gzip
781 .Pp
782 The default should be to read and write archives to the standard I/O paths,
783 but tradition (and POSIX) dictates otherwise.
784 .Pp
785 The
786 .Cm r
787 and
788 .Cm u
789 modes require that the archive be uncompressed
790 and located in a regular file on disk.
791 Other archives can be modified using
792 .Cm c
793 mode with the
794 .Pa @archive-file
795 extension.
796 .Pp
797 To archive a file called
798 .Pa @foo
799 or
800 .Pa -foo
801 you must specify it as
802 .Pa ./@foo
803 or
804 .Pa ./-foo ,
805 respectively.
806 .Pp
807 In create mode, a leading
808 .Pa ./
809 is always removed.
810 A leading
811 .Pa /
812 is stripped unless the
813 .Fl P
814 option is specified.
815 .Pp
816 There needs to be better support for file selection on both create
817 and extract.
818 .Pp
819 There is not yet any support for multi-volume archives or for archiving
820 sparse files.
821 .Pp
822 Converting between dissimilar archive formats (such as tar and cpio) using the
823 .Cm @ Ns Pa -
824 convention can cause hard link information to be lost.
825 (This is a consequence of the incompatible ways that different archive
826 formats store hardlink information.)
827 .Pp
828 There are alternative long options for many of the short options that
829 are deliberately not documented.