160b4ad09SPeter Avalos.\" Copyright (c) 2003-2007 Tim Kientzle 2e95abc47Szrj.\" Copyright (c) 2017 Martin Matuska 360b4ad09SPeter Avalos.\" All rights reserved. 460b4ad09SPeter Avalos.\" 560b4ad09SPeter Avalos.\" Redistribution and use in source and binary forms, with or without 660b4ad09SPeter Avalos.\" modification, are permitted provided that the following conditions 760b4ad09SPeter Avalos.\" are met: 860b4ad09SPeter Avalos.\" 1. Redistributions of source code must retain the above copyright 960b4ad09SPeter Avalos.\" notice, this list of conditions and the following disclaimer. 1060b4ad09SPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright 1160b4ad09SPeter Avalos.\" notice, this list of conditions and the following disclaimer in the 1260b4ad09SPeter Avalos.\" documentation and/or other materials provided with the distribution. 1360b4ad09SPeter Avalos.\" 1460b4ad09SPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1560b4ad09SPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1660b4ad09SPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1760b4ad09SPeter Avalos.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1860b4ad09SPeter Avalos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1960b4ad09SPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2060b4ad09SPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2160b4ad09SPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2260b4ad09SPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2360b4ad09SPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2460b4ad09SPeter Avalos.\" SUCH DAMAGE. 2560b4ad09SPeter Avalos.\" 2659bf7050SPeter Avalos.\" $FreeBSD$ 2760b4ad09SPeter Avalos.\" 28085658deSDaniel Fojt.Dd January 31, 2020 29c09f92d2SPeter Avalos.Dt TAR 1 3060b4ad09SPeter Avalos.Os 3160b4ad09SPeter Avalos.Sh NAME 3260b4ad09SPeter Avalos.Nm tar 3360b4ad09SPeter Avalos.Nd manipulate tape archives 3460b4ad09SPeter Avalos.Sh SYNOPSIS 3560b4ad09SPeter Avalos.Nm 3660b4ad09SPeter Avalos.Op Ar bundled-flags Ao args Ac 3760b4ad09SPeter Avalos.Op Ao Ar file Ac | Ao Ar pattern Ac ... 3860b4ad09SPeter Avalos.Nm 3960b4ad09SPeter Avalos.Brq Fl c 4060b4ad09SPeter Avalos.Op Ar options 418029ab02SPeter Avalos.Op Ar files | Ar directories 4260b4ad09SPeter Avalos.Nm 4360b4ad09SPeter Avalos.Brq Fl r | Fl u 4460b4ad09SPeter Avalos.Fl f Ar archive-file 4560b4ad09SPeter Avalos.Op Ar options 468029ab02SPeter Avalos.Op Ar files | Ar directories 4760b4ad09SPeter Avalos.Nm 4860b4ad09SPeter Avalos.Brq Fl t | Fl x 4960b4ad09SPeter Avalos.Op Ar options 5060b4ad09SPeter Avalos.Op Ar patterns 5160b4ad09SPeter Avalos.Sh DESCRIPTION 5260b4ad09SPeter Avalos.Nm 5360b4ad09SPeter Avaloscreates and manipulates streaming archive files. 54c09f92d2SPeter AvalosThis implementation can extract from tar, pax, cpio, zip, jar, ar, xar, 55c09f92d2SPeter Avalosrpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip, 56c09f92d2SPeter Avalos7-zip, and shar archives. 5760b4ad09SPeter Avalos.Pp 5860b4ad09SPeter AvalosThe first synopsis form shows a 5960b4ad09SPeter Avalos.Dq bundled 6060b4ad09SPeter Avalosoption word. 6160b4ad09SPeter AvalosThis usage is provided for compatibility with historical implementations. 6260b4ad09SPeter AvalosSee COMPATIBILITY below for details. 6360b4ad09SPeter Avalos.Pp 6460b4ad09SPeter AvalosThe other synopsis forms show the preferred usage. 6560b4ad09SPeter AvalosThe first option to 6660b4ad09SPeter Avalos.Nm 6760b4ad09SPeter Avalosis a mode indicator from the following list: 6860b4ad09SPeter Avalos.Bl -tag -compact -width indent 6960b4ad09SPeter Avalos.It Fl c 7060b4ad09SPeter AvalosCreate a new archive containing the specified items. 71c09f92d2SPeter AvalosThe long option form is 72c09f92d2SPeter Avalos.Fl Fl create . 7360b4ad09SPeter Avalos.It Fl r 7460b4ad09SPeter AvalosLike 7560b4ad09SPeter Avalos.Fl c , 7660b4ad09SPeter Avalosbut new entries are appended to the archive. 7760b4ad09SPeter AvalosNote that this only works on uncompressed archives stored in regular files. 7860b4ad09SPeter AvalosThe 7960b4ad09SPeter Avalos.Fl f 8060b4ad09SPeter Avalosoption is required. 81c09f92d2SPeter AvalosThe long option form is 82c09f92d2SPeter Avalos.Fl Fl append . 8360b4ad09SPeter Avalos.It Fl t 8460b4ad09SPeter AvalosList archive contents to stdout. 85c09f92d2SPeter AvalosThe long option form is 86c09f92d2SPeter Avalos.Fl Fl list . 8760b4ad09SPeter Avalos.It Fl u 8860b4ad09SPeter AvalosLike 8960b4ad09SPeter Avalos.Fl r , 9060b4ad09SPeter Avalosbut new entries are added only if they have a modification date 9160b4ad09SPeter Avalosnewer than the corresponding entry in the archive. 9260b4ad09SPeter AvalosNote that this only works on uncompressed archives stored in regular files. 9360b4ad09SPeter AvalosThe 9460b4ad09SPeter Avalos.Fl f 9560b4ad09SPeter Avalosoption is required. 96c09f92d2SPeter AvalosThe long form is 97c09f92d2SPeter Avalos.Fl Fl update . 9860b4ad09SPeter Avalos.It Fl x 9960b4ad09SPeter AvalosExtract to disk from the archive. 10060b4ad09SPeter AvalosIf a file with the same name appears more than once in the archive, 10160b4ad09SPeter Avaloseach copy will be extracted, with later copies overwriting (replacing) 10260b4ad09SPeter Avalosearlier copies. 103c09f92d2SPeter AvalosThe long option form is 104c09f92d2SPeter Avalos.Fl Fl extract . 10560b4ad09SPeter Avalos.El 10660b4ad09SPeter Avalos.Pp 10760b4ad09SPeter AvalosIn 10860b4ad09SPeter Avalos.Fl c , 10960b4ad09SPeter Avalos.Fl r , 11060b4ad09SPeter Avalosor 11160b4ad09SPeter Avalos.Fl u 11260b4ad09SPeter Avalosmode, each specified file or directory is added to the 11360b4ad09SPeter Avalosarchive in the order specified on the command line. 11460b4ad09SPeter AvalosBy default, the contents of each directory are also archived. 11560b4ad09SPeter Avalos.Pp 11660b4ad09SPeter AvalosIn extract or list mode, the entire command line 11760b4ad09SPeter Avalosis read and parsed before the archive is opened. 11860b4ad09SPeter AvalosThe pathnames or patterns on the command line indicate 11960b4ad09SPeter Avaloswhich items in the archive should be processed. 12060b4ad09SPeter AvalosPatterns are shell-style globbing patterns as 12160b4ad09SPeter Avalosdocumented in 12260b4ad09SPeter Avalos.Xr tcsh 1 . 12360b4ad09SPeter Avalos.Sh OPTIONS 12460b4ad09SPeter AvalosUnless specifically stated otherwise, options are applicable in 12560b4ad09SPeter Avalosall operating modes. 12660b4ad09SPeter Avalos.Bl -tag -width indent 12760b4ad09SPeter Avalos.It Cm @ Ns Pa archive 128e95abc47Szrj(c and r modes only) 12960b4ad09SPeter AvalosThe specified archive is opened and the entries 13060b4ad09SPeter Avalosin it will be appended to the current archive. 13160b4ad09SPeter AvalosAs a simple example, 13260b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar 13360b4ad09SPeter Avaloswrites a new archive to standard output containing a file 13460b4ad09SPeter Avalos.Pa newfile 13560b4ad09SPeter Avalosand all of the entries from 13660b4ad09SPeter Avalos.Pa original.tar . 13760b4ad09SPeter AvalosIn contrast, 13860b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar 13960b4ad09SPeter Avaloscreates a new archive with only two entries. 14060b4ad09SPeter AvalosSimilarly, 141c09f92d2SPeter Avalos.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa - 14260b4ad09SPeter Avalosreads an archive from standard input (whose format will be determined 14360b4ad09SPeter Avalosautomatically) and converts it into a gzip-compressed 14460b4ad09SPeter Avalospax-format archive on stdout. 14560b4ad09SPeter AvalosIn this way, 14660b4ad09SPeter Avalos.Nm 14760b4ad09SPeter Avaloscan be used to convert archives from one format to another. 148d4d8193eSPeter Avalos.It Fl a , Fl Fl auto-compress 149d4d8193eSPeter Avalos(c mode only) 150d4d8193eSPeter AvalosUse the archive suffix to decide a set of the format and 151d4d8193eSPeter Avalosthe compressions. 152d4d8193eSPeter AvalosAs a simple example, 153d4d8193eSPeter Avalos.Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h 154d4d8193eSPeter Avaloscreates a new archive with restricted pax format and gzip compression, 155d4d8193eSPeter Avalos.Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h 156d4d8193eSPeter Avaloscreates a new archive with restricted pax format and bzip2 compression 157d4d8193eSPeter Avalosand uuencode compression, 158d4d8193eSPeter Avalos.Dl Nm Fl a Fl cf Pa archive.zip source.c source.h 159d4d8193eSPeter Avaloscreates a new archive with zip format, 160d4d8193eSPeter Avalos.Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h 161d4d8193eSPeter Avalosignores the 162d4d8193eSPeter Avalos.Dq -j 163d4d8193eSPeter Avalosoption, and creates a new archive with restricted pax format 164d4d8193eSPeter Avalosand gzip compression, 165d4d8193eSPeter Avalos.Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h 166d4d8193eSPeter Avalosif it is unknown suffix or no suffix, creates a new archive with 167d4d8193eSPeter Avalosrestricted pax format and bzip2 compression. 168e95abc47Szrj.It Fl Fl acls 169e95abc47Szrj(c, r, u, x modes only) 170085658deSDaniel FojtArchive or extract POSIX.1e or NFSv4 ACLs. 171085658deSDaniel FojtThis is the reverse of 172e95abc47Szrj.Fl Fl no-acls 173e95abc47Szrjand the default behavior in c, r, and u modes (except on Mac OS X) or if 174e95abc47Szrj.Nm 175085658deSDaniel Fojtis run in x mode as root. 176085658deSDaniel FojtOn Mac OS X this option translates extended ACLs to NFSv4 ACLs. 177085658deSDaniel FojtTo store extended ACLs the 178e95abc47Szrj.Fl Fl mac-metadata 179e95abc47Szrjoption is preferred. 180c09f92d2SPeter Avalos.It Fl B , Fl Fl read-full-blocks 181c09f92d2SPeter AvalosIgnored for compatibility with other 182c09f92d2SPeter Avalos.Xr tar 1 183c09f92d2SPeter Avalosimplementations. 184c09f92d2SPeter Avalos.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize 18560b4ad09SPeter AvalosSpecify the block size, in 512-byte records, for tape drive I/O. 18660b4ad09SPeter AvalosAs a rule, this argument is only needed when reading from or writing 18760b4ad09SPeter Avalosto tape drives, and usually not even then as the default block size of 18860b4ad09SPeter Avalos20 records (10240 bytes) is very common. 189c09f92d2SPeter Avalos.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory 19060b4ad09SPeter AvalosIn c and r mode, this changes the directory before adding 19160b4ad09SPeter Avalosthe following files. 19260b4ad09SPeter AvalosIn x mode, change directories after opening the archive 19360b4ad09SPeter Avalosbut before extracting entries from the archive. 194c09f92d2SPeter Avalos.It Fl Fl chroot 19560b4ad09SPeter Avalos(x mode only) 19660b4ad09SPeter Avalos.Fn chroot 19760b4ad09SPeter Avalosto the current directory after processing any 19860b4ad09SPeter Avalos.Fl C 19960b4ad09SPeter Avalosoptions and before extracting any files. 2006b384f39SPeter Avalos.It Fl Fl clear-nochange-fflags 2016b384f39SPeter Avalos(x mode only) 2026b384f39SPeter AvalosBefore removing file system objects to replace them, clear platform-specific 203085658deSDaniel Fojtfile attributes or file flags that might prevent removal. 204c09f92d2SPeter Avalos.It Fl Fl exclude Ar pattern 20560b4ad09SPeter AvalosDo not process files or directories that match the 20660b4ad09SPeter Avalosspecified pattern. 20760b4ad09SPeter AvalosNote that exclusions take precedence over patterns or filenames 20860b4ad09SPeter Avalosspecified on the command line. 209085658deSDaniel Fojt.It Fl Fl exclude-vcs 210085658deSDaniel FojtDo not process files or directories internally used by the 211085658deSDaniel Fojtversion control systems 212085658deSDaniel Fojt.Sq Arch , 213085658deSDaniel Fojt.Sq Bazaar , 214085658deSDaniel Fojt.Sq CVS , 215085658deSDaniel Fojt.Sq Darcs , 216085658deSDaniel Fojt.Sq Mercurial , 217085658deSDaniel Fojt.Sq RCS , 218085658deSDaniel Fojt.Sq SCCS , 219085658deSDaniel Fojt.Sq SVN 220085658deSDaniel Fojtand 221085658deSDaniel Fojt.Sq git . 222e95abc47Szrj.It Fl Fl fflags 223e95abc47Szrj(c, r, u, x modes only) 224085658deSDaniel FojtArchive or extract platform-specific file attributes or file flags. 225085658deSDaniel FojtThis is the reverse of 226e95abc47Szrj.Fl Fl no-fflags 227e95abc47Szrjand the default behavior in c, r, and u modes or if 228e95abc47Szrj.Nm 229e95abc47Szrjis run in x mode as root. 230c09f92d2SPeter Avalos.It Fl Fl format Ar format 23160b4ad09SPeter Avalos(c, r, u mode only) 23260b4ad09SPeter AvalosUse the specified format for the created archive. 23360b4ad09SPeter AvalosSupported formats include 23460b4ad09SPeter Avalos.Dq cpio , 23560b4ad09SPeter Avalos.Dq pax , 23660b4ad09SPeter Avalos.Dq shar , 23760b4ad09SPeter Avalosand 23860b4ad09SPeter Avalos.Dq ustar . 23960b4ad09SPeter AvalosOther formats may also be supported; see 24060b4ad09SPeter Avalos.Xr libarchive-formats 5 24160b4ad09SPeter Avalosfor more information about currently-supported formats. 24260b4ad09SPeter AvalosIn r and u modes, when extending an existing archive, the format specified 24360b4ad09SPeter Avaloshere must be compatible with the format of the existing archive on disk. 244c09f92d2SPeter Avalos.It Fl f Ar file , Fl Fl file Ar file 24560b4ad09SPeter AvalosRead the archive from or write the archive to the specified file. 24660b4ad09SPeter AvalosThe filename can be 24760b4ad09SPeter Avalos.Pa - 24860b4ad09SPeter Avalosfor standard input or standard output. 249c09f92d2SPeter AvalosThe default varies by system; 250c09f92d2SPeter Avaloson 25160b4ad09SPeter Avalos.Fx , 252c09f92d2SPeter Avalosthe default is 253c09f92d2SPeter Avalos.Pa /dev/sa0 ; 254c09f92d2SPeter Avaloson Linux, the default is 255c09f92d2SPeter Avalos.Pa /dev/st0 . 256c09f92d2SPeter Avalos.It Fl Fl gid Ar id 257c09f92d2SPeter AvalosUse the provided group id number. 258c09f92d2SPeter AvalosOn extract, this overrides the group id in the archive; 259c09f92d2SPeter Avalosthe group name in the archive will be ignored. 260c09f92d2SPeter AvalosOn create, this overrides the group id read from disk; 261c09f92d2SPeter Avalosif 262c09f92d2SPeter Avalos.Fl Fl gname 263c09f92d2SPeter Avalosis not also specified, the group name will be set to 264c09f92d2SPeter Avalosmatch the group id. 265c09f92d2SPeter Avalos.It Fl Fl gname Ar name 266c09f92d2SPeter AvalosUse the provided group name. 267c09f92d2SPeter AvalosOn extract, this overrides the group name in the archive; 268c09f92d2SPeter Avalosif the provided group name does not exist on the system, 269c09f92d2SPeter Avalosthe group id 270c09f92d2SPeter Avalos(from the archive or from the 271c09f92d2SPeter Avalos.Fl Fl gid 272c09f92d2SPeter Avalosoption) 273c09f92d2SPeter Avaloswill be used instead. 274c09f92d2SPeter AvalosOn create, this sets the group name that will be stored 275c09f92d2SPeter Avalosin the archive; 276c09f92d2SPeter Avalosthe name will not be verified against the system group database. 27760b4ad09SPeter Avalos.It Fl H 278e95abc47Szrj(c and r modes only) 27960b4ad09SPeter AvalosSymbolic links named on the command line will be followed; the 28060b4ad09SPeter Avalostarget of the link will be archived, not the link itself. 28160b4ad09SPeter Avalos.It Fl h 282e95abc47Szrj(c and r modes only) 28360b4ad09SPeter AvalosSynonym for 28460b4ad09SPeter Avalos.Fl L . 28560b4ad09SPeter Avalos.It Fl I 28660b4ad09SPeter AvalosSynonym for 28760b4ad09SPeter Avalos.Fl T . 288c09f92d2SPeter Avalos.It Fl Fl help 289c09f92d2SPeter AvalosShow usage. 290d4d8193eSPeter Avalos.It Fl Fl hfsCompression 291d4d8193eSPeter Avalos(x mode only) 292e95abc47SzrjMac OS X specific (v10.6 or later). Compress extracted regular files with HFS+ 293e95abc47Szrjcompression. 2946b384f39SPeter Avalos.It Fl Fl ignore-zeros 2956b384f39SPeter AvalosAn alias of 2966b384f39SPeter Avalos.Fl Fl options Cm read_concatenated_archives 2976b384f39SPeter Avalosfor compatibility with GNU tar. 298c09f92d2SPeter Avalos.It Fl Fl include Ar pattern 29960b4ad09SPeter AvalosProcess only files or directories that match the specified pattern. 30060b4ad09SPeter AvalosNote that exclusions specified with 301c09f92d2SPeter Avalos.Fl Fl exclude 30260b4ad09SPeter Avalostake precedence over inclusions. 30360b4ad09SPeter AvalosIf no inclusions are explicitly specified, all entries are processed by 30460b4ad09SPeter Avalosdefault. 30560b4ad09SPeter AvalosThe 306c09f92d2SPeter Avalos.Fl Fl include 30760b4ad09SPeter Avalosoption is especially useful when filtering archives. 30860b4ad09SPeter AvalosFor example, the command 309c09f92d2SPeter Avalos.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz 31060b4ad09SPeter Avaloscreates a new archive 31160b4ad09SPeter Avalos.Pa new.tar 31260b4ad09SPeter Avaloscontaining only the entries from 31360b4ad09SPeter Avalos.Pa old.tgz 31460b4ad09SPeter Avaloscontaining the string 31560b4ad09SPeter Avalos.Sq foo . 316c09f92d2SPeter Avalos.It Fl J , Fl Fl xz 317c09f92d2SPeter Avalos(c mode only) 318c09f92d2SPeter AvalosCompress the resulting archive with 319c09f92d2SPeter Avalos.Xr xz 1 . 320c09f92d2SPeter AvalosIn extract or list modes, this option is ignored. 321e95abc47SzrjNote that this 322c09f92d2SPeter Avalos.Nm tar 323e95abc47Szrjimplementation recognizes XZ compression automatically when reading archives. 324c09f92d2SPeter Avalos.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2 32560b4ad09SPeter Avalos(c mode only) 32660b4ad09SPeter AvalosCompress the resulting archive with 32760b4ad09SPeter Avalos.Xr bzip2 1 . 32860b4ad09SPeter AvalosIn extract or list modes, this option is ignored. 329e95abc47SzrjNote that this 33060b4ad09SPeter Avalos.Nm tar 331e95abc47Szrjimplementation recognizes bzip2 compression automatically when reading 332e95abc47Szrjarchives. 333c09f92d2SPeter Avalos.It Fl k , Fl Fl keep-old-files 33460b4ad09SPeter Avalos(x mode only) 33560b4ad09SPeter AvalosDo not overwrite existing files. 33660b4ad09SPeter AvalosIn particular, if a file appears more than once in an archive, 33760b4ad09SPeter Avaloslater copies will not overwrite earlier copies. 338c09f92d2SPeter Avalos.It Fl Fl keep-newer-files 33960b4ad09SPeter Avalos(x mode only) 34060b4ad09SPeter AvalosDo not overwrite existing files that are newer than the 34160b4ad09SPeter Avalosversions appearing in the archive being extracted. 342c09f92d2SPeter Avalos.It Fl L , Fl Fl dereference 343e95abc47Szrj(c and r modes only) 34460b4ad09SPeter AvalosAll symbolic links will be followed. 34560b4ad09SPeter AvalosNormally, symbolic links are archived as such. 34660b4ad09SPeter AvalosWith this option, the target of the link will be archived instead. 347c09f92d2SPeter Avalos.It Fl l , Fl Fl check-links 348c09f92d2SPeter Avalos(c and r modes only) 349c09f92d2SPeter AvalosIssue a warning message unless all links to each file are archived. 350d4d8193eSPeter Avalos.It Fl Fl lrzip 351d4d8193eSPeter Avalos(c mode only) 352d4d8193eSPeter AvalosCompress the resulting archive with 353d4d8193eSPeter Avalos.Xr lrzip 1 . 354d4d8193eSPeter AvalosIn extract or list modes, this option is ignored. 355e95abc47SzrjNote that this 356e95abc47Szrj.Nm tar 357e95abc47Szrjimplementation recognizes lrzip compression automatically when reading 358e95abc47Szrjarchives. 3596b384f39SPeter Avalos.It Fl Fl lz4 3606b384f39SPeter Avalos(c mode only) 3616b384f39SPeter AvalosCompress the archive with lz4-compatible compression before writing it. 362e95abc47SzrjIn extract or list modes, this option is ignored. 363e95abc47SzrjNote that this 364e95abc47Szrj.Nm tar 365e95abc47Szrjimplementation recognizes lz4 compression automatically when reading archives. 366e95abc47Szrj.It Fl Fl zstd 367e95abc47Szrj(c mode only) 368e95abc47SzrjCompress the archive with zstd-compatible compression before writing it. 369e95abc47SzrjIn extract or list modes, this option is ignored. 370e95abc47SzrjNote that this 371e95abc47Szrj.Nm tar 372e95abc47Szrjimplementation recognizes zstd compression automatically when reading archives. 373c09f92d2SPeter Avalos.It Fl Fl lzma 374c09f92d2SPeter Avalos(c mode only) Compress the resulting archive with the original LZMA algorithm. 375e95abc47SzrjIn extract or list modes, this option is ignored. 376c09f92d2SPeter AvalosUse of this option is discouraged and new archives should be created with 377c09f92d2SPeter Avalos.Fl Fl xz 378c09f92d2SPeter Avalosinstead. 379e95abc47SzrjNote that this 380c09f92d2SPeter Avalos.Nm tar 381e95abc47Szrjimplementation recognizes LZMA compression automatically when reading archives. 382d4d8193eSPeter Avalos.It Fl Fl lzop 383d4d8193eSPeter Avalos(c mode only) 384d4d8193eSPeter AvalosCompress the resulting archive with 385d4d8193eSPeter Avalos.Xr lzop 1 . 386d4d8193eSPeter AvalosIn extract or list modes, this option is ignored. 387e95abc47SzrjNote that this 388e95abc47Szrj.Nm tar 389e95abc47Szrjimplementation recognizes LZO compression automatically when reading archives. 390c09f92d2SPeter Avalos.It Fl m , Fl Fl modification-time 39160b4ad09SPeter Avalos(x mode only) 39260b4ad09SPeter AvalosDo not extract modification time. 39360b4ad09SPeter AvalosBy default, the modification time is set to the time stored in the archive. 394e95abc47Szrj.It Fl Fl mac-metadata 395e95abc47Szrj(c, r, u and x mode only) 396085658deSDaniel FojtMac OS X specific. 397085658deSDaniel FojtArchive or extract extended ACLs and extended file 398085658deSDaniel Fojtattributes using 399e95abc47Szrj.Xr copyfile 3 400085658deSDaniel Fojtin AppleDouble format. 401085658deSDaniel FojtThis is the reverse of 402e95abc47Szrj.Fl Fl no-mac-metadata . 403e95abc47Szrjand the default behavior in c, r, and u modes or if 404e95abc47Szrj.Nm 405e95abc47Szrjis run in x mode as root. 406c09f92d2SPeter Avalos.It Fl n , Fl Fl norecurse , Fl Fl no-recursion 407085658deSDaniel FojtDo not operate recursively on the content of directories. 408c09f92d2SPeter Avalos.It Fl Fl newer Ar date 40960b4ad09SPeter Avalos(c, r, u modes only) 41060b4ad09SPeter AvalosOnly include files and directories newer than the specified date. 41160b4ad09SPeter AvalosThis compares ctime entries. 412c09f92d2SPeter Avalos.It Fl Fl newer-mtime Ar date 41360b4ad09SPeter Avalos(c, r, u modes only) 41460b4ad09SPeter AvalosLike 415c09f92d2SPeter Avalos.Fl Fl newer , 41660b4ad09SPeter Avalosexcept it compares mtime entries instead of ctime entries. 417c09f92d2SPeter Avalos.It Fl Fl newer-than Pa file 41860b4ad09SPeter Avalos(c, r, u modes only) 41960b4ad09SPeter AvalosOnly include files and directories newer than the specified file. 42060b4ad09SPeter AvalosThis compares ctime entries. 421c09f92d2SPeter Avalos.It Fl Fl newer-mtime-than Pa file 42260b4ad09SPeter Avalos(c, r, u modes only) 42360b4ad09SPeter AvalosLike 424c09f92d2SPeter Avalos.Fl Fl newer-than , 42560b4ad09SPeter Avalosexcept it compares mtime entries instead of ctime entries. 426c09f92d2SPeter Avalos.It Fl Fl nodump 42760b4ad09SPeter Avalos(c and r modes only) 42860b4ad09SPeter AvalosHonor the nodump file flag by skipping this file. 429d4d8193eSPeter Avalos.It Fl Fl nopreserveHFSCompression 430d4d8193eSPeter Avalos(x mode only) 431d4d8193eSPeter AvalosMac OS X specific (v10.6 or later). Do not compress extracted regular files 432d4d8193eSPeter Avaloswhich were compressed with HFS+ compression before archived. 433d4d8193eSPeter AvalosBy default, compress the regular files again with HFS+ compression. 434c09f92d2SPeter Avalos.It Fl Fl null 43560b4ad09SPeter Avalos(use with 436c09f92d2SPeter Avalos.Fl I 43760b4ad09SPeter Avalosor 438c09f92d2SPeter Avalos.Fl T ) 43960b4ad09SPeter AvalosFilenames or patterns are separated by null characters, 44060b4ad09SPeter Avalosnot by newlines. 44160b4ad09SPeter AvalosThis is often used to read filenames output by the 44260b4ad09SPeter Avalos.Fl print0 44360b4ad09SPeter Avalosoption to 44460b4ad09SPeter Avalos.Xr find 1 . 445e95abc47Szrj.It Fl Fl no-acls 446e95abc47Szrj(c, r, u, x modes only) 447085658deSDaniel FojtDo not archive or extract POSIX.1e or NFSv4 ACLs. 448085658deSDaniel FojtThis is the reverse of 449e95abc47Szrj.Fl Fl acls 450e95abc47Szrjand the default behavior if 451e95abc47Szrj.Nm 452e95abc47Szrjis run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes). 453e95abc47Szrj.It Fl Fl no-fflags 454e95abc47Szrj(c, r, u, x modes only) 455085658deSDaniel FojtDo not archive or extract file attributes or file flags. 456085658deSDaniel FojtThis is the reverse of 457e95abc47Szrj.Fl Fl fflags 458e95abc47Szrjand the default behavior if 459e95abc47Szrj.Nm 460e95abc47Szrjis run as non-root in x mode. 461e95abc47Szrj.It Fl Fl no-mac-metadata 462e95abc47Szrj(x mode only) 463085658deSDaniel FojtMac OS X specific. 464085658deSDaniel FojtDo not archive or extract ACLs and extended file attributes 465085658deSDaniel Fojtusing 466e95abc47Szrj.Xr copyfile 3 467085658deSDaniel Fojtin AppleDouble format. 468085658deSDaniel FojtThis is the reverse of 469e95abc47Szrj.Fl Fl mac-metadata . 470e95abc47Szrjand the default behavior if 471e95abc47Szrj.Nm 472e95abc47Szrjis run as non-root in x mode. 473*50f8aa9cSAntonio Huete Jimenez.It Fl Fl no-read-sparse 474*50f8aa9cSAntonio Huete Jimenez(c, r, u modes only) 475*50f8aa9cSAntonio Huete JimenezDo not read sparse file information from disk. 476*50f8aa9cSAntonio Huete JimenezThis is the reverse of 477*50f8aa9cSAntonio Huete Jimenez.Fl Fl read-sparse . 478085658deSDaniel Fojt.It Fl Fl no-safe-writes 479085658deSDaniel Fojt(x mode only) 480085658deSDaniel FojtDo not create temporary files and use 481085658deSDaniel Fojt.Xr rename 2 482085658deSDaniel Fojtto replace the original ones. 483085658deSDaniel FojtThis is the reverse of 484085658deSDaniel Fojt.Fl Fl safe-writes . 485c09f92d2SPeter Avalos.It Fl Fl no-same-owner 48660b4ad09SPeter Avalos(x mode only) 487c09f92d2SPeter AvalosDo not extract owner and group IDs. 488c09f92d2SPeter AvalosThis is the reverse of 489c09f92d2SPeter Avalos.Fl Fl same-owner 490c09f92d2SPeter Avalosand the default behavior if 491c09f92d2SPeter Avalos.Nm 492c09f92d2SPeter Avalosis run as non-root. 493c09f92d2SPeter Avalos.It Fl Fl no-same-permissions 494c09f92d2SPeter Avalos(x mode only) 495085658deSDaniel FojtDo not extract full permissions (SGID, SUID, sticky bit, 496085658deSDaniel Fojtfile attributes or file flags, extended file attributes and ACLs). 497c09f92d2SPeter AvalosThis is the reverse of 498c09f92d2SPeter Avalos.Fl p 499c09f92d2SPeter Avalosand the default behavior if 500c09f92d2SPeter Avalos.Nm 501c09f92d2SPeter Avalosis run as non-root. 502e95abc47Szrj.It Fl Fl no-xattrs 503e95abc47Szrj(c, r, u, x modes only) 504085658deSDaniel FojtDo not archive or extract extended file attributes. 505085658deSDaniel FojtThis is the reverse of 506e95abc47Szrj.Fl Fl xattrs 507e95abc47Szrjand the default behavior if 508e95abc47Szrj.Nm 509e95abc47Szrjis run as non-root in x mode. 510c09f92d2SPeter Avalos.It Fl Fl numeric-owner 511c09f92d2SPeter AvalosThis is equivalent to 512c09f92d2SPeter Avalos.Fl Fl uname 513c09f92d2SPeter Avalos.Qq 514c09f92d2SPeter Avalos.Fl Fl gname 515c09f92d2SPeter Avalos.Qq . 516c09f92d2SPeter AvalosOn extract, it causes user and group names in the archive 517c09f92d2SPeter Avalosto be ignored in favor of the numeric user and group ids. 518c09f92d2SPeter AvalosOn create, it causes user and group names to not be stored 519c09f92d2SPeter Avalosin the archive. 520c09f92d2SPeter Avalos.It Fl O , Fl Fl to-stdout 52160b4ad09SPeter Avalos(x, t modes only) 52260b4ad09SPeter AvalosIn extract (-x) mode, files will be written to standard out rather than 52360b4ad09SPeter Avalosbeing extracted to disk. 52460b4ad09SPeter AvalosIn list (-t) mode, the file listing will be written to stderr rather than 52560b4ad09SPeter Avalosthe usual stdout. 52660b4ad09SPeter Avalos.It Fl o 52760b4ad09SPeter Avalos(x mode) 52860b4ad09SPeter AvalosUse the user and group of the user running the program rather 52960b4ad09SPeter Avalosthan those specified in the archive. 53060b4ad09SPeter AvalosNote that this has no significance unless 53160b4ad09SPeter Avalos.Fl p 53260b4ad09SPeter Avalosis specified, and the program is being run by the root user. 53360b4ad09SPeter AvalosIn this case, the file modes and flags from 53460b4ad09SPeter Avalosthe archive will be restored, but ACLs or owner information in 53560b4ad09SPeter Avalosthe archive will be discarded. 53660b4ad09SPeter Avalos.It Fl o 53760b4ad09SPeter Avalos(c, r, u mode) 53860b4ad09SPeter AvalosA synonym for 539c09f92d2SPeter Avalos.Fl Fl format Ar ustar 540d4d8193eSPeter Avalos.It Fl Fl older Ar date 541d4d8193eSPeter Avalos(c, r, u modes only) 542d4d8193eSPeter AvalosOnly include files and directories older than the specified date. 543d4d8193eSPeter AvalosThis compares ctime entries. 544d4d8193eSPeter Avalos.It Fl Fl older-mtime Ar date 545d4d8193eSPeter Avalos(c, r, u modes only) 546d4d8193eSPeter AvalosLike 547d4d8193eSPeter Avalos.Fl Fl older , 548d4d8193eSPeter Avalosexcept it compares mtime entries instead of ctime entries. 549d4d8193eSPeter Avalos.It Fl Fl older-than Pa file 550d4d8193eSPeter Avalos(c, r, u modes only) 551d4d8193eSPeter AvalosOnly include files and directories older than the specified file. 552d4d8193eSPeter AvalosThis compares ctime entries. 553d4d8193eSPeter Avalos.It Fl Fl older-mtime-than Pa file 554d4d8193eSPeter Avalos(c, r, u modes only) 555d4d8193eSPeter AvalosLike 556d4d8193eSPeter Avalos.Fl Fl older-than , 557d4d8193eSPeter Avalosexcept it compares mtime entries instead of ctime entries. 558c09f92d2SPeter Avalos.It Fl Fl one-file-system 55960b4ad09SPeter Avalos(c, r, and u modes) 56060b4ad09SPeter AvalosDo not cross mount points. 561c09f92d2SPeter Avalos.It Fl Fl options Ar options 5628029ab02SPeter AvalosSelect optional behaviors for particular modules. 5638029ab02SPeter AvalosThe argument is a text string containing comma-separated 5648029ab02SPeter Avaloskeywords and values. 5658029ab02SPeter AvalosThese are passed to the modules that handle particular 5668029ab02SPeter Avalosformats to control how those formats will behave. 5678029ab02SPeter AvalosEach option has one of the following forms: 5688029ab02SPeter Avalos.Bl -tag -compact -width indent 5698029ab02SPeter Avalos.It Ar key=value 5708029ab02SPeter AvalosThe key will be set to the specified value in every module that supports it. 5718029ab02SPeter AvalosModules that do not support this key will ignore it. 5728029ab02SPeter Avalos.It Ar key 5738029ab02SPeter AvalosThe key will be enabled in every module that supports it. 5748029ab02SPeter AvalosThis is equivalent to 5758029ab02SPeter Avalos.Ar key Ns Cm =1 . 5768029ab02SPeter Avalos.It Ar !key 5778029ab02SPeter AvalosThe key will be disabled in every module that supports it. 5788029ab02SPeter Avalos.It Ar module:key=value , Ar module:key , Ar module:!key 5798029ab02SPeter AvalosAs above, but the corresponding key and value will be provided 5808029ab02SPeter Avalosonly to modules whose name matches 5818029ab02SPeter Avalos.Ar module . 5828029ab02SPeter Avalos.El 583085658deSDaniel Fojt.Pp 584085658deSDaniel FojtThe complete list of supported modules and keys 585085658deSDaniel Fojtfor create and append modes is in 586085658deSDaniel Fojt.Xr archive_write_set_options 3 587085658deSDaniel Fojtand for extract and list modes in 588085658deSDaniel Fojt.Xr archive_read_set_options 3 . 589085658deSDaniel Fojt.Pp 590085658deSDaniel FojtExamples of supported options: 5918029ab02SPeter Avalos.Bl -tag -compact -width indent 5928029ab02SPeter Avalos.It Cm iso9660:joliet 5938029ab02SPeter AvalosSupport Joliet extensions. 5948029ab02SPeter AvalosThis is enabled by default, use 5958029ab02SPeter Avalos.Cm !joliet 5968029ab02SPeter Avalosor 5978029ab02SPeter Avalos.Cm iso9660:!joliet 5988029ab02SPeter Avalosto disable. 5999c82a63eSPeter Avalos.It Cm iso9660:rockridge 6009c82a63eSPeter AvalosSupport Rock Ridge extensions. 6019c82a63eSPeter AvalosThis is enabled by default, use 6029c82a63eSPeter Avalos.Cm !rockridge 6039c82a63eSPeter Avalosor 6049c82a63eSPeter Avalos.Cm iso9660:!rockridge 6059c82a63eSPeter Avalosto disable. 6068029ab02SPeter Avalos.It Cm gzip:compression-level 607d4d8193eSPeter AvalosA decimal integer from 1 to 9 specifying the gzip compression level. 608d4d8193eSPeter Avalos.It Cm gzip:timestamp 609085658deSDaniel FojtStore timestamp. 610085658deSDaniel FojtThis is enabled by default, use 611d4d8193eSPeter Avalos.Cm !timestamp 612d4d8193eSPeter Avalosor 613d4d8193eSPeter Avalos.Cm gzip:!timestamp 614d4d8193eSPeter Avalosto disable. 615d4d8193eSPeter Avalos.It Cm lrzip:compression Ns = Ns Ar type 616d4d8193eSPeter AvalosUse 617d4d8193eSPeter Avalos.Ar type 618d4d8193eSPeter Avalosas compression method. 619d4d8193eSPeter AvalosSupported values are bzip2, gzip, lzo (ultra fast), 620d4d8193eSPeter Avalosand zpaq (best, extremely slow). 621d4d8193eSPeter Avalos.It Cm lrzip:compression-level 622d4d8193eSPeter AvalosA decimal integer from 1 to 9 specifying the lrzip compression level. 6236b384f39SPeter Avalos.It Cm lz4:compression-level 6246b384f39SPeter AvalosA decimal integer from 1 to 9 specifying the lzop compression level. 6256b384f39SPeter Avalos.It Cm lz4:stream-checksum 626085658deSDaniel FojtEnable stream checksum. 627085658deSDaniel FojtThis is by default, use 6286b384f39SPeter Avalos.Cm lz4:!stream-checksum 6296b384f39SPeter Avalosto disable. 6306b384f39SPeter Avalos.It Cm lz4:block-checksum 6316b384f39SPeter AvalosEnable block checksum (Disabled by default). 6326b384f39SPeter Avalos.It Cm lz4:block-size 6336b384f39SPeter AvalosA decimal integer from 4 to 7 specifying the lz4 compression block size 6346b384f39SPeter Avalos(7 is set by default). 6356b384f39SPeter Avalos.It Cm lz4:block-dependence 6366b384f39SPeter AvalosUse the previous block of the block being compressed for 6376b384f39SPeter Avalosa compression dictionary to improve compression ratio. 638e95abc47Szrj.It Cm zstd:compression-level 639085658deSDaniel FojtA decimal integer specifying the zstd compression level. Supported values depend 640085658deSDaniel Fojton the library version, common values are from 1 to 22. 641*50f8aa9cSAntonio Huete Jimenez.It Cm zstd:threads 642*50f8aa9cSAntonio Huete JimenezSpecify the number of worker threads to use. 643*50f8aa9cSAntonio Huete JimenezSetting threads to a special value 0 makes 644*50f8aa9cSAntonio Huete Jimenez.Xr zstd 1 645*50f8aa9cSAntonio Huete Jimenezuse as many threads as there are CPU cores on the system. 646d4d8193eSPeter Avalos.It Cm lzop:compression-level 647d4d8193eSPeter AvalosA decimal integer from 1 to 9 specifying the lzop compression level. 6488029ab02SPeter Avalos.It Cm xz:compression-level 6498029ab02SPeter AvalosA decimal integer from 0 to 9 specifying the xz compression level. 650*50f8aa9cSAntonio Huete Jimenez.It Cm xz:threads 651*50f8aa9cSAntonio Huete JimenezSpecify the number of worker threads to use. 652*50f8aa9cSAntonio Huete JimenezSetting threads to a special value 0 makes 653*50f8aa9cSAntonio Huete Jimenez.Xr xz 1 654*50f8aa9cSAntonio Huete Jimenezuse as many threads as there are CPU cores on the system. 6558029ab02SPeter Avalos.It Cm mtree: Ns Ar keyword 6568029ab02SPeter AvalosThe mtree writer module allows you to specify which mtree keywords 6578029ab02SPeter Avaloswill be included in the output. 6588029ab02SPeter AvalosSupported keywords include: 6598029ab02SPeter Avalos.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , 6608029ab02SPeter Avalos.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , 6618029ab02SPeter Avalos.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname . 6628029ab02SPeter AvalosThe default is equivalent to: 6638029ab02SPeter Avalos.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname . 6648029ab02SPeter Avalos.It Cm mtree:all 6658029ab02SPeter AvalosEnables all of the above keywords. 6668029ab02SPeter AvalosYou can also use 6678029ab02SPeter Avalos.Cm mtree:!all 6688029ab02SPeter Avalosto disable all keywords. 6698029ab02SPeter Avalos.It Cm mtree:use-set 6708029ab02SPeter AvalosEnable generation of 6718029ab02SPeter Avalos.Cm /set 6728029ab02SPeter Avaloslines in the output. 6738029ab02SPeter Avalos.It Cm mtree:indent 6749c82a63eSPeter AvalosProduce human-readable output by indenting options and splitting lines 6759c82a63eSPeter Avalosto fit into 80 columns. 6769c82a63eSPeter Avalos.It Cm zip:compression Ns = Ns Ar type 6779c82a63eSPeter AvalosUse 6789c82a63eSPeter Avalos.Ar type 6799c82a63eSPeter Avalosas compression method. 6809c82a63eSPeter AvalosSupported values are store (uncompressed) and deflate (gzip algorithm). 6816b384f39SPeter Avalos.It Cm zip:encryption 6826b384f39SPeter AvalosEnable encryption using traditional zip encryption. 6836b384f39SPeter Avalos.It Cm zip:encryption Ns = Ns Ar type 6846b384f39SPeter AvalosUse 6856b384f39SPeter Avalos.Ar type 6866b384f39SPeter Avalosas encryption type. 6876b384f39SPeter AvalosSupported values are zipcrypt (traditional zip encryption), 6886b384f39SPeter Avalosaes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption). 6896b384f39SPeter Avalos.It Cm read_concatenated_archives 6906b384f39SPeter AvalosIgnore zeroed blocks in the archive, which occurs when multiple tar archives 691085658deSDaniel Fojthave been concatenated together. 692085658deSDaniel FojtWithout this option, only the contents of 693085658deSDaniel Fojtthe first concatenated archive would be read. 694085658deSDaniel FojtThis option is comparable to the 6956b384f39SPeter Avalos.Fl i , Fl Fl ignore-zeros 6966b384f39SPeter Avalosoption of GNU tar. 6978029ab02SPeter Avalos.El 6988029ab02SPeter AvalosIf a provided option is not supported by any module, that 6998029ab02SPeter Avalosis a fatal error. 700c09f92d2SPeter Avalos.It Fl P , Fl Fl absolute-paths 70160b4ad09SPeter AvalosPreserve pathnames. 70260b4ad09SPeter AvalosBy default, absolute pathnames (those that begin with a / 70360b4ad09SPeter Avaloscharacter) have the leading slash removed both when creating archives 70460b4ad09SPeter Avalosand extracting from them. 70560b4ad09SPeter AvalosAlso, 70660b4ad09SPeter Avalos.Nm 70760b4ad09SPeter Avaloswill refuse to extract archive entries whose pathnames contain 70860b4ad09SPeter Avalos.Pa .. 70960b4ad09SPeter Avalosor whose target directory would be altered by a symlink. 71060b4ad09SPeter AvalosThis option suppresses these behaviors. 711c09f92d2SPeter Avalos.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions 71260b4ad09SPeter Avalos(x mode only) 71360b4ad09SPeter AvalosPreserve file permissions. 714085658deSDaniel FojtAttempt to restore the full permissions, including file modes, file attributes 715085658deSDaniel Fojtor file flags, extended file attributes and ACLs, if available, for each item 716085658deSDaniel Fojtextracted from the archive. 717085658deSDaniel FojtThis is the reverse of 718e95abc47Szrj.Fl Fl no-same-permissions 719e95abc47Szrjand the default if 72060b4ad09SPeter Avalos.Nm 721085658deSDaniel Fojtis being run as root. 722085658deSDaniel FojtIt can be partially overridden by also specifying 723e95abc47Szrj.Fl Fl no-acls , 724e95abc47Szrj.Fl Fl no-fflags , 725e95abc47Szrj.Fl Fl no-mac-metadata 726e95abc47Szrjor 727e95abc47Szrj.Fl Fl no-xattrs . 7286b384f39SPeter Avalos.It Fl Fl passphrase Ar passphrase 7296b384f39SPeter AvalosThe 7306b384f39SPeter Avalos.Pa passphrase 7316b384f39SPeter Avalosis used to extract or create an encrypted archive. 7326b384f39SPeter AvalosCurrently, zip is the only supported format that supports encryption. 7336b384f39SPeter AvalosYou shouldn't use this option unless you realize how insecure 7346b384f39SPeter Avalosuse of this option is. 735c09f92d2SPeter Avalos.It Fl Fl posix 736c09f92d2SPeter Avalos(c, r, u mode only) 737c09f92d2SPeter AvalosSynonym for 738c09f92d2SPeter Avalos.Fl Fl format Ar pax 739c09f92d2SPeter Avalos.It Fl q , Fl Fl fast-read 74060b4ad09SPeter Avalos(x and t mode only) 74160b4ad09SPeter AvalosExtract or list only the first archive entry that matches each pattern 74260b4ad09SPeter Avalosor filename operand. 74360b4ad09SPeter AvalosExit as soon as each specified pattern or filename has been matched. 74460b4ad09SPeter AvalosBy default, the archive is always read to the very end, since 74560b4ad09SPeter Avalosthere can be multiple entries with the same name and, by convention, 74660b4ad09SPeter Avaloslater entries overwrite earlier entries. 74760b4ad09SPeter AvalosThis option is provided as a performance optimization. 748*50f8aa9cSAntonio Huete Jimenez.It Fl Fl read-sparse 749*50f8aa9cSAntonio Huete Jimenez(c, r, u modes only) 750*50f8aa9cSAntonio Huete JimenezRead sparse file information from disk. 751*50f8aa9cSAntonio Huete JimenezThis is the reverse of 752*50f8aa9cSAntonio Huete Jimenez.Fl Fl no-read-sparse 753*50f8aa9cSAntonio Huete Jimenezand the default behavior. 75460b4ad09SPeter Avalos.It Fl S 75560b4ad09SPeter Avalos(x mode only) 75660b4ad09SPeter AvalosExtract files as sparse files. 75760b4ad09SPeter AvalosFor every block on disk, check first if it contains only NULL bytes and seek 75860b4ad09SPeter Avalosover it otherwise. 759c09f92d2SPeter AvalosThis works similar to the conv=sparse option of dd. 76060b4ad09SPeter Avalos.It Fl s Ar pattern 76160b4ad09SPeter AvalosModify file or archive member names according to 76260b4ad09SPeter Avalos.Pa pattern . 7639c82a63eSPeter AvalosThe pattern has the format 764c09f92d2SPeter Avalos.Ar /old/new/ Ns Op ghHprRsS 7659c82a63eSPeter Avaloswhere 7669c82a63eSPeter Avalos.Ar old 7679c82a63eSPeter Avalosis a basic regular expression, 7689c82a63eSPeter Avalos.Ar new 7699c82a63eSPeter Avalosis the replacement string of the matched part, 7709c82a63eSPeter Avalosand the optional trailing letters modify 7719c82a63eSPeter Avaloshow the replacement is handled. 7729c82a63eSPeter AvalosIf 7739c82a63eSPeter Avalos.Ar old 7749c82a63eSPeter Avalosis not matched, the pattern is skipped. 7759c82a63eSPeter AvalosWithin 7769c82a63eSPeter Avalos.Ar new , 7779c82a63eSPeter Avalos~ is substituted with the match, \e1 to \e9 with the content of 77860b4ad09SPeter Avalosthe corresponding captured group. 77960b4ad09SPeter AvalosThe optional trailing g specifies that matching should continue 780c09f92d2SPeter Avalosafter the matched part and stop on the first unmatched pattern. 78160b4ad09SPeter AvalosThe optional trailing s specifies that the pattern applies to the value 78260b4ad09SPeter Avalosof symbolic links. 78360b4ad09SPeter AvalosThe optional trailing p specifies that after a successful substitution 78460b4ad09SPeter Avalosthe original path name and the new path name should be printed to 78560b4ad09SPeter Avalosstandard error. 786c09f92d2SPeter AvalosOptional trailing H, R, or S characters suppress substitutions 787c09f92d2SPeter Avalosfor hardlink targets, regular filenames, or symlink targets, 788c09f92d2SPeter Avalosrespectively. 789c09f92d2SPeter AvalosOptional trailing h, r, or s characters enable substitutions 790c09f92d2SPeter Avalosfor hardlink targets, regular filenames, or symlink targets, 791c09f92d2SPeter Avalosrespectively. 792c09f92d2SPeter AvalosThe default is 793c09f92d2SPeter Avalos.Ar hrs 794c09f92d2SPeter Avaloswhich applies substitutions to all names. 795c09f92d2SPeter AvalosIn particular, it is never necessary to specify h, r, or s. 796085658deSDaniel Fojt.It Fl Fl safe-writes 797085658deSDaniel Fojt(x mode only) 798085658deSDaniel FojtExtract files atomically. 799085658deSDaniel FojtBy default 800085658deSDaniel Fojt.Nm 801085658deSDaniel Fojtunlinks the original file with the same name as the extracted file (if it 802085658deSDaniel Fojtexists), and then creates it immediately under the same name and writes to 803085658deSDaniel Fojtit. 804085658deSDaniel FojtFor a short period of time, applications trying to access the file might 805085658deSDaniel Fojtnot find it, or see incomplete results. 806085658deSDaniel FojtIf 807085658deSDaniel Fojt.Fl Fl safe-writes 808085658deSDaniel Fojtis enabled, 809085658deSDaniel Fojt.Nm 810085658deSDaniel Fojtfirst creates a unique temporary file, then writes the new contents to 811085658deSDaniel Fojtthe temporary file, and finally renames the temporary file to its final 812085658deSDaniel Fojtname atomically using 813085658deSDaniel Fojt.Xr rename 2 . 814085658deSDaniel FojtThis guarantees that an application accessing the file, will either see 815085658deSDaniel Fojtthe old contents or the new contents at all times. 816c09f92d2SPeter Avalos.It Fl Fl same-owner 817c09f92d2SPeter Avalos(x mode only) 818c09f92d2SPeter AvalosExtract owner and group IDs. 819c09f92d2SPeter AvalosThis is the reverse of 820c09f92d2SPeter Avalos.Fl Fl no-same-owner 821c09f92d2SPeter Avalosand the default behavior if 822c09f92d2SPeter Avalos.Nm 823c09f92d2SPeter Avalosis run as root. 824c09f92d2SPeter Avalos.It Fl Fl strip-components Ar count 825c09f92d2SPeter AvalosRemove the specified number of leading path elements. 826c09f92d2SPeter AvalosPathnames with fewer elements will be silently skipped. 827c09f92d2SPeter AvalosNote that the pathname is edited after checking inclusion/exclusion patterns 828c09f92d2SPeter Avalosbut before security checks. 829c09f92d2SPeter Avalos.It Fl T Ar filename , Fl Fl files-from Ar filename 83060b4ad09SPeter AvalosIn x or t mode, 83160b4ad09SPeter Avalos.Nm 83260b4ad09SPeter Avaloswill read the list of names to be extracted from 83360b4ad09SPeter Avalos.Pa filename . 83460b4ad09SPeter AvalosIn c mode, 83560b4ad09SPeter Avalos.Nm 83660b4ad09SPeter Avaloswill read names to be archived from 83760b4ad09SPeter Avalos.Pa filename . 83860b4ad09SPeter AvalosThe special name 83960b4ad09SPeter Avalos.Dq -C 84060b4ad09SPeter Avaloson a line by itself will cause the current directory to be changed to 84160b4ad09SPeter Avalosthe directory specified on the following line. 84260b4ad09SPeter AvalosNames are terminated by newlines unless 843c09f92d2SPeter Avalos.Fl Fl null 84460b4ad09SPeter Avalosis specified. 84560b4ad09SPeter AvalosNote that 846c09f92d2SPeter Avalos.Fl Fl null 84760b4ad09SPeter Avalosalso disables the special handling of lines containing 84860b4ad09SPeter Avalos.Dq -C . 849d4d8193eSPeter AvalosNote: If you are generating lists of files using 850d4d8193eSPeter Avalos.Xr find 1 , 851d4d8193eSPeter Avalosyou probably want to use 852d4d8193eSPeter Avalos.Fl n 853d4d8193eSPeter Avalosas well. 854c09f92d2SPeter Avalos.It Fl Fl totals 855e95abc47Szrj(c, r, u modes only) 856c09f92d2SPeter AvalosAfter archiving all files, print a summary to stderr. 857c09f92d2SPeter Avalos.It Fl U , Fl Fl unlink , Fl Fl unlink-first 85860b4ad09SPeter Avalos(x mode only) 85960b4ad09SPeter AvalosUnlink files before creating them. 860c09f92d2SPeter AvalosThis can be a minor performance optimization if most files 861c09f92d2SPeter Avalosalready exist, but can make things slower if most files 862c09f92d2SPeter Avalosdo not already exist. 863c09f92d2SPeter AvalosThis flag also causes 86460b4ad09SPeter Avalos.Nm 865c09f92d2SPeter Avalosto remove intervening directory symlinks instead of 866c09f92d2SPeter Avalosreporting an error. 867c09f92d2SPeter AvalosSee the SECURITY section below for more details. 868c09f92d2SPeter Avalos.It Fl Fl uid Ar id 869c09f92d2SPeter AvalosUse the provided user id number and ignore the user 870c09f92d2SPeter Avalosname from the archive. 871c09f92d2SPeter AvalosOn create, if 872c09f92d2SPeter Avalos.Fl Fl uname 873c09f92d2SPeter Avalosis not also specified, the user name will be set to 874c09f92d2SPeter Avalosmatch the user id. 875c09f92d2SPeter Avalos.It Fl Fl uname Ar name 876c09f92d2SPeter AvalosUse the provided user name. 877c09f92d2SPeter AvalosOn extract, this overrides the user name in the archive; 878c09f92d2SPeter Avalosif the provided user name does not exist on the system, 879c09f92d2SPeter Avalosit will be ignored and the user id 880c09f92d2SPeter Avalos(from the archive or from the 881c09f92d2SPeter Avalos.Fl Fl uid 882c09f92d2SPeter Avalosoption) 883c09f92d2SPeter Avaloswill be used instead. 884c09f92d2SPeter AvalosOn create, this sets the user name that will be stored 885c09f92d2SPeter Avalosin the archive; 886c09f92d2SPeter Avalosthe name is not verified against the system user database. 887c09f92d2SPeter Avalos.It Fl Fl use-compress-program Ar program 88860b4ad09SPeter AvalosPipe the input (in x or t mode) or the output (in c mode) through 88960b4ad09SPeter Avalos.Pa program 89060b4ad09SPeter Avalosinstead of using the builtin compression support. 891c09f92d2SPeter Avalos.It Fl v , Fl Fl verbose 89260b4ad09SPeter AvalosProduce verbose output. 89360b4ad09SPeter AvalosIn create and extract modes, 89460b4ad09SPeter Avalos.Nm 89560b4ad09SPeter Avaloswill list each file name as it is read from or written to 89660b4ad09SPeter Avalosthe archive. 89760b4ad09SPeter AvalosIn list mode, 89860b4ad09SPeter Avalos.Nm 89960b4ad09SPeter Avaloswill produce output similar to that of 90060b4ad09SPeter Avalos.Xr ls 1 . 9016b384f39SPeter AvalosAn additional 90260b4ad09SPeter Avalos.Fl v 9036b384f39SPeter Avalosoption will also provide ls-like details in create and extract mode. 904c09f92d2SPeter Avalos.It Fl Fl version 9058029ab02SPeter AvalosPrint version of 9068029ab02SPeter Avalos.Nm 9078029ab02SPeter Avalosand 9088029ab02SPeter Avalos.Nm libarchive , 9098029ab02SPeter Avalosand exit. 910c09f92d2SPeter Avalos.It Fl w , Fl Fl confirmation , Fl Fl interactive 91160b4ad09SPeter AvalosAsk for confirmation for every action. 912c09f92d2SPeter Avalos.It Fl X Ar filename , Fl Fl exclude-from Ar filename 91360b4ad09SPeter AvalosRead a list of exclusion patterns from the specified file. 91460b4ad09SPeter AvalosSee 915c09f92d2SPeter Avalos.Fl Fl exclude 91660b4ad09SPeter Avalosfor more information about the handling of exclusions. 917e95abc47Szrj.It Fl Fl xattrs 918e95abc47Szrj(c, r, u, x modes only) 919085658deSDaniel FojtArchive or extract extended file attributes. 920085658deSDaniel FojtThis is the reverse of 921e95abc47Szrj.Fl Fl no-xattrs 922e95abc47Szrjand the default behavior in c, r, and u modes or if 923e95abc47Szrj.Nm 924e95abc47Szrjis run in x mode as root. 92560b4ad09SPeter Avalos.It Fl y 92660b4ad09SPeter Avalos(c mode only) 92760b4ad09SPeter AvalosCompress the resulting archive with 92860b4ad09SPeter Avalos.Xr bzip2 1 . 92960b4ad09SPeter AvalosIn extract or list modes, this option is ignored. 930e95abc47SzrjNote that this 93160b4ad09SPeter Avalos.Nm tar 932e95abc47Szrjimplementation recognizes bzip2 compression automatically when reading 933e95abc47Szrjarchives. 934c09f92d2SPeter Avalos.It Fl Z , Fl Fl compress , Fl Fl uncompress 93560b4ad09SPeter Avalos(c mode only) 93660b4ad09SPeter AvalosCompress the resulting archive with 93760b4ad09SPeter Avalos.Xr compress 1 . 93860b4ad09SPeter AvalosIn extract or list modes, this option is ignored. 939e95abc47SzrjNote that this 94060b4ad09SPeter Avalos.Nm tar 941e95abc47Szrjimplementation recognizes compress compression automatically when reading 942e95abc47Szrjarchives. 943c09f92d2SPeter Avalos.It Fl z , Fl Fl gunzip , Fl Fl gzip 944c09f92d2SPeter Avalos(c mode only) 945c09f92d2SPeter AvalosCompress the resulting archive with 946c09f92d2SPeter Avalos.Xr gzip 1 . 947c09f92d2SPeter AvalosIn extract or list modes, this option is ignored. 948e95abc47SzrjNote that this 949c09f92d2SPeter Avalos.Nm tar 950e95abc47Szrjimplementation recognizes gzip compression automatically when reading 951e95abc47Szrjarchives. 95260b4ad09SPeter Avalos.El 95360b4ad09SPeter Avalos.Sh ENVIRONMENT 95460b4ad09SPeter AvalosThe following environment variables affect the execution of 95560b4ad09SPeter Avalos.Nm : 95660b4ad09SPeter Avalos.Bl -tag -width ".Ev BLOCKSIZE" 957d4d8193eSPeter Avalos.It Ev TAR_READER_OPTIONS 958d4d8193eSPeter AvalosThe default options for format readers and compression readers. 959d4d8193eSPeter AvalosThe 960d4d8193eSPeter Avalos.Fl Fl options 961d4d8193eSPeter Avalosoption overrides this. 962d4d8193eSPeter Avalos.It Ev TAR_WRITER_OPTIONS 963d4d8193eSPeter AvalosThe default options for format writers and compression writers. 964d4d8193eSPeter AvalosThe 965d4d8193eSPeter Avalos.Fl Fl options 966d4d8193eSPeter Avalosoption overrides this. 96760b4ad09SPeter Avalos.It Ev LANG 96860b4ad09SPeter AvalosThe locale to use. 96960b4ad09SPeter AvalosSee 97060b4ad09SPeter Avalos.Xr environ 7 97160b4ad09SPeter Avalosfor more information. 97260b4ad09SPeter Avalos.It Ev TAPE 973c09f92d2SPeter AvalosThe default device. 97460b4ad09SPeter AvalosThe 97560b4ad09SPeter Avalos.Fl f 97660b4ad09SPeter Avalosoption overrides this. 977c09f92d2SPeter AvalosPlease see the description of the 978c09f92d2SPeter Avalos.Fl f 979c09f92d2SPeter Avalosoption above for more details. 98060b4ad09SPeter Avalos.It Ev TZ 98160b4ad09SPeter AvalosThe timezone to use when displaying dates. 98260b4ad09SPeter AvalosSee 98360b4ad09SPeter Avalos.Xr environ 7 98460b4ad09SPeter Avalosfor more information. 98560b4ad09SPeter Avalos.El 986c09f92d2SPeter Avalos.Sh EXIT STATUS 987c09f92d2SPeter Avalos.Ex -std 98860b4ad09SPeter Avalos.Sh EXAMPLES 98960b4ad09SPeter AvalosThe following creates a new archive 99060b4ad09SPeter Avaloscalled 99160b4ad09SPeter Avalos.Ar file.tar.gz 99260b4ad09SPeter Avalosthat contains two files 99360b4ad09SPeter Avalos.Ar source.c 99460b4ad09SPeter Avalosand 99560b4ad09SPeter Avalos.Ar source.h : 99660b4ad09SPeter Avalos.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h 99760b4ad09SPeter Avalos.Pp 99860b4ad09SPeter AvalosTo view a detailed table of contents for this 99960b4ad09SPeter Avalosarchive: 100060b4ad09SPeter Avalos.Dl Nm Fl tvf Pa file.tar.gz 100160b4ad09SPeter Avalos.Pp 100260b4ad09SPeter AvalosTo extract all entries from the archive on 100360b4ad09SPeter Avalosthe default tape drive: 100460b4ad09SPeter Avalos.Dl Nm Fl x 100560b4ad09SPeter Avalos.Pp 100660b4ad09SPeter AvalosTo examine the contents of an ISO 9660 cdrom image: 100760b4ad09SPeter Avalos.Dl Nm Fl tf Pa image.iso 100860b4ad09SPeter Avalos.Pp 100960b4ad09SPeter AvalosTo move file hierarchies, invoke 101060b4ad09SPeter Avalos.Nm 101160b4ad09SPeter Avalosas 1012085658deSDaniel Fojt.Dl Nm Fl cf Pa - Fl C Pa srcdir \&. | Nm Fl xpf Pa - Fl C Pa destdir 101360b4ad09SPeter Avalosor more traditionally 1014085658deSDaniel Fojt.Dl cd srcdir \&; Nm Fl cf Pa - \&. | ( cd destdir \&; Nm Fl xpf Pa - ) 101560b4ad09SPeter Avalos.Pp 101660b4ad09SPeter AvalosIn create mode, the list of files and directories to be archived 101760b4ad09SPeter Avaloscan also include directory change instructions of the form 101860b4ad09SPeter Avalos.Cm -C Ns Pa foo/baz 101960b4ad09SPeter Avalosand archive inclusions of the form 102060b4ad09SPeter Avalos.Cm @ Ns Pa archive-file . 102160b4ad09SPeter AvalosFor example, the command line 102260b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2 102360b4ad09SPeter Avaloswill create a new archive 102460b4ad09SPeter Avalos.Pa new.tar . 102560b4ad09SPeter Avalos.Nm 102660b4ad09SPeter Avaloswill read the file 102760b4ad09SPeter Avalos.Pa foo1 102860b4ad09SPeter Avalosfrom the current directory and add it to the output archive. 102960b4ad09SPeter AvalosIt will then read each entry from 103060b4ad09SPeter Avalos.Pa old.tgz 103160b4ad09SPeter Avalosand add those entries to the output archive. 103260b4ad09SPeter AvalosFinally, it will switch to the 103360b4ad09SPeter Avalos.Pa /tmp 103460b4ad09SPeter Avalosdirectory and add 103560b4ad09SPeter Avalos.Pa foo2 103660b4ad09SPeter Avalosto the output archive. 103760b4ad09SPeter Avalos.Pp 103860b4ad09SPeter AvalosAn input file in 103960b4ad09SPeter Avalos.Xr mtree 5 104060b4ad09SPeter Avalosformat can be used to create an output archive with arbitrary ownership, 104160b4ad09SPeter Avalospermissions, or names that differ from existing data on disk: 10426b384f39SPeter Avalos.Bd -literal -offset indent 10436b384f39SPeter Avalos$ cat input.mtree 10446b384f39SPeter Avalos#mtree 10456b384f39SPeter Avalosusr/bin uid=0 gid=0 mode=0755 type=dir 10466b384f39SPeter Avalosusr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls 10476b384f39SPeter Avalos$ tar -cvf output.tar @input.mtree 10486b384f39SPeter Avalos.Ed 104960b4ad09SPeter Avalos.Pp 105060b4ad09SPeter AvalosThe 1051c09f92d2SPeter Avalos.Fl Fl newer 105260b4ad09SPeter Avalosand 1053c09f92d2SPeter Avalos.Fl Fl newer-mtime 105460b4ad09SPeter Avalosswitches accept a variety of common date and time specifications, including 105560b4ad09SPeter Avalos.Dq 12 Mar 2005 7:14:29pm , 105660b4ad09SPeter Avalos.Dq 2005-03-12 19:14 , 105760b4ad09SPeter Avalos.Dq 5 minutes ago , 105860b4ad09SPeter Avalosand 105960b4ad09SPeter Avalos.Dq 19:14 PST May 1 . 10608029ab02SPeter Avalos.Pp 10618029ab02SPeter AvalosThe 1062c09f92d2SPeter Avalos.Fl Fl options 10638029ab02SPeter Avalosargument can be used to control various details of archive generation 10648029ab02SPeter Avalosor reading. 10658029ab02SPeter AvalosFor example, you can generate mtree output which only contains 10668029ab02SPeter Avalos.Cm type , Cm time , 10678029ab02SPeter Avalosand 10688029ab02SPeter Avalos.Cm uid 10698029ab02SPeter Avaloskeywords: 1070c09f92d2SPeter Avalos.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir 10718029ab02SPeter Avalosor you can set the compression level used by gzip or xz compression: 1072c09f92d2SPeter Avalos.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' . 10738029ab02SPeter AvalosFor more details, see the explanation of the 10748029ab02SPeter Avalos.Fn archive_read_set_options 10758029ab02SPeter Avalosand 10768029ab02SPeter Avalos.Fn archive_write_set_options 10778029ab02SPeter AvalosAPI calls that are described in 10788029ab02SPeter Avalos.Xr archive_read 3 10798029ab02SPeter Avalosand 10808029ab02SPeter Avalos.Xr archive_write 3 . 108160b4ad09SPeter Avalos.Sh COMPATIBILITY 108260b4ad09SPeter AvalosThe bundled-arguments format is supported for compatibility 108360b4ad09SPeter Avaloswith historic implementations. 108460b4ad09SPeter AvalosIt consists of an initial word (with no leading - character) in which 108560b4ad09SPeter Avaloseach character indicates an option. 108660b4ad09SPeter AvalosArguments follow as separate words. 108760b4ad09SPeter AvalosThe order of the arguments must match the order 108860b4ad09SPeter Avalosof the corresponding characters in the bundled command word. 108960b4ad09SPeter AvalosFor example, 109060b4ad09SPeter Avalos.Dl Nm Cm tbf 32 Pa file.tar 109160b4ad09SPeter Avalosspecifies three flags 109260b4ad09SPeter Avalos.Cm t , 109360b4ad09SPeter Avalos.Cm b , 109460b4ad09SPeter Avalosand 109560b4ad09SPeter Avalos.Cm f . 109660b4ad09SPeter AvalosThe 109760b4ad09SPeter Avalos.Cm b 109860b4ad09SPeter Avalosand 109960b4ad09SPeter Avalos.Cm f 110060b4ad09SPeter Avalosflags both require arguments, 110160b4ad09SPeter Avalosso there must be two additional items 110260b4ad09SPeter Avaloson the command line. 110360b4ad09SPeter AvalosThe 110460b4ad09SPeter Avalos.Ar 32 110560b4ad09SPeter Avalosis the argument to the 110660b4ad09SPeter Avalos.Cm b 110760b4ad09SPeter Avalosflag, and 110860b4ad09SPeter Avalos.Ar file.tar 110960b4ad09SPeter Avalosis the argument to the 111060b4ad09SPeter Avalos.Cm f 111160b4ad09SPeter Avalosflag. 111260b4ad09SPeter Avalos.Pp 111360b4ad09SPeter AvalosThe mode options c, r, t, u, and x and the options 111460b4ad09SPeter Avalosb, f, l, m, o, v, and w comply with SUSv2. 111560b4ad09SPeter Avalos.Pp 111660b4ad09SPeter AvalosFor maximum portability, scripts that invoke 111760b4ad09SPeter Avalos.Nm tar 111860b4ad09SPeter Avalosshould use the bundled-argument format above, should limit 111960b4ad09SPeter Avalosthemselves to the 112060b4ad09SPeter Avalos.Cm c , 112160b4ad09SPeter Avalos.Cm t , 112260b4ad09SPeter Avalosand 112360b4ad09SPeter Avalos.Cm x 112460b4ad09SPeter Avalosmodes, and the 112560b4ad09SPeter Avalos.Cm b , 112660b4ad09SPeter Avalos.Cm f , 112760b4ad09SPeter Avalos.Cm m , 112860b4ad09SPeter Avalos.Cm v , 112960b4ad09SPeter Avalosand 113060b4ad09SPeter Avalos.Cm w 113160b4ad09SPeter Avalosoptions. 113260b4ad09SPeter Avalos.Pp 11338029ab02SPeter AvalosAdditional long options are provided to improve compatibility with other 11348029ab02SPeter Avalostar implementations. 113560b4ad09SPeter Avalos.Sh SECURITY 113660b4ad09SPeter AvalosCertain security issues are common to many archiving programs, including 113760b4ad09SPeter Avalos.Nm . 113860b4ad09SPeter AvalosIn particular, carefully-crafted archives can request that 113960b4ad09SPeter Avalos.Nm 114060b4ad09SPeter Avalosextract files to locations outside of the target directory. 114160b4ad09SPeter AvalosThis can potentially be used to cause unwitting users to overwrite 114260b4ad09SPeter Avalosfiles they did not intend to overwrite. 114360b4ad09SPeter AvalosIf the archive is being extracted by the superuser, any file 114460b4ad09SPeter Avaloson the system can potentially be overwritten. 114560b4ad09SPeter AvalosThere are three ways this can happen. 114660b4ad09SPeter AvalosAlthough 114760b4ad09SPeter Avalos.Nm 114860b4ad09SPeter Avaloshas mechanisms to protect against each one, 114960b4ad09SPeter Avalossavvy users should be aware of the implications: 115060b4ad09SPeter Avalos.Bl -bullet -width indent 115160b4ad09SPeter Avalos.It 115260b4ad09SPeter AvalosArchive entries can have absolute pathnames. 115360b4ad09SPeter AvalosBy default, 115460b4ad09SPeter Avalos.Nm 115560b4ad09SPeter Avalosremoves the leading 115660b4ad09SPeter Avalos.Pa / 115760b4ad09SPeter Avaloscharacter from filenames before restoring them to guard against this problem. 115860b4ad09SPeter Avalos.It 115960b4ad09SPeter AvalosArchive entries can have pathnames that include 116060b4ad09SPeter Avalos.Pa .. 116160b4ad09SPeter Avaloscomponents. 116260b4ad09SPeter AvalosBy default, 116360b4ad09SPeter Avalos.Nm 116460b4ad09SPeter Avaloswill not extract files containing 116560b4ad09SPeter Avalos.Pa .. 116660b4ad09SPeter Avaloscomponents in their pathname. 116760b4ad09SPeter Avalos.It 116860b4ad09SPeter AvalosArchive entries can exploit symbolic links to restore 116960b4ad09SPeter Avalosfiles to other directories. 117060b4ad09SPeter AvalosAn archive can restore a symbolic link to another directory, 117160b4ad09SPeter Avalosthen use that link to restore a file into that directory. 117260b4ad09SPeter AvalosTo guard against this, 117360b4ad09SPeter Avalos.Nm 117460b4ad09SPeter Avaloschecks each extracted path for symlinks. 117560b4ad09SPeter AvalosIf the final path element is a symlink, it will be removed 117660b4ad09SPeter Avalosand replaced with the archive entry. 117760b4ad09SPeter AvalosIf 117860b4ad09SPeter Avalos.Fl U 117960b4ad09SPeter Avalosis specified, any intermediate symlink will also be unconditionally removed. 118060b4ad09SPeter AvalosIf neither 118160b4ad09SPeter Avalos.Fl U 118260b4ad09SPeter Avalosnor 118360b4ad09SPeter Avalos.Fl P 118460b4ad09SPeter Avalosis specified, 118560b4ad09SPeter Avalos.Nm 118660b4ad09SPeter Avaloswill refuse to extract the entry. 118760b4ad09SPeter Avalos.El 118860b4ad09SPeter AvalosTo protect yourself, you should be wary of any archives that 118960b4ad09SPeter Avaloscome from untrusted sources. 119060b4ad09SPeter AvalosYou should examine the contents of an archive with 119160b4ad09SPeter Avalos.Dl Nm Fl tf Pa filename 119260b4ad09SPeter Avalosbefore extraction. 119360b4ad09SPeter AvalosYou should use the 119460b4ad09SPeter Avalos.Fl k 119560b4ad09SPeter Avalosoption to ensure that 119660b4ad09SPeter Avalos.Nm 119760b4ad09SPeter Avaloswill not overwrite any existing files or the 119860b4ad09SPeter Avalos.Fl U 119960b4ad09SPeter Avalosoption to remove any pre-existing files. 120060b4ad09SPeter AvalosYou should generally not extract archives while running with super-user 120160b4ad09SPeter Avalosprivileges. 120260b4ad09SPeter AvalosNote that the 120360b4ad09SPeter Avalos.Fl P 120460b4ad09SPeter Avalosoption to 120560b4ad09SPeter Avalos.Nm 120660b4ad09SPeter Avalosdisables the security checks above and allows you to extract 120760b4ad09SPeter Avalosan archive while preserving any absolute pathnames, 120860b4ad09SPeter Avalos.Pa .. 120960b4ad09SPeter Avaloscomponents, or symlinks to other directories. 121060b4ad09SPeter Avalos.Sh SEE ALSO 121160b4ad09SPeter Avalos.Xr bzip2 1 , 121260b4ad09SPeter Avalos.Xr compress 1 , 121360b4ad09SPeter Avalos.Xr cpio 1 , 121460b4ad09SPeter Avalos.Xr gzip 1 , 121560b4ad09SPeter Avalos.Xr mt 1 , 121660b4ad09SPeter Avalos.Xr pax 1 , 121760b4ad09SPeter Avalos.Xr shar 1 , 1218c09f92d2SPeter Avalos.Xr xz 1 , 121960b4ad09SPeter Avalos.Xr libarchive 3 , 122060b4ad09SPeter Avalos.Xr libarchive-formats 5 , 122160b4ad09SPeter Avalos.Xr tar 5 122260b4ad09SPeter Avalos.Sh STANDARDS 122360b4ad09SPeter AvalosThere is no current POSIX standard for the tar command; it appeared 122460b4ad09SPeter Avalosin 122560b4ad09SPeter Avalos.St -p1003.1-96 122660b4ad09SPeter Avalosbut was dropped from 122760b4ad09SPeter Avalos.St -p1003.1-2001 . 1228c09f92d2SPeter AvalosThe options supported by this implementation were developed by surveying a 122960b4ad09SPeter Avalosnumber of existing tar implementations as well as the old POSIX specification 123060b4ad09SPeter Avalosfor tar and the current POSIX specification for pax. 123160b4ad09SPeter Avalos.Pp 123260b4ad09SPeter AvalosThe ustar and pax interchange file formats are defined by 123360b4ad09SPeter Avalos.St -p1003.1-2001 123460b4ad09SPeter Avalosfor the pax command. 123560b4ad09SPeter Avalos.Sh HISTORY 123660b4ad09SPeter AvalosA 123760b4ad09SPeter Avalos.Nm tar 123860b4ad09SPeter Avaloscommand appeared in Seventh Edition Unix, which was released in January, 1979. 123960b4ad09SPeter AvalosThere have been numerous other implementations, 124060b4ad09SPeter Avalosmany of which extended the file format. 124160b4ad09SPeter AvalosJohn Gilmore's 124260b4ad09SPeter Avalos.Nm pdtar 124360b4ad09SPeter Avalospublic-domain implementation (circa November, 1987) 124460b4ad09SPeter Avaloswas quite influential, and formed the basis of GNU tar. 124560b4ad09SPeter AvalosGNU tar was included as the standard system tar 124660b4ad09SPeter Avalosin 124760b4ad09SPeter Avalos.Fx 124860b4ad09SPeter Avalosbeginning with 124960b4ad09SPeter Avalos.Fx 1.0 . 125060b4ad09SPeter Avalos.Pp 125160b4ad09SPeter AvalosThis is a complete re-implementation based on the 125260b4ad09SPeter Avalos.Xr libarchive 3 125360b4ad09SPeter Avaloslibrary. 1254c09f92d2SPeter AvalosIt was first released with 1255c09f92d2SPeter Avalos.Fx 5.4 1256c09f92d2SPeter Avalosin May, 2005. 125760b4ad09SPeter Avalos.Sh BUGS 125860b4ad09SPeter AvalosThis program follows 125960b4ad09SPeter Avalos.St -p1003.1-96 126060b4ad09SPeter Avalosfor the definition of the 126160b4ad09SPeter Avalos.Fl l 126260b4ad09SPeter Avalosoption. 126360b4ad09SPeter AvalosNote that GNU tar prior to version 1.15 treated 126460b4ad09SPeter Avalos.Fl l 126560b4ad09SPeter Avalosas a synonym for the 1266c09f92d2SPeter Avalos.Fl Fl one-file-system 126760b4ad09SPeter Avalosoption. 126860b4ad09SPeter Avalos.Pp 126960b4ad09SPeter AvalosThe 127060b4ad09SPeter Avalos.Fl C Pa dir 127160b4ad09SPeter Avalosoption may differ from historic implementations. 127260b4ad09SPeter Avalos.Pp 127360b4ad09SPeter AvalosAll archive output is written in correctly-sized blocks, even 127460b4ad09SPeter Avalosif the output is being compressed. 127560b4ad09SPeter AvalosWhether or not the last output block is padded to a full 127660b4ad09SPeter Avalosblock size varies depending on the format and the 127760b4ad09SPeter Avalosoutput device. 127860b4ad09SPeter AvalosFor tar and cpio formats, the last block of output is padded 127960b4ad09SPeter Avalosto a full block size if the output is being 128060b4ad09SPeter Avaloswritten to standard output or to a character or block device such as 128160b4ad09SPeter Avalosa tape drive. 128260b4ad09SPeter AvalosIf the output is being written to a regular file, the last block 128360b4ad09SPeter Avaloswill not be padded. 128460b4ad09SPeter AvalosMany compressors, including 128560b4ad09SPeter Avalos.Xr gzip 1 128660b4ad09SPeter Avalosand 128760b4ad09SPeter Avalos.Xr bzip2 1 , 128860b4ad09SPeter Avaloscomplain about the null padding when decompressing an archive created by 128960b4ad09SPeter Avalos.Nm , 129060b4ad09SPeter Avalosalthough they still extract it correctly. 129160b4ad09SPeter Avalos.Pp 129260b4ad09SPeter AvalosThe compression and decompression is implemented internally, so 129360b4ad09SPeter Avalosthere may be insignificant differences between the compressed output 129460b4ad09SPeter Avalosgenerated by 129560b4ad09SPeter Avalos.Dl Nm Fl czf Pa - file 129660b4ad09SPeter Avalosand that generated by 129760b4ad09SPeter Avalos.Dl Nm Fl cf Pa - file | Nm gzip 129860b4ad09SPeter Avalos.Pp 129960b4ad09SPeter AvalosThe default should be to read and write archives to the standard I/O paths, 130060b4ad09SPeter Avalosbut tradition (and POSIX) dictates otherwise. 130160b4ad09SPeter Avalos.Pp 130260b4ad09SPeter AvalosThe 130360b4ad09SPeter Avalos.Cm r 130460b4ad09SPeter Avalosand 130560b4ad09SPeter Avalos.Cm u 130660b4ad09SPeter Avalosmodes require that the archive be uncompressed 130760b4ad09SPeter Avalosand located in a regular file on disk. 130860b4ad09SPeter AvalosOther archives can be modified using 130960b4ad09SPeter Avalos.Cm c 131060b4ad09SPeter Avalosmode with the 131160b4ad09SPeter Avalos.Pa @archive-file 131260b4ad09SPeter Avalosextension. 131360b4ad09SPeter Avalos.Pp 131460b4ad09SPeter AvalosTo archive a file called 131560b4ad09SPeter Avalos.Pa @foo 131660b4ad09SPeter Avalosor 131760b4ad09SPeter Avalos.Pa -foo 131860b4ad09SPeter Avalosyou must specify it as 131960b4ad09SPeter Avalos.Pa ./@foo 132060b4ad09SPeter Avalosor 132160b4ad09SPeter Avalos.Pa ./-foo , 132260b4ad09SPeter Avalosrespectively. 132360b4ad09SPeter Avalos.Pp 132460b4ad09SPeter AvalosIn create mode, a leading 132560b4ad09SPeter Avalos.Pa ./ 132660b4ad09SPeter Avalosis always removed. 132760b4ad09SPeter AvalosA leading 132860b4ad09SPeter Avalos.Pa / 132960b4ad09SPeter Avalosis stripped unless the 133060b4ad09SPeter Avalos.Fl P 133160b4ad09SPeter Avalosoption is specified. 133260b4ad09SPeter Avalos.Pp 133360b4ad09SPeter AvalosThere needs to be better support for file selection on both create 133460b4ad09SPeter Avalosand extract. 133560b4ad09SPeter Avalos.Pp 13366b384f39SPeter AvalosThere is not yet any support for multi-volume archives. 133760b4ad09SPeter Avalos.Pp 133860b4ad09SPeter AvalosConverting between dissimilar archive formats (such as tar and cpio) using the 133960b4ad09SPeter Avalos.Cm @ Ns Pa - 134060b4ad09SPeter Avalosconvention can cause hard link information to be lost. 134160b4ad09SPeter Avalos(This is a consequence of the incompatible ways that different archive 134260b4ad09SPeter Avalosformats store hardlink information.) 1343