1 .\" Copyright (c) 2003-2007 Tim Kientzle
2 .\" Copyright (c) 2017 Martin Matuska
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd manipulate tape archives
36 .Op Ar bundled-flags Ao args Ac
37 .Op Ao Ar file Ac | Ao Ar pattern Ac ...
41 .Op Ar files | Ar directories
46 .Op Ar files | Ar directories
53 creates and manipulates streaming archive files.
54 This implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
55 rpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
56 7-zip, and shar archives.
58 The first synopsis form shows a
61 This usage is provided for compatibility with historical implementations.
62 See COMPATIBILITY below for details.
64 The other synopsis forms show the preferred usage.
67 is a mode indicator from the following list:
68 .Bl -tag -compact -width indent
70 Create a new archive containing the specified items.
71 The long option form is
76 but new entries are appended to the archive.
77 Note that this only works on uncompressed archives stored in regular files.
81 The long option form is
84 List archive contents to stdout.
85 The long option form is
90 but new entries are added only if they have a modification date
91 newer than the corresponding entry in the archive.
92 Note that this only works on uncompressed archives stored in regular files.
99 Extract to disk from the archive.
100 If a file with the same name appears more than once in the archive,
101 each copy will be extracted, with later copies overwriting (replacing)
103 The long option form is
112 mode, each specified file or directory is added to the
113 archive in the order specified on the command line.
114 By default, the contents of each directory are also archived.
116 In extract or list mode, the entire command line
117 is read and parsed before the archive is opened.
118 The pathnames or patterns on the command line indicate
119 which items in the archive should be processed.
120 Patterns are shell-style globbing patterns as
124 Unless specifically stated otherwise, options are applicable in
126 .Bl -tag -width indent
127 .It Cm @ Ns Pa archive
129 The specified archive is opened and the entries
130 in it will be appended to the current archive.
132 .Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
133 writes a new archive to standard output containing a file
135 and all of the entries from
138 .Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
139 creates a new archive with only two entries.
141 .Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
142 reads an archive from standard input (whose format will be determined
143 automatically) and converts it into a gzip-compressed
144 pax-format archive on stdout.
147 can be used to convert archives from one format to another.
148 .It Fl a , Fl Fl auto-compress
150 Use the archive suffix to decide a set of the format and
153 .Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h
154 creates a new archive with restricted pax format and gzip compression,
155 .Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h
156 creates a new archive with restricted pax format and bzip2 compression
157 and uuencode compression,
158 .Dl Nm Fl a Fl cf Pa archive.zip source.c source.h
159 creates a new archive with zip format,
160 .Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h
163 option, and creates a new archive with restricted pax format
164 and gzip compression,
165 .Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h
166 if it is unknown suffix or no suffix, creates a new archive with
167 restricted pax format and bzip2 compression.
169 (c, r, u, x modes only)
170 Archive or extract POSIX.1e or NFSv4 ACLs.
171 This is the reverse of
173 and the default behavior in c, r, and u modes (except on Mac OS X) or if
175 is run in x mode as root.
176 On Mac OS X this option translates extended ACLs to NFSv4 ACLs.
177 To store extended ACLs the
180 .It Fl B , Fl Fl read-full-blocks
181 Ignored for compatibility with other
184 .It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
185 Specify the block size, in 512-byte records, for tape drive I/O.
186 As a rule, this argument is only needed when reading from or writing
187 to tape drives, and usually not even then as the default block size of
188 20 records (10240 bytes) is very common.
189 .It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
190 In c and r mode, this changes the directory before adding
192 In x mode, change directories after opening the archive
193 but before extracting entries from the archive.
197 to the current directory after processing any
199 options and before extracting any files.
200 .It Fl Fl clear-nochange-fflags
202 Before removing file system objects to replace them, clear platform-specific
203 file attributes or file flags that might prevent removal.
204 .It Fl Fl exclude Ar pattern
205 Do not process files or directories that match the
207 Note that exclusions take precedence over patterns or filenames
208 specified on the command line.
209 .It Fl Fl exclude-vcs
210 Do not process files or directories internally used by the
211 version control systems
223 (c, r, u, x modes only)
224 Archive or extract platform-specific file attributes or file flags.
225 This is the reverse of
227 and the default behavior in c, r, and u modes or if
229 is run in x mode as root.
230 .It Fl Fl format Ar format
232 Use the specified format for the created archive.
233 Supported formats include
239 Other formats may also be supported; see
240 .Xr libarchive-formats 5
241 for more information about currently-supported formats.
242 In r and u modes, when extending an existing archive, the format specified
243 here must be compatible with the format of the existing archive on disk.
244 .It Fl f Ar file , Fl Fl file Ar file
245 Read the archive from or write the archive to the specified file.
248 for standard input or standard output.
249 The default varies by system;
254 on Linux, the default is
257 Use the provided group id number.
258 On extract, this overrides the group id in the archive;
259 the group name in the archive will be ignored.
260 On create, this overrides the group id read from disk;
263 is not also specified, the group name will be set to
265 .It Fl Fl gname Ar name
266 Use the provided group name.
267 On extract, this overrides the group name in the archive;
268 if the provided group name does not exist on the system,
270 (from the archive or from the
273 will be used instead.
274 On create, this sets the group name that will be stored
276 the name will not be verified against the system group database.
279 Symbolic links named on the command line will be followed; the
280 target of the link will be archived, not the link itself.
290 .It Fl Fl hfsCompression
292 Mac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
294 .It Fl Fl ignore-zeros
296 .Fl Fl options Cm read_concatenated_archives
297 for compatibility with GNU tar.
298 .It Fl Fl include Ar pattern
299 Process only files or directories that match the specified pattern.
300 Note that exclusions specified with
302 take precedence over inclusions.
303 If no inclusions are explicitly specified, all entries are processed by
307 option is especially useful when filtering archives.
308 For example, the command
309 .Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
310 creates a new archive
312 containing only the entries from
314 containing the string
318 Compress the resulting archive with
320 In extract or list modes, this option is ignored.
323 implementation recognizes XZ compression automatically when reading archives.
324 .It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
326 Compress the resulting archive with
328 In extract or list modes, this option is ignored.
331 implementation recognizes bzip2 compression automatically when reading
333 .It Fl k , Fl Fl keep-old-files
335 Do not overwrite existing files.
336 In particular, if a file appears more than once in an archive,
337 later copies will not overwrite earlier copies.
338 .It Fl Fl keep-newer-files
340 Do not overwrite existing files that are newer than the
341 versions appearing in the archive being extracted.
342 .It Fl L , Fl Fl dereference
344 All symbolic links will be followed.
345 Normally, symbolic links are archived as such.
346 With this option, the target of the link will be archived instead.
347 .It Fl l , Fl Fl check-links
349 Issue a warning message unless all links to each file are archived.
352 Compress the resulting archive with
354 In extract or list modes, this option is ignored.
357 implementation recognizes lrzip compression automatically when reading
361 Compress the archive with lz4-compatible compression before writing it.
362 In extract or list modes, this option is ignored.
365 implementation recognizes lz4 compression automatically when reading archives.
368 Compress the archive with zstd-compatible compression before writing it.
369 In extract or list modes, this option is ignored.
372 implementation recognizes zstd compression automatically when reading archives.
374 (c mode only) Compress the resulting archive with the original LZMA algorithm.
375 In extract or list modes, this option is ignored.
376 Use of this option is discouraged and new archives should be created with
381 implementation recognizes LZMA compression automatically when reading archives.
384 Compress the resulting archive with
386 In extract or list modes, this option is ignored.
389 implementation recognizes LZO compression automatically when reading archives.
390 .It Fl m , Fl Fl modification-time
392 Do not extract modification time.
393 By default, the modification time is set to the time stored in the archive.
394 .It Fl Fl mac-metadata
395 (c, r, u and x mode only)
397 Archive or extract extended ACLs and extended file
400 in AppleDouble format.
401 This is the reverse of
402 .Fl Fl no-mac-metadata .
403 and the default behavior in c, r, and u modes or if
405 is run in x mode as root.
406 .It Fl n , Fl Fl norecurse , Fl Fl no-recursion
407 Do not operate recursively on the content of directories.
408 .It Fl Fl newer Ar date
410 Only include files and directories newer than the specified date.
411 This compares ctime entries.
412 .It Fl Fl newer-mtime Ar date
416 except it compares mtime entries instead of ctime entries.
417 .It Fl Fl newer-than Pa file
419 Only include files and directories newer than the specified file.
420 This compares ctime entries.
421 .It Fl Fl newer-mtime-than Pa file
425 except it compares mtime entries instead of ctime entries.
428 Honor the nodump file flag by skipping this file.
429 .It Fl Fl nopreserveHFSCompression
431 Mac OS X specific (v10.6 or later). Do not compress extracted regular files
432 which were compressed with HFS+ compression before archived.
433 By default, compress the regular files again with HFS+ compression.
439 Filenames or patterns are separated by null characters,
441 This is often used to read filenames output by the
446 (c, r, u, x modes only)
447 Do not archive or extract POSIX.1e or NFSv4 ACLs.
448 This is the reverse of
450 and the default behavior if
452 is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
454 (c, r, u, x modes only)
455 Do not archive or extract file attributes or file flags.
456 This is the reverse of
458 and the default behavior if
460 is run as non-root in x mode.
461 .It Fl Fl no-mac-metadata
464 Do not archive or extract ACLs and extended file attributes
467 in AppleDouble format.
468 This is the reverse of
469 .Fl Fl mac-metadata .
470 and the default behavior if
472 is run as non-root in x mode.
473 .It Fl Fl no-safe-writes
475 Do not create temporary files and use
477 to replace the original ones.
478 This is the reverse of
480 .It Fl Fl no-same-owner
482 Do not extract owner and group IDs.
483 This is the reverse of
485 and the default behavior if
488 .It Fl Fl no-same-permissions
490 Do not extract full permissions (SGID, SUID, sticky bit,
491 file attributes or file flags, extended file attributes and ACLs).
492 This is the reverse of
494 and the default behavior if
498 (c, r, u, x modes only)
499 Do not archive or extract extended file attributes.
500 This is the reverse of
502 and the default behavior if
504 is run as non-root in x mode.
505 .It Fl Fl numeric-owner
506 This is equivalent to
511 On extract, it causes user and group names in the archive
512 to be ignored in favor of the numeric user and group ids.
513 On create, it causes user and group names to not be stored
515 .It Fl O , Fl Fl to-stdout
517 In extract (-x) mode, files will be written to standard out rather than
518 being extracted to disk.
519 In list (-t) mode, the file listing will be written to stderr rather than
523 Use the user and group of the user running the program rather
524 than those specified in the archive.
525 Note that this has no significance unless
527 is specified, and the program is being run by the root user.
528 In this case, the file modes and flags from
529 the archive will be restored, but ACLs or owner information in
530 the archive will be discarded.
534 .Fl Fl format Ar ustar
535 .It Fl Fl older Ar date
537 Only include files and directories older than the specified date.
538 This compares ctime entries.
539 .It Fl Fl older-mtime Ar date
543 except it compares mtime entries instead of ctime entries.
544 .It Fl Fl older-than Pa file
546 Only include files and directories older than the specified file.
547 This compares ctime entries.
548 .It Fl Fl older-mtime-than Pa file
552 except it compares mtime entries instead of ctime entries.
553 .It Fl Fl one-file-system
555 Do not cross mount points.
556 .It Fl Fl options Ar options
557 Select optional behaviors for particular modules.
558 The argument is a text string containing comma-separated
560 These are passed to the modules that handle particular
561 formats to control how those formats will behave.
562 Each option has one of the following forms:
563 .Bl -tag -compact -width indent
565 The key will be set to the specified value in every module that supports it.
566 Modules that do not support this key will ignore it.
568 The key will be enabled in every module that supports it.
569 This is equivalent to
572 The key will be disabled in every module that supports it.
573 .It Ar module:key=value , Ar module:key , Ar module:!key
574 As above, but the corresponding key and value will be provided
575 only to modules whose name matches
579 The complete list of supported modules and keys
580 for create and append modes is in
581 .Xr archive_write_set_options 3
582 and for extract and list modes in
583 .Xr archive_read_set_options 3 .
585 Examples of supported options:
586 .Bl -tag -compact -width indent
587 .It Cm iso9660:joliet
588 Support Joliet extensions.
589 This is enabled by default, use
594 .It Cm iso9660:rockridge
595 Support Rock Ridge extensions.
596 This is enabled by default, use
599 .Cm iso9660:!rockridge
601 .It Cm gzip:compression-level
602 A decimal integer from 1 to 9 specifying the gzip compression level.
603 .It Cm gzip:timestamp
605 This is enabled by default, use
610 .It Cm lrzip:compression Ns = Ns Ar type
613 as compression method.
614 Supported values are bzip2, gzip, lzo (ultra fast),
615 and zpaq (best, extremely slow).
616 .It Cm lrzip:compression-level
617 A decimal integer from 1 to 9 specifying the lrzip compression level.
618 .It Cm lz4:compression-level
619 A decimal integer from 1 to 9 specifying the lzop compression level.
620 .It Cm lz4:stream-checksum
621 Enable stream checksum.
622 This is by default, use
623 .Cm lz4:!stream-checksum
625 .It Cm lz4:block-checksum
626 Enable block checksum (Disabled by default).
627 .It Cm lz4:block-size
628 A decimal integer from 4 to 7 specifying the lz4 compression block size
629 (7 is set by default).
630 .It Cm lz4:block-dependence
631 Use the previous block of the block being compressed for
632 a compression dictionary to improve compression ratio.
633 .It Cm zstd:compression-level
634 A decimal integer from 1 to 22 specifying the zstd compression level.
635 .It Cm lzop:compression-level
636 A decimal integer from 1 to 9 specifying the lzop compression level.
637 .It Cm xz:compression-level
638 A decimal integer from 0 to 9 specifying the xz compression level.
639 .It Cm mtree: Ns Ar keyword
640 The mtree writer module allows you to specify which mtree keywords
641 will be included in the output.
642 Supported keywords include:
643 .Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
644 .Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
645 .Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
646 The default is equivalent to:
647 .Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
649 Enables all of the above keywords.
652 to disable all keywords.
658 Produce human-readable output by indenting options and splitting lines
659 to fit into 80 columns.
660 .It Cm zip:compression Ns = Ns Ar type
663 as compression method.
664 Supported values are store (uncompressed) and deflate (gzip algorithm).
665 .It Cm zip:encryption
666 Enable encryption using traditional zip encryption.
667 .It Cm zip:encryption Ns = Ns Ar type
671 Supported values are zipcrypt (traditional zip encryption),
672 aes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
673 .It Cm read_concatenated_archives
674 Ignore zeroed blocks in the archive, which occurs when multiple tar archives
675 have been concatenated together.
676 Without this option, only the contents of
677 the first concatenated archive would be read.
678 This option is comparable to the
679 .Fl i , Fl Fl ignore-zeros
682 If a provided option is not supported by any module, that
684 .It Fl P , Fl Fl absolute-paths
686 By default, absolute pathnames (those that begin with a /
687 character) have the leading slash removed both when creating archives
688 and extracting from them.
691 will refuse to extract archive entries whose pathnames contain
693 or whose target directory would be altered by a symlink.
694 This option suppresses these behaviors.
695 .It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
697 Preserve file permissions.
698 Attempt to restore the full permissions, including file modes, file attributes
699 or file flags, extended file attributes and ACLs, if available, for each item
700 extracted from the archive.
701 This is the reverse of
702 .Fl Fl no-same-permissions
705 is being run as root.
706 It can be partially overridden by also specifying
709 .Fl Fl no-mac-metadata
712 .It Fl Fl passphrase Ar passphrase
715 is used to extract or create an encrypted archive.
716 Currently, zip is the only supported format that supports encryption.
717 You shouldn't use this option unless you realize how insecure
718 use of this option is.
723 .It Fl q , Fl Fl fast-read
725 Extract or list only the first archive entry that matches each pattern
727 Exit as soon as each specified pattern or filename has been matched.
728 By default, the archive is always read to the very end, since
729 there can be multiple entries with the same name and, by convention,
730 later entries overwrite earlier entries.
731 This option is provided as a performance optimization.
734 Extract files as sparse files.
735 For every block on disk, check first if it contains only NULL bytes and seek
737 This works similar to the conv=sparse option of dd.
739 Modify file or archive member names according to
741 The pattern has the format
742 .Ar /old/new/ Ns Op ghHprRsS
745 is a basic regular expression,
747 is the replacement string of the matched part,
748 and the optional trailing letters modify
749 how the replacement is handled.
752 is not matched, the pattern is skipped.
755 ~ is substituted with the match, \e1 to \e9 with the content of
756 the corresponding captured group.
757 The optional trailing g specifies that matching should continue
758 after the matched part and stop on the first unmatched pattern.
759 The optional trailing s specifies that the pattern applies to the value
761 The optional trailing p specifies that after a successful substitution
762 the original path name and the new path name should be printed to
764 Optional trailing H, R, or S characters suppress substitutions
765 for hardlink targets, regular filenames, or symlink targets,
767 Optional trailing h, r, or s characters enable substitutions
768 for hardlink targets, regular filenames, or symlink targets,
772 which applies substitutions to all names.
773 In particular, it is never necessary to specify h, r, or s.
774 .It Fl Fl safe-writes
776 Extract files atomically.
779 unlinks the original file with the same name as the extracted file (if it
780 exists), and then creates it immediately under the same name and writes to
782 For a short period of time, applications trying to access the file might
783 not find it, or see incomplete results.
788 first creates a unique temporary file, then writes the new contents to
789 the temporary file, and finally renames the temporary file to its final
790 name atomically using
792 This guarantees that an application accessing the file, will either see
793 the old contents or the new contents at all times.
796 Extract owner and group IDs.
797 This is the reverse of
799 and the default behavior if
802 .It Fl Fl strip-components Ar count
803 Remove the specified number of leading path elements.
804 Pathnames with fewer elements will be silently skipped.
805 Note that the pathname is edited after checking inclusion/exclusion patterns
806 but before security checks.
807 .It Fl T Ar filename , Fl Fl files-from Ar filename
810 will read the list of names to be extracted from
814 will read names to be archived from
818 on a line by itself will cause the current directory to be changed to
819 the directory specified on the following line.
820 Names are terminated by newlines unless
825 also disables the special handling of lines containing
827 Note: If you are generating lists of files using
829 you probably want to use
834 After archiving all files, print a summary to stderr.
835 .It Fl U , Fl Fl unlink , Fl Fl unlink-first
837 Unlink files before creating them.
838 This can be a minor performance optimization if most files
839 already exist, but can make things slower if most files
840 do not already exist.
841 This flag also causes
843 to remove intervening directory symlinks instead of
845 See the SECURITY section below for more details.
847 Use the provided user id number and ignore the user
848 name from the archive.
851 is not also specified, the user name will be set to
853 .It Fl Fl uname Ar name
854 Use the provided user name.
855 On extract, this overrides the user name in the archive;
856 if the provided user name does not exist on the system,
857 it will be ignored and the user id
858 (from the archive or from the
861 will be used instead.
862 On create, this sets the user name that will be stored
864 the name is not verified against the system user database.
865 .It Fl Fl use-compress-program Ar program
866 Pipe the input (in x or t mode) or the output (in c mode) through
868 instead of using the builtin compression support.
869 .It Fl v , Fl Fl verbose
870 Produce verbose output.
871 In create and extract modes,
873 will list each file name as it is read from or written to
877 will produce output similar to that of
881 option will also provide ls-like details in create and extract mode.
888 .It Fl w , Fl Fl confirmation , Fl Fl interactive
889 Ask for confirmation for every action.
890 .It Fl X Ar filename , Fl Fl exclude-from Ar filename
891 Read a list of exclusion patterns from the specified file.
894 for more information about the handling of exclusions.
896 (c, r, u, x modes only)
897 Archive or extract extended file attributes.
898 This is the reverse of
900 and the default behavior in c, r, and u modes or if
902 is run in x mode as root.
905 Compress the resulting archive with
907 In extract or list modes, this option is ignored.
910 implementation recognizes bzip2 compression automatically when reading
912 .It Fl Z , Fl Fl compress , Fl Fl uncompress
914 Compress the resulting archive with
916 In extract or list modes, this option is ignored.
919 implementation recognizes compress compression automatically when reading
921 .It Fl z , Fl Fl gunzip , Fl Fl gzip
923 Compress the resulting archive with
925 In extract or list modes, this option is ignored.
928 implementation recognizes gzip compression automatically when reading
932 The following environment variables affect the execution of
934 .Bl -tag -width ".Ev BLOCKSIZE"
935 .It Ev TAR_READER_OPTIONS
936 The default options for format readers and compression readers.
939 option overrides this.
940 .It Ev TAR_WRITER_OPTIONS
941 The default options for format writers and compression writers.
944 option overrides this.
949 for more information.
954 option overrides this.
955 Please see the description of the
957 option above for more details.
959 The timezone to use when displaying dates.
962 for more information.
967 The following creates a new archive
970 that contains two files
974 .Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
976 To view a detailed table of contents for this
978 .Dl Nm Fl tvf Pa file.tar.gz
980 To extract all entries from the archive on
981 the default tape drive:
984 To examine the contents of an ISO 9660 cdrom image:
985 .Dl Nm Fl tf Pa image.iso
987 To move file hierarchies, invoke
990 .Dl Nm Fl cf Pa - Fl C Pa srcdir \&. | Nm Fl xpf Pa - Fl C Pa destdir
991 or more traditionally
992 .Dl cd srcdir \&; Nm Fl cf Pa - \&. | ( cd destdir \&; Nm Fl xpf Pa - )
994 In create mode, the list of files and directories to be archived
995 can also include directory change instructions of the form
997 and archive inclusions of the form
998 .Cm @ Ns Pa archive-file .
999 For example, the command line
1000 .Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
1001 will create a new archive
1006 from the current directory and add it to the output archive.
1007 It will then read each entry from
1009 and add those entries to the output archive.
1010 Finally, it will switch to the
1014 to the output archive.
1018 format can be used to create an output archive with arbitrary ownership,
1019 permissions, or names that differ from existing data on disk:
1020 .Bd -literal -offset indent
1023 usr/bin uid=0 gid=0 mode=0755 type=dir
1024 usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
1025 $ tar -cvf output.tar @input.mtree
1032 switches accept a variety of common date and time specifications, including
1033 .Dq 12 Mar 2005 7:14:29pm ,
1034 .Dq 2005-03-12 19:14 ,
1037 .Dq 19:14 PST May 1 .
1041 argument can be used to control various details of archive generation
1043 For example, you can generate mtree output which only contains
1044 .Cm type , Cm time ,
1048 .Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
1049 or you can set the compression level used by gzip or xz compression:
1050 .Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
1051 For more details, see the explanation of the
1052 .Fn archive_read_set_options
1054 .Fn archive_write_set_options
1055 API calls that are described in
1058 .Xr archive_write 3 .
1060 The bundled-arguments format is supported for compatibility
1061 with historic implementations.
1062 It consists of an initial word (with no leading - character) in which
1063 each character indicates an option.
1064 Arguments follow as separate words.
1065 The order of the arguments must match the order
1066 of the corresponding characters in the bundled command word.
1068 .Dl Nm Cm tbf 32 Pa file.tar
1069 specifies three flags
1078 flags both require arguments,
1079 so there must be two additional items
1080 on the command line.
1083 is the argument to the
1087 is the argument to the
1091 The mode options c, r, t, u, and x and the options
1092 b, f, l, m, o, v, and w comply with SUSv2.
1094 For maximum portability, scripts that invoke
1096 should use the bundled-argument format above, should limit
1111 Additional long options are provided to improve compatibility with other
1112 tar implementations.
1114 Certain security issues are common to many archiving programs, including
1116 In particular, carefully-crafted archives can request that
1118 extract files to locations outside of the target directory.
1119 This can potentially be used to cause unwitting users to overwrite
1120 files they did not intend to overwrite.
1121 If the archive is being extracted by the superuser, any file
1122 on the system can potentially be overwritten.
1123 There are three ways this can happen.
1126 has mechanisms to protect against each one,
1127 savvy users should be aware of the implications:
1128 .Bl -bullet -width indent
1130 Archive entries can have absolute pathnames.
1135 character from filenames before restoring them to guard against this problem.
1137 Archive entries can have pathnames that include
1142 will not extract files containing
1144 components in their pathname.
1146 Archive entries can exploit symbolic links to restore
1147 files to other directories.
1148 An archive can restore a symbolic link to another directory,
1149 then use that link to restore a file into that directory.
1150 To guard against this,
1152 checks each extracted path for symlinks.
1153 If the final path element is a symlink, it will be removed
1154 and replaced with the archive entry.
1157 is specified, any intermediate symlink will also be unconditionally removed.
1164 will refuse to extract the entry.
1166 To protect yourself, you should be wary of any archives that
1167 come from untrusted sources.
1168 You should examine the contents of an archive with
1169 .Dl Nm Fl tf Pa filename
1173 option to ensure that
1175 will not overwrite any existing files or the
1177 option to remove any pre-existing files.
1178 You should generally not extract archives while running with super-user
1184 disables the security checks above and allows you to extract
1185 an archive while preserving any absolute pathnames,
1187 components, or symlinks to other directories.
1198 .Xr libarchive-formats 5 ,
1201 There is no current POSIX standard for the tar command; it appeared
1204 but was dropped from
1206 The options supported by this implementation were developed by surveying a
1207 number of existing tar implementations as well as the old POSIX specification
1208 for tar and the current POSIX specification for pax.
1210 The ustar and pax interchange file formats are defined by
1212 for the pax command.
1216 command appeared in Seventh Edition Unix, which was released in January, 1979.
1217 There have been numerous other implementations,
1218 many of which extended the file format.
1221 public-domain implementation (circa November, 1987)
1222 was quite influential, and formed the basis of GNU tar.
1223 GNU tar was included as the standard system tar
1229 This is a complete re-implementation based on the
1232 It was first released with
1236 This program follows
1238 for the definition of the
1241 Note that GNU tar prior to version 1.15 treated
1243 as a synonym for the
1244 .Fl Fl one-file-system
1249 option may differ from historic implementations.
1251 All archive output is written in correctly-sized blocks, even
1252 if the output is being compressed.
1253 Whether or not the last output block is padded to a full
1254 block size varies depending on the format and the
1256 For tar and cpio formats, the last block of output is padded
1257 to a full block size if the output is being
1258 written to standard output or to a character or block device such as
1260 If the output is being written to a regular file, the last block
1262 Many compressors, including
1266 complain about the null padding when decompressing an archive created by
1268 although they still extract it correctly.
1270 The compression and decompression is implemented internally, so
1271 there may be insignificant differences between the compressed output
1273 .Dl Nm Fl czf Pa - file
1274 and that generated by
1275 .Dl Nm Fl cf Pa - file | Nm gzip
1277 The default should be to read and write archives to the standard I/O paths,
1278 but tradition (and POSIX) dictates otherwise.
1284 modes require that the archive be uncompressed
1285 and located in a regular file on disk.
1286 Other archives can be modified using
1292 To archive a file called
1296 you must specify it as
1302 In create mode, a leading
1307 is stripped unless the
1309 option is specified.
1311 There needs to be better support for file selection on both create
1314 There is not yet any support for multi-volume archives.
1316 Converting between dissimilar archive formats (such as tar and cpio) using the
1318 convention can cause hard link information to be lost.
1319 (This is a consequence of the incompatible ways that different archive
1320 formats store hardlink information.)