1caf54c4fSMartin Matuska.\" Copyright (c) 2003-2007 Tim Kientzle 264287048SMartin Matuska.\" Copyright (c) 2017 Martin Matuska 3caf54c4fSMartin Matuska.\" All rights reserved. 4caf54c4fSMartin Matuska.\" 5caf54c4fSMartin Matuska.\" Redistribution and use in source and binary forms, with or without 6caf54c4fSMartin Matuska.\" modification, are permitted provided that the following conditions 7caf54c4fSMartin Matuska.\" are met: 8caf54c4fSMartin Matuska.\" 1. Redistributions of source code must retain the above copyright 9caf54c4fSMartin Matuska.\" notice, this list of conditions and the following disclaimer. 10caf54c4fSMartin Matuska.\" 2. Redistributions in binary form must reproduce the above copyright 11caf54c4fSMartin Matuska.\" notice, this list of conditions and the following disclaimer in the 12caf54c4fSMartin Matuska.\" documentation and/or other materials provided with the distribution. 13caf54c4fSMartin Matuska.\" 14caf54c4fSMartin Matuska.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15caf54c4fSMartin Matuska.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16caf54c4fSMartin Matuska.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17caf54c4fSMartin Matuska.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18caf54c4fSMartin Matuska.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19caf54c4fSMartin Matuska.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20caf54c4fSMartin Matuska.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21caf54c4fSMartin Matuska.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22caf54c4fSMartin Matuska.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23caf54c4fSMartin Matuska.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24caf54c4fSMartin Matuska.\" SUCH DAMAGE. 25caf54c4fSMartin Matuska.\" 266c22d9efSMartin Matuska.\" $FreeBSD$ 27caf54c4fSMartin Matuska.\" 285c831a5bSMartin Matuska.Dd October 1, 2017 296c95142eSMartin Matuska.Dt TAR 1 30caf54c4fSMartin Matuska.Os 31caf54c4fSMartin Matuska.Sh NAME 32caf54c4fSMartin Matuska.Nm tar 33caf54c4fSMartin Matuska.Nd manipulate tape archives 34caf54c4fSMartin Matuska.Sh SYNOPSIS 35caf54c4fSMartin Matuska.Nm 36caf54c4fSMartin Matuska.Op Ar bundled-flags Ao args Ac 37caf54c4fSMartin Matuska.Op Ao Ar file Ac | Ao Ar pattern Ac ... 38caf54c4fSMartin Matuska.Nm 39caf54c4fSMartin Matuska.Brq Fl c 40caf54c4fSMartin Matuska.Op Ar options 41caf54c4fSMartin Matuska.Op Ar files | Ar directories 42caf54c4fSMartin Matuska.Nm 43caf54c4fSMartin Matuska.Brq Fl r | Fl u 44caf54c4fSMartin Matuska.Fl f Ar archive-file 45caf54c4fSMartin Matuska.Op Ar options 46caf54c4fSMartin Matuska.Op Ar files | Ar directories 47caf54c4fSMartin Matuska.Nm 48caf54c4fSMartin Matuska.Brq Fl t | Fl x 49caf54c4fSMartin Matuska.Op Ar options 50caf54c4fSMartin Matuska.Op Ar patterns 51caf54c4fSMartin Matuska.Sh DESCRIPTION 52caf54c4fSMartin Matuska.Nm 53caf54c4fSMartin Matuskacreates and manipulates streaming archive files. 54c5d360f8SMartin MatuskaThis implementation can extract from tar, pax, cpio, zip, jar, ar, xar, 556c95142eSMartin Matuskarpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip, 566c95142eSMartin Matuska7-zip, and shar archives. 57caf54c4fSMartin Matuska.Pp 58caf54c4fSMartin MatuskaThe first synopsis form shows a 59caf54c4fSMartin Matuska.Dq bundled 60caf54c4fSMartin Matuskaoption word. 61caf54c4fSMartin MatuskaThis usage is provided for compatibility with historical implementations. 62caf54c4fSMartin MatuskaSee COMPATIBILITY below for details. 63caf54c4fSMartin Matuska.Pp 64caf54c4fSMartin MatuskaThe other synopsis forms show the preferred usage. 65caf54c4fSMartin MatuskaThe first option to 66caf54c4fSMartin Matuska.Nm 67caf54c4fSMartin Matuskais a mode indicator from the following list: 68caf54c4fSMartin Matuska.Bl -tag -compact -width indent 69caf54c4fSMartin Matuska.It Fl c 70caf54c4fSMartin MatuskaCreate a new archive containing the specified items. 71c5d360f8SMartin MatuskaThe long option form is 72c5d360f8SMartin Matuska.Fl Fl create . 73caf54c4fSMartin Matuska.It Fl r 74caf54c4fSMartin MatuskaLike 75caf54c4fSMartin Matuska.Fl c , 76caf54c4fSMartin Matuskabut new entries are appended to the archive. 77caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files. 78caf54c4fSMartin MatuskaThe 79caf54c4fSMartin Matuska.Fl f 80caf54c4fSMartin Matuskaoption is required. 81c5d360f8SMartin MatuskaThe long option form is 82c5d360f8SMartin Matuska.Fl Fl append . 83caf54c4fSMartin Matuska.It Fl t 84caf54c4fSMartin MatuskaList archive contents to stdout. 85c5d360f8SMartin MatuskaThe long option form is 86c5d360f8SMartin Matuska.Fl Fl list . 87caf54c4fSMartin Matuska.It Fl u 88caf54c4fSMartin MatuskaLike 89caf54c4fSMartin Matuska.Fl r , 90caf54c4fSMartin Matuskabut new entries are added only if they have a modification date 91caf54c4fSMartin Matuskanewer than the corresponding entry in the archive. 92caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files. 93caf54c4fSMartin MatuskaThe 94caf54c4fSMartin Matuska.Fl f 95caf54c4fSMartin Matuskaoption is required. 96c5d360f8SMartin MatuskaThe long form is 97c5d360f8SMartin Matuska.Fl Fl update . 98caf54c4fSMartin Matuska.It Fl x 99caf54c4fSMartin MatuskaExtract to disk from the archive. 100caf54c4fSMartin MatuskaIf a file with the same name appears more than once in the archive, 101caf54c4fSMartin Matuskaeach copy will be extracted, with later copies overwriting (replacing) 102caf54c4fSMartin Matuskaearlier copies. 103c5d360f8SMartin MatuskaThe long option form is 104c5d360f8SMartin Matuska.Fl Fl extract . 105caf54c4fSMartin Matuska.El 106caf54c4fSMartin Matuska.Pp 107caf54c4fSMartin MatuskaIn 108caf54c4fSMartin Matuska.Fl c , 109caf54c4fSMartin Matuska.Fl r , 110caf54c4fSMartin Matuskaor 111caf54c4fSMartin Matuska.Fl u 112caf54c4fSMartin Matuskamode, each specified file or directory is added to the 113caf54c4fSMartin Matuskaarchive in the order specified on the command line. 114caf54c4fSMartin MatuskaBy default, the contents of each directory are also archived. 115caf54c4fSMartin Matuska.Pp 116caf54c4fSMartin MatuskaIn extract or list mode, the entire command line 117caf54c4fSMartin Matuskais read and parsed before the archive is opened. 118caf54c4fSMartin MatuskaThe pathnames or patterns on the command line indicate 119caf54c4fSMartin Matuskawhich items in the archive should be processed. 120caf54c4fSMartin MatuskaPatterns are shell-style globbing patterns as 121caf54c4fSMartin Matuskadocumented in 122caf54c4fSMartin Matuska.Xr tcsh 1 . 123caf54c4fSMartin Matuska.Sh OPTIONS 124caf54c4fSMartin MatuskaUnless specifically stated otherwise, options are applicable in 125caf54c4fSMartin Matuskaall operating modes. 126caf54c4fSMartin Matuska.Bl -tag -width indent 127caf54c4fSMartin Matuska.It Cm @ Ns Pa archive 12864287048SMartin Matuska(c and r modes only) 129caf54c4fSMartin MatuskaThe specified archive is opened and the entries 130caf54c4fSMartin Matuskain it will be appended to the current archive. 131caf54c4fSMartin MatuskaAs a simple example, 132caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar 133caf54c4fSMartin Matuskawrites a new archive to standard output containing a file 134caf54c4fSMartin Matuska.Pa newfile 135caf54c4fSMartin Matuskaand all of the entries from 136caf54c4fSMartin Matuska.Pa original.tar . 137caf54c4fSMartin MatuskaIn contrast, 138caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar 139caf54c4fSMartin Matuskacreates a new archive with only two entries. 140caf54c4fSMartin MatuskaSimilarly, 141c5d360f8SMartin Matuska.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa - 142caf54c4fSMartin Matuskareads an archive from standard input (whose format will be determined 143caf54c4fSMartin Matuskaautomatically) and converts it into a gzip-compressed 144caf54c4fSMartin Matuskapax-format archive on stdout. 145caf54c4fSMartin MatuskaIn this way, 146caf54c4fSMartin Matuska.Nm 147caf54c4fSMartin Matuskacan be used to convert archives from one format to another. 148acc60b03SMartin Matuska.It Fl a , Fl Fl auto-compress 149acc60b03SMartin Matuska(c mode only) 150acc60b03SMartin MatuskaUse the archive suffix to decide a set of the format and 151acc60b03SMartin Matuskathe compressions. 152acc60b03SMartin MatuskaAs a simple example, 153acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h 154acc60b03SMartin Matuskacreates a new archive with restricted pax format and gzip compression, 155acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h 156acc60b03SMartin Matuskacreates a new archive with restricted pax format and bzip2 compression 157acc60b03SMartin Matuskaand uuencode compression, 158acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.zip source.c source.h 159acc60b03SMartin Matuskacreates a new archive with zip format, 160acc60b03SMartin Matuska.Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h 161acc60b03SMartin Matuskaignores the 162acc60b03SMartin Matuska.Dq -j 163acc60b03SMartin Matuskaoption, and creates a new archive with restricted pax format 164acc60b03SMartin Matuskaand gzip compression, 165acc60b03SMartin Matuska.Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h 166acc60b03SMartin Matuskaif it is unknown suffix or no suffix, creates a new archive with 167acc60b03SMartin Matuskarestricted pax format and bzip2 compression. 16864287048SMartin Matuska.It Fl Fl acls 16964287048SMartin Matuska(c, r, u, x modes only) 17064287048SMartin MatuskaArchive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of 17164287048SMartin Matuska.Fl Fl no-acls 172e46d4714SMartin Matuskaand the default behavior in c, r, and u modes (except on Mac OS X) or if 17364287048SMartin Matuska.Nm 17464287048SMartin Matuskais run in x mode as root. On Mac OS X this option translates extended ACLs 17564287048SMartin Matuskato NFSv4 ACLs. To store extended ACLs the 17664287048SMartin Matuska.Fl Fl mac-metadata 17764287048SMartin Matuskaoption is preferred. 178c5d360f8SMartin Matuska.It Fl B , Fl Fl read-full-blocks 179c5d360f8SMartin MatuskaIgnored for compatibility with other 180c5d360f8SMartin Matuska.Xr tar 1 181c5d360f8SMartin Matuskaimplementations. 182c5d360f8SMartin Matuska.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize 183caf54c4fSMartin MatuskaSpecify the block size, in 512-byte records, for tape drive I/O. 184caf54c4fSMartin MatuskaAs a rule, this argument is only needed when reading from or writing 185caf54c4fSMartin Matuskato tape drives, and usually not even then as the default block size of 186caf54c4fSMartin Matuska20 records (10240 bytes) is very common. 1876c95142eSMartin Matuska.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory 188caf54c4fSMartin MatuskaIn c and r mode, this changes the directory before adding 189caf54c4fSMartin Matuskathe following files. 190caf54c4fSMartin MatuskaIn x mode, change directories after opening the archive 191caf54c4fSMartin Matuskabut before extracting entries from the archive. 192c5d360f8SMartin Matuska.It Fl Fl chroot 193caf54c4fSMartin Matuska(x mode only) 194caf54c4fSMartin Matuska.Fn chroot 195caf54c4fSMartin Matuskato the current directory after processing any 196caf54c4fSMartin Matuska.Fl C 197caf54c4fSMartin Matuskaoptions and before extracting any files. 198cdf63a70SMartin Matuska.It Fl Fl clear-nochange-fflags 199cdf63a70SMartin Matuska(x mode only) 200cdf63a70SMartin MatuskaBefore removing file system objects to replace them, clear platform-specific 201cdf63a70SMartin Matuskafile flags that might prevent removal. 202c5d360f8SMartin Matuska.It Fl Fl exclude Ar pattern 203caf54c4fSMartin MatuskaDo not process files or directories that match the 204caf54c4fSMartin Matuskaspecified pattern. 205caf54c4fSMartin MatuskaNote that exclusions take precedence over patterns or filenames 206caf54c4fSMartin Matuskaspecified on the command line. 207*52c2bb75SMartin Matuska.It Fl Fl exclude-vcs 208*52c2bb75SMartin MatuskaDo not process files or directories internally used by the 209*52c2bb75SMartin Matuskaversion control systems 210*52c2bb75SMartin Matuska.Sq CVS , 211*52c2bb75SMartin Matuska.Sq RCS , 212*52c2bb75SMartin Matuska.Sq SCCS , 213*52c2bb75SMartin Matuska.Sq SVN , 214*52c2bb75SMartin Matuska.Sq Arch , 215*52c2bb75SMartin Matuska.Sq Bazaar , 216*52c2bb75SMartin Matuska.Sq Mercurial 217*52c2bb75SMartin Matuskaand 218*52c2bb75SMartin Matuska.Sq Darcs . 21964287048SMartin Matuska.It Fl Fl fflags 22064287048SMartin Matuska(c, r, u, x modes only) 22164287048SMartin MatuskaArchive or extract file flags. This is the reverse of 22264287048SMartin Matuska.Fl Fl no-fflags 22364287048SMartin Matuskaand the default behavior in c, r, and u modes or if 22464287048SMartin Matuska.Nm 22564287048SMartin Matuskais run in x mode as root. 226c5d360f8SMartin Matuska.It Fl Fl format Ar format 227caf54c4fSMartin Matuska(c, r, u mode only) 228caf54c4fSMartin MatuskaUse the specified format for the created archive. 229caf54c4fSMartin MatuskaSupported formats include 230caf54c4fSMartin Matuska.Dq cpio , 231caf54c4fSMartin Matuska.Dq pax , 232caf54c4fSMartin Matuska.Dq shar , 233caf54c4fSMartin Matuskaand 234caf54c4fSMartin Matuska.Dq ustar . 235caf54c4fSMartin MatuskaOther formats may also be supported; see 236caf54c4fSMartin Matuska.Xr libarchive-formats 5 237caf54c4fSMartin Matuskafor more information about currently-supported formats. 238caf54c4fSMartin MatuskaIn r and u modes, when extending an existing archive, the format specified 239caf54c4fSMartin Matuskahere must be compatible with the format of the existing archive on disk. 240c5d360f8SMartin Matuska.It Fl f Ar file , Fl Fl file Ar file 241caf54c4fSMartin MatuskaRead the archive from or write the archive to the specified file. 242caf54c4fSMartin MatuskaThe filename can be 243caf54c4fSMartin Matuska.Pa - 244caf54c4fSMartin Matuskafor standard input or standard output. 245c5d360f8SMartin MatuskaThe default varies by system; 246c5d360f8SMartin Matuskaon 247caf54c4fSMartin Matuska.Fx , 248c5d360f8SMartin Matuskathe default is 249c5d360f8SMartin Matuska.Pa /dev/sa0 ; 250c5d360f8SMartin Matuskaon Linux, the default is 251c5d360f8SMartin Matuska.Pa /dev/st0 . 252caf54c4fSMartin Matuska.It Fl Fl gid Ar id 253caf54c4fSMartin MatuskaUse the provided group id number. 254caf54c4fSMartin MatuskaOn extract, this overrides the group id in the archive; 255caf54c4fSMartin Matuskathe group name in the archive will be ignored. 256caf54c4fSMartin MatuskaOn create, this overrides the group id read from disk; 257caf54c4fSMartin Matuskaif 258caf54c4fSMartin Matuska.Fl Fl gname 259caf54c4fSMartin Matuskais not also specified, the group name will be set to 260caf54c4fSMartin Matuskamatch the group id. 261caf54c4fSMartin Matuska.It Fl Fl gname Ar name 262caf54c4fSMartin MatuskaUse the provided group name. 263caf54c4fSMartin MatuskaOn extract, this overrides the group name in the archive; 264caf54c4fSMartin Matuskaif the provided group name does not exist on the system, 265caf54c4fSMartin Matuskathe group id 266caf54c4fSMartin Matuska(from the archive or from the 267caf54c4fSMartin Matuska.Fl Fl gid 268caf54c4fSMartin Matuskaoption) 269caf54c4fSMartin Matuskawill be used instead. 270caf54c4fSMartin MatuskaOn create, this sets the group name that will be stored 271caf54c4fSMartin Matuskain the archive; 272caf54c4fSMartin Matuskathe name will not be verified against the system group database. 273caf54c4fSMartin Matuska.It Fl H 27464287048SMartin Matuska(c and r modes only) 275caf54c4fSMartin MatuskaSymbolic links named on the command line will be followed; the 276caf54c4fSMartin Matuskatarget of the link will be archived, not the link itself. 277caf54c4fSMartin Matuska.It Fl h 27864287048SMartin Matuska(c and r modes only) 279caf54c4fSMartin MatuskaSynonym for 280caf54c4fSMartin Matuska.Fl L . 281caf54c4fSMartin Matuska.It Fl I 282caf54c4fSMartin MatuskaSynonym for 283caf54c4fSMartin Matuska.Fl T . 284c5d360f8SMartin Matuska.It Fl Fl help 285c5d360f8SMartin MatuskaShow usage. 286acc60b03SMartin Matuska.It Fl Fl hfsCompression 287acc60b03SMartin Matuska(x mode only) 28864287048SMartin MatuskaMac OS X specific (v10.6 or later). Compress extracted regular files with HFS+ 28964287048SMartin Matuskacompression. 290cdf63a70SMartin Matuska.It Fl Fl ignore-zeros 291cdf63a70SMartin MatuskaAn alias of 292cdf63a70SMartin Matuska.Fl Fl options Cm read_concatenated_archives 293cdf63a70SMartin Matuskafor compatibility with GNU tar. 294c5d360f8SMartin Matuska.It Fl Fl include Ar pattern 295caf54c4fSMartin MatuskaProcess only files or directories that match the specified pattern. 296caf54c4fSMartin MatuskaNote that exclusions specified with 297c5d360f8SMartin Matuska.Fl Fl exclude 298caf54c4fSMartin Matuskatake precedence over inclusions. 299caf54c4fSMartin MatuskaIf no inclusions are explicitly specified, all entries are processed by 300caf54c4fSMartin Matuskadefault. 301caf54c4fSMartin MatuskaThe 302c5d360f8SMartin Matuska.Fl Fl include 303caf54c4fSMartin Matuskaoption is especially useful when filtering archives. 304caf54c4fSMartin MatuskaFor example, the command 305c5d360f8SMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz 306caf54c4fSMartin Matuskacreates a new archive 307caf54c4fSMartin Matuska.Pa new.tar 308caf54c4fSMartin Matuskacontaining only the entries from 309caf54c4fSMartin Matuska.Pa old.tgz 310caf54c4fSMartin Matuskacontaining the string 311caf54c4fSMartin Matuska.Sq foo . 312c5d360f8SMartin Matuska.It Fl J , Fl Fl xz 313c5d360f8SMartin Matuska(c mode only) 314c5d360f8SMartin MatuskaCompress the resulting archive with 315c5d360f8SMartin Matuska.Xr xz 1 . 316c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored. 3175c831a5bSMartin MatuskaNote that this 318c5d360f8SMartin Matuska.Nm tar 3195c831a5bSMartin Matuskaimplementation recognizes XZ compression automatically when reading archives. 320c5d360f8SMartin Matuska.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2 321caf54c4fSMartin Matuska(c mode only) 322caf54c4fSMartin MatuskaCompress the resulting archive with 323caf54c4fSMartin Matuska.Xr bzip2 1 . 324caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 3255c831a5bSMartin MatuskaNote that this 326caf54c4fSMartin Matuska.Nm tar 3275c831a5bSMartin Matuskaimplementation recognizes bzip2 compression automatically when reading 3285c831a5bSMartin Matuskaarchives. 329c5d360f8SMartin Matuska.It Fl k , Fl Fl keep-old-files 330caf54c4fSMartin Matuska(x mode only) 331caf54c4fSMartin MatuskaDo not overwrite existing files. 332caf54c4fSMartin MatuskaIn particular, if a file appears more than once in an archive, 333caf54c4fSMartin Matuskalater copies will not overwrite earlier copies. 334c5d360f8SMartin Matuska.It Fl Fl keep-newer-files 335caf54c4fSMartin Matuska(x mode only) 336caf54c4fSMartin MatuskaDo not overwrite existing files that are newer than the 337caf54c4fSMartin Matuskaversions appearing in the archive being extracted. 338c5d360f8SMartin Matuska.It Fl L , Fl Fl dereference 33964287048SMartin Matuska(c and r modes only) 340caf54c4fSMartin MatuskaAll symbolic links will be followed. 341caf54c4fSMartin MatuskaNormally, symbolic links are archived as such. 342caf54c4fSMartin MatuskaWith this option, the target of the link will be archived instead. 343c5d360f8SMartin Matuska.It Fl l , Fl Fl check-links 344c5d360f8SMartin Matuska(c and r modes only) 345c5d360f8SMartin MatuskaIssue a warning message unless all links to each file are archived. 346acc60b03SMartin Matuska.It Fl Fl lrzip 347acc60b03SMartin Matuska(c mode only) 348acc60b03SMartin MatuskaCompress the resulting archive with 349acc60b03SMartin Matuska.Xr lrzip 1 . 350acc60b03SMartin MatuskaIn extract or list modes, this option is ignored. 3515c831a5bSMartin MatuskaNote that this 3525c831a5bSMartin Matuska.Nm tar 3535c831a5bSMartin Matuskaimplementation recognizes lrzip compression automatically when reading 3545c831a5bSMartin Matuskaarchives. 355cdf63a70SMartin Matuska.It Fl Fl lz4 356cdf63a70SMartin Matuska(c mode only) 357cdf63a70SMartin MatuskaCompress the archive with lz4-compatible compression before writing it. 3585c831a5bSMartin MatuskaIn extract or list modes, this option is ignored. 3595c831a5bSMartin MatuskaNote that this 3605c831a5bSMartin Matuska.Nm tar 3615c831a5bSMartin Matuskaimplementation recognizes lz4 compression automatically when reading archives. 3625c831a5bSMartin Matuska.It Fl Fl zstd 3635c831a5bSMartin Matuska(c mode only) 3645c831a5bSMartin MatuskaCompress the archive with zstd-compatible compression before writing it. 3655c831a5bSMartin MatuskaIn extract or list modes, this option is ignored. 3665c831a5bSMartin MatuskaNote that this 3675c831a5bSMartin Matuska.Nm tar 3685c831a5bSMartin Matuskaimplementation recognizes zstd compression automatically when reading archives. 369c5d360f8SMartin Matuska.It Fl Fl lzma 370c5d360f8SMartin Matuska(c mode only) Compress the resulting archive with the original LZMA algorithm. 3715c831a5bSMartin MatuskaIn extract or list modes, this option is ignored. 372c5d360f8SMartin MatuskaUse of this option is discouraged and new archives should be created with 373c5d360f8SMartin Matuska.Fl Fl xz 374c5d360f8SMartin Matuskainstead. 3755c831a5bSMartin MatuskaNote that this 376c5d360f8SMartin Matuska.Nm tar 3775c831a5bSMartin Matuskaimplementation recognizes LZMA compression automatically when reading archives. 378acc60b03SMartin Matuska.It Fl Fl lzop 379acc60b03SMartin Matuska(c mode only) 380acc60b03SMartin MatuskaCompress the resulting archive with 381acc60b03SMartin Matuska.Xr lzop 1 . 382acc60b03SMartin MatuskaIn extract or list modes, this option is ignored. 3835c831a5bSMartin MatuskaNote that this 3845c831a5bSMartin Matuska.Nm tar 3855c831a5bSMartin Matuskaimplementation recognizes LZO compression automatically when reading archives. 386c5d360f8SMartin Matuska.It Fl m , Fl Fl modification-time 387caf54c4fSMartin Matuska(x mode only) 388caf54c4fSMartin MatuskaDo not extract modification time. 389caf54c4fSMartin MatuskaBy default, the modification time is set to the time stored in the archive. 39064287048SMartin Matuska.It Fl Fl mac-metadata 39164287048SMartin Matuska(c, r, u and x mode only) 39264287048SMartin MatuskaMac OS X specific. Archive or extract extended ACLs and extended attributes 39364287048SMartin Matuskausing 39464287048SMartin Matuska.Xr copyfile 3 39564287048SMartin Matuskain AppleDouble format. This is the reverse of 39664287048SMartin Matuska.Fl Fl no-mac-metadata . 39764287048SMartin Matuskaand the default behavior in c, r, and u modes or if 39864287048SMartin Matuska.Nm 39964287048SMartin Matuskais run in x mode as root. 400c5d360f8SMartin Matuska.It Fl n , Fl Fl norecurse , Fl Fl no-recursion 401*52c2bb75SMartin MatuskaDo not operate recursively on the content of directories. 402c5d360f8SMartin Matuska.It Fl Fl newer Ar date 403caf54c4fSMartin Matuska(c, r, u modes only) 404caf54c4fSMartin MatuskaOnly include files and directories newer than the specified date. 405caf54c4fSMartin MatuskaThis compares ctime entries. 406c5d360f8SMartin Matuska.It Fl Fl newer-mtime Ar date 407caf54c4fSMartin Matuska(c, r, u modes only) 408caf54c4fSMartin MatuskaLike 409c5d360f8SMartin Matuska.Fl Fl newer , 410caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries. 411c5d360f8SMartin Matuska.It Fl Fl newer-than Pa file 412caf54c4fSMartin Matuska(c, r, u modes only) 413caf54c4fSMartin MatuskaOnly include files and directories newer than the specified file. 414caf54c4fSMartin MatuskaThis compares ctime entries. 415c5d360f8SMartin Matuska.It Fl Fl newer-mtime-than Pa file 416caf54c4fSMartin Matuska(c, r, u modes only) 417caf54c4fSMartin MatuskaLike 418c5d360f8SMartin Matuska.Fl Fl newer-than , 419caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries. 420c5d360f8SMartin Matuska.It Fl Fl nodump 421caf54c4fSMartin Matuska(c and r modes only) 422caf54c4fSMartin MatuskaHonor the nodump file flag by skipping this file. 423acc60b03SMartin Matuska.It Fl Fl nopreserveHFSCompression 424acc60b03SMartin Matuska(x mode only) 425acc60b03SMartin MatuskaMac OS X specific (v10.6 or later). Do not compress extracted regular files 426acc60b03SMartin Matuskawhich were compressed with HFS+ compression before archived. 427acc60b03SMartin MatuskaBy default, compress the regular files again with HFS+ compression. 428c5d360f8SMartin Matuska.It Fl Fl null 429caf54c4fSMartin Matuska(use with 430c5d360f8SMartin Matuska.Fl I 431caf54c4fSMartin Matuskaor 432c5d360f8SMartin Matuska.Fl T ) 433caf54c4fSMartin MatuskaFilenames or patterns are separated by null characters, 434caf54c4fSMartin Matuskanot by newlines. 435caf54c4fSMartin MatuskaThis is often used to read filenames output by the 436caf54c4fSMartin Matuska.Fl print0 437caf54c4fSMartin Matuskaoption to 438caf54c4fSMartin Matuska.Xr find 1 . 43964287048SMartin Matuska.It Fl Fl no-acls 44064287048SMartin Matuska(c, r, u, x modes only) 44164287048SMartin MatuskaDo not archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of 44264287048SMartin Matuska.Fl Fl acls 44364287048SMartin Matuskaand the default behavior if 44464287048SMartin Matuska.Nm 445e46d4714SMartin Matuskais run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes). 44664287048SMartin Matuska.It Fl Fl no-fflags 44764287048SMartin Matuska(c, r, u, x modes only) 44864287048SMartin MatuskaDo not archive or extract file flags. This is the reverse of 44964287048SMartin Matuska.Fl Fl fflags 45064287048SMartin Matuskaand the default behavior if 45164287048SMartin Matuska.Nm 45264287048SMartin Matuskais run as non-root in x mode. 45364287048SMartin Matuska.It Fl Fl no-mac-metadata 45464287048SMartin Matuska(x mode only) 45564287048SMartin MatuskaMac OS X specific. Do not archive or extract ACLs and extended attributes using 45664287048SMartin Matuska.Xr copyfile 3 45764287048SMartin Matuskain AppleDouble format. This is the reverse of 45864287048SMartin Matuska.Fl Fl mac-metadata . 45964287048SMartin Matuskaand the default behavior if 46064287048SMartin Matuska.Nm 46164287048SMartin Matuskais run as non-root in x mode. 46264287048SMartin Matuska.It Fl n , Fl Fl norecurse , Fl Fl no-recursion 463caf54c4fSMartin Matuska.It Fl Fl no-same-owner 464caf54c4fSMartin Matuska(x mode only) 465caf54c4fSMartin MatuskaDo not extract owner and group IDs. 466caf54c4fSMartin MatuskaThis is the reverse of 467caf54c4fSMartin Matuska.Fl Fl same-owner 468caf54c4fSMartin Matuskaand the default behavior if 469caf54c4fSMartin Matuska.Nm 470caf54c4fSMartin Matuskais run as non-root. 471caf54c4fSMartin Matuska.It Fl Fl no-same-permissions 472caf54c4fSMartin Matuska(x mode only) 473caf54c4fSMartin MatuskaDo not extract full permissions (SGID, SUID, sticky bit, ACLs, 474caf54c4fSMartin Matuskaextended attributes or extended file flags). 475caf54c4fSMartin MatuskaThis is the reverse of 476caf54c4fSMartin Matuska.Fl p 477caf54c4fSMartin Matuskaand the default behavior if 478caf54c4fSMartin Matuska.Nm 479caf54c4fSMartin Matuskais run as non-root. 48064287048SMartin Matuska.It Fl Fl no-xattrs 48164287048SMartin Matuska(c, r, u, x modes only) 48264287048SMartin MatuskaDo not archive or extract extended attributes. This is the reverse of 48364287048SMartin Matuska.Fl Fl xattrs 48464287048SMartin Matuskaand the default behavior if 48564287048SMartin Matuska.Nm 48664287048SMartin Matuskais run as non-root in x mode. 487caf54c4fSMartin Matuska.It Fl Fl numeric-owner 488caf54c4fSMartin MatuskaThis is equivalent to 489caf54c4fSMartin Matuska.Fl Fl uname 490caf54c4fSMartin Matuska.Qq 491caf54c4fSMartin Matuska.Fl Fl gname 492caf54c4fSMartin Matuska.Qq . 493caf54c4fSMartin MatuskaOn extract, it causes user and group names in the archive 494caf54c4fSMartin Matuskato be ignored in favor of the numeric user and group ids. 495caf54c4fSMartin MatuskaOn create, it causes user and group names to not be stored 496caf54c4fSMartin Matuskain the archive. 497c5d360f8SMartin Matuska.It Fl O , Fl Fl to-stdout 498caf54c4fSMartin Matuska(x, t modes only) 499caf54c4fSMartin MatuskaIn extract (-x) mode, files will be written to standard out rather than 500caf54c4fSMartin Matuskabeing extracted to disk. 501caf54c4fSMartin MatuskaIn list (-t) mode, the file listing will be written to stderr rather than 502caf54c4fSMartin Matuskathe usual stdout. 503caf54c4fSMartin Matuska.It Fl o 504caf54c4fSMartin Matuska(x mode) 505caf54c4fSMartin MatuskaUse the user and group of the user running the program rather 506caf54c4fSMartin Matuskathan those specified in the archive. 507caf54c4fSMartin MatuskaNote that this has no significance unless 508caf54c4fSMartin Matuska.Fl p 509caf54c4fSMartin Matuskais specified, and the program is being run by the root user. 510caf54c4fSMartin MatuskaIn this case, the file modes and flags from 511caf54c4fSMartin Matuskathe archive will be restored, but ACLs or owner information in 512caf54c4fSMartin Matuskathe archive will be discarded. 513caf54c4fSMartin Matuska.It Fl o 514caf54c4fSMartin Matuska(c, r, u mode) 515caf54c4fSMartin MatuskaA synonym for 516c5d360f8SMartin Matuska.Fl Fl format Ar ustar 517acc60b03SMartin Matuska.It Fl Fl older Ar date 518acc60b03SMartin Matuska(c, r, u modes only) 519acc60b03SMartin MatuskaOnly include files and directories older than the specified date. 520acc60b03SMartin MatuskaThis compares ctime entries. 521acc60b03SMartin Matuska.It Fl Fl older-mtime Ar date 522acc60b03SMartin Matuska(c, r, u modes only) 523acc60b03SMartin MatuskaLike 524acc60b03SMartin Matuska.Fl Fl older , 525acc60b03SMartin Matuskaexcept it compares mtime entries instead of ctime entries. 526acc60b03SMartin Matuska.It Fl Fl older-than Pa file 527acc60b03SMartin Matuska(c, r, u modes only) 528acc60b03SMartin MatuskaOnly include files and directories older than the specified file. 529acc60b03SMartin MatuskaThis compares ctime entries. 530acc60b03SMartin Matuska.It Fl Fl older-mtime-than Pa file 531acc60b03SMartin Matuska(c, r, u modes only) 532acc60b03SMartin MatuskaLike 533acc60b03SMartin Matuska.Fl Fl older-than , 534acc60b03SMartin Matuskaexcept it compares mtime entries instead of ctime entries. 535c5d360f8SMartin Matuska.It Fl Fl one-file-system 536caf54c4fSMartin Matuska(c, r, and u modes) 537caf54c4fSMartin MatuskaDo not cross mount points. 538c5d360f8SMartin Matuska.It Fl Fl options Ar options 539caf54c4fSMartin MatuskaSelect optional behaviors for particular modules. 540caf54c4fSMartin MatuskaThe argument is a text string containing comma-separated 541caf54c4fSMartin Matuskakeywords and values. 542caf54c4fSMartin MatuskaThese are passed to the modules that handle particular 543caf54c4fSMartin Matuskaformats to control how those formats will behave. 544caf54c4fSMartin MatuskaEach option has one of the following forms: 545caf54c4fSMartin Matuska.Bl -tag -compact -width indent 546caf54c4fSMartin Matuska.It Ar key=value 547caf54c4fSMartin MatuskaThe key will be set to the specified value in every module that supports it. 548caf54c4fSMartin MatuskaModules that do not support this key will ignore it. 549caf54c4fSMartin Matuska.It Ar key 550caf54c4fSMartin MatuskaThe key will be enabled in every module that supports it. 551caf54c4fSMartin MatuskaThis is equivalent to 552caf54c4fSMartin Matuska.Ar key Ns Cm =1 . 553caf54c4fSMartin Matuska.It Ar !key 554caf54c4fSMartin MatuskaThe key will be disabled in every module that supports it. 555caf54c4fSMartin Matuska.It Ar module:key=value , Ar module:key , Ar module:!key 556caf54c4fSMartin MatuskaAs above, but the corresponding key and value will be provided 557caf54c4fSMartin Matuskaonly to modules whose name matches 558caf54c4fSMartin Matuska.Ar module . 559caf54c4fSMartin Matuska.El 560caf54c4fSMartin MatuskaThe currently supported modules and keys are: 561caf54c4fSMartin Matuska.Bl -tag -compact -width indent 562caf54c4fSMartin Matuska.It Cm iso9660:joliet 563caf54c4fSMartin MatuskaSupport Joliet extensions. 564caf54c4fSMartin MatuskaThis is enabled by default, use 565caf54c4fSMartin Matuska.Cm !joliet 566caf54c4fSMartin Matuskaor 567caf54c4fSMartin Matuska.Cm iso9660:!joliet 568caf54c4fSMartin Matuskato disable. 569caf54c4fSMartin Matuska.It Cm iso9660:rockridge 570caf54c4fSMartin MatuskaSupport Rock Ridge extensions. 571caf54c4fSMartin MatuskaThis is enabled by default, use 572caf54c4fSMartin Matuska.Cm !rockridge 573caf54c4fSMartin Matuskaor 574caf54c4fSMartin Matuska.Cm iso9660:!rockridge 575caf54c4fSMartin Matuskato disable. 576caf54c4fSMartin Matuska.It Cm gzip:compression-level 577acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the gzip compression level. 578acc60b03SMartin Matuska.It Cm gzip:timestamp 579acc60b03SMartin MatuskaStore timestamp. This is enabled by default, use 580acc60b03SMartin Matuska.Cm !timestamp 581acc60b03SMartin Matuskaor 582acc60b03SMartin Matuska.Cm gzip:!timestamp 583acc60b03SMartin Matuskato disable. 584acc60b03SMartin Matuska.It Cm lrzip:compression Ns = Ns Ar type 585acc60b03SMartin MatuskaUse 586acc60b03SMartin Matuska.Ar type 587acc60b03SMartin Matuskaas compression method. 588acc60b03SMartin MatuskaSupported values are bzip2, gzip, lzo (ultra fast), 589acc60b03SMartin Matuskaand zpaq (best, extremely slow). 590acc60b03SMartin Matuska.It Cm lrzip:compression-level 591acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the lrzip compression level. 592cdf63a70SMartin Matuska.It Cm lz4:compression-level 593cdf63a70SMartin MatuskaA decimal integer from 1 to 9 specifying the lzop compression level. 594cdf63a70SMartin Matuska.It Cm lz4:stream-checksum 595cdf63a70SMartin MatuskaEnable stream checksum. This is by default, use 596cdf63a70SMartin Matuska.Cm lz4:!stream-checksum 597cdf63a70SMartin Matuskato disable. 598cdf63a70SMartin Matuska.It Cm lz4:block-checksum 599cdf63a70SMartin MatuskaEnable block checksum (Disabled by default). 600cdf63a70SMartin Matuska.It Cm lz4:block-size 601cdf63a70SMartin MatuskaA decimal integer from 4 to 7 specifying the lz4 compression block size 602cdf63a70SMartin Matuska(7 is set by default). 603cdf63a70SMartin Matuska.It Cm lz4:block-dependence 604cdf63a70SMartin MatuskaUse the previous block of the block being compressed for 605cdf63a70SMartin Matuskaa compression dictionary to improve compression ratio. 6065c831a5bSMartin Matuska.It Cm zstd:compression-level 6075c831a5bSMartin MatuskaA decimal integer from 1 to 22 specifying the zstd compression level. 608acc60b03SMartin Matuska.It Cm lzop:compression-level 609acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the lzop compression level. 610caf54c4fSMartin Matuska.It Cm xz:compression-level 611caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the xz compression level. 612caf54c4fSMartin Matuska.It Cm mtree: Ns Ar keyword 613caf54c4fSMartin MatuskaThe mtree writer module allows you to specify which mtree keywords 614caf54c4fSMartin Matuskawill be included in the output. 615caf54c4fSMartin MatuskaSupported keywords include: 616caf54c4fSMartin Matuska.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , 617caf54c4fSMartin Matuska.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , 618caf54c4fSMartin Matuska.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname . 619caf54c4fSMartin MatuskaThe default is equivalent to: 620caf54c4fSMartin Matuska.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname . 621caf54c4fSMartin Matuska.It Cm mtree:all 622caf54c4fSMartin MatuskaEnables all of the above keywords. 623caf54c4fSMartin MatuskaYou can also use 624caf54c4fSMartin Matuska.Cm mtree:!all 625caf54c4fSMartin Matuskato disable all keywords. 626caf54c4fSMartin Matuska.It Cm mtree:use-set 627caf54c4fSMartin MatuskaEnable generation of 628caf54c4fSMartin Matuska.Cm /set 629caf54c4fSMartin Matuskalines in the output. 630caf54c4fSMartin Matuska.It Cm mtree:indent 631caf54c4fSMartin MatuskaProduce human-readable output by indenting options and splitting lines 632caf54c4fSMartin Matuskato fit into 80 columns. 633caf54c4fSMartin Matuska.It Cm zip:compression Ns = Ns Ar type 634caf54c4fSMartin MatuskaUse 635caf54c4fSMartin Matuska.Ar type 636caf54c4fSMartin Matuskaas compression method. 637caf54c4fSMartin MatuskaSupported values are store (uncompressed) and deflate (gzip algorithm). 638cdf63a70SMartin Matuska.It Cm zip:encryption 639cdf63a70SMartin MatuskaEnable encryption using traditional zip encryption. 640cdf63a70SMartin Matuska.It Cm zip:encryption Ns = Ns Ar type 641cdf63a70SMartin MatuskaUse 642cdf63a70SMartin Matuska.Ar type 643cdf63a70SMartin Matuskaas encryption type. 644cdf63a70SMartin MatuskaSupported values are zipcrypt (traditional zip encryption), 645cdf63a70SMartin Matuskaaes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption). 646cdf63a70SMartin Matuska.It Cm read_concatenated_archives 647cdf63a70SMartin MatuskaIgnore zeroed blocks in the archive, which occurs when multiple tar archives 648cdf63a70SMartin Matuskahave been concatenated together. Without this option, only the contents of 649cdf63a70SMartin Matuskathe first concatenated archive would be read. This option is comparable to 650cdf63a70SMartin Matuskathe 651cdf63a70SMartin Matuska.Fl i , Fl Fl ignore-zeros 652cdf63a70SMartin Matuskaoption of GNU tar. 653caf54c4fSMartin Matuska.El 654caf54c4fSMartin MatuskaIf a provided option is not supported by any module, that 655caf54c4fSMartin Matuskais a fatal error. 656c5d360f8SMartin Matuska.It Fl P , Fl Fl absolute-paths 657caf54c4fSMartin MatuskaPreserve pathnames. 658caf54c4fSMartin MatuskaBy default, absolute pathnames (those that begin with a / 659caf54c4fSMartin Matuskacharacter) have the leading slash removed both when creating archives 660caf54c4fSMartin Matuskaand extracting from them. 661caf54c4fSMartin MatuskaAlso, 662caf54c4fSMartin Matuska.Nm 663caf54c4fSMartin Matuskawill refuse to extract archive entries whose pathnames contain 664caf54c4fSMartin Matuska.Pa .. 665caf54c4fSMartin Matuskaor whose target directory would be altered by a symlink. 666caf54c4fSMartin MatuskaThis option suppresses these behaviors. 667c5d360f8SMartin Matuska.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions 668caf54c4fSMartin Matuska(x mode only) 669caf54c4fSMartin MatuskaPreserve file permissions. 67064287048SMartin MatuskaAttempt to restore the full permissions, including owner, file modes, ACLs, 6714657548dSMartin Matuskaextended attributes and extended file flags, if available, for each item 67264287048SMartin Matuskaextracted from the archive. This is te reverse of 67364287048SMartin Matuska.Fl Fl no-same-permissions 67464287048SMartin Matuskaand the default if 675caf54c4fSMartin Matuska.Nm 67664287048SMartin Matuskais being run by root and can be partially overridden by also specifying 67764287048SMartin Matuska.Fl Fl no-acls , 67864287048SMartin Matuska.Fl Fl no-fflags , 67964287048SMartin Matuska.Fl Fl no-mac-metadata 68064287048SMartin Matuskaor 68164287048SMartin Matuska.Fl Fl no-xattrs . 682cdf63a70SMartin Matuska.It Fl Fl passphrase Ar passphrase 683cdf63a70SMartin MatuskaThe 684cdf63a70SMartin Matuska.Pa passphrase 685cdf63a70SMartin Matuskais used to extract or create an encrypted archive. 686cdf63a70SMartin MatuskaCurrently, zip is the only supported format that supports encryption. 687cdf63a70SMartin MatuskaYou shouldn't use this option unless you realize how insecure 688cdf63a70SMartin Matuskause of this option is. 689c5d360f8SMartin Matuska.It Fl Fl posix 690c5d360f8SMartin Matuska(c, r, u mode only) 691c5d360f8SMartin MatuskaSynonym for 692c5d360f8SMartin Matuska.Fl Fl format Ar pax 693c5d360f8SMartin Matuska.It Fl q , Fl Fl fast-read 694caf54c4fSMartin Matuska(x and t mode only) 695caf54c4fSMartin MatuskaExtract or list only the first archive entry that matches each pattern 696caf54c4fSMartin Matuskaor filename operand. 697caf54c4fSMartin MatuskaExit as soon as each specified pattern or filename has been matched. 698caf54c4fSMartin MatuskaBy default, the archive is always read to the very end, since 699caf54c4fSMartin Matuskathere can be multiple entries with the same name and, by convention, 700caf54c4fSMartin Matuskalater entries overwrite earlier entries. 701caf54c4fSMartin MatuskaThis option is provided as a performance optimization. 702caf54c4fSMartin Matuska.It Fl S 703caf54c4fSMartin Matuska(x mode only) 704caf54c4fSMartin MatuskaExtract files as sparse files. 705caf54c4fSMartin MatuskaFor every block on disk, check first if it contains only NULL bytes and seek 706caf54c4fSMartin Matuskaover it otherwise. 707c5d360f8SMartin MatuskaThis works similar to the conv=sparse option of dd. 708caf54c4fSMartin Matuska.It Fl s Ar pattern 709caf54c4fSMartin MatuskaModify file or archive member names according to 710caf54c4fSMartin Matuska.Pa pattern . 711caf54c4fSMartin MatuskaThe pattern has the format 7126c95142eSMartin Matuska.Ar /old/new/ Ns Op ghHprRsS 713caf54c4fSMartin Matuskawhere 714caf54c4fSMartin Matuska.Ar old 715caf54c4fSMartin Matuskais a basic regular expression, 716caf54c4fSMartin Matuska.Ar new 717caf54c4fSMartin Matuskais the replacement string of the matched part, 718caf54c4fSMartin Matuskaand the optional trailing letters modify 719caf54c4fSMartin Matuskahow the replacement is handled. 720caf54c4fSMartin MatuskaIf 721caf54c4fSMartin Matuska.Ar old 722caf54c4fSMartin Matuskais not matched, the pattern is skipped. 723caf54c4fSMartin MatuskaWithin 724caf54c4fSMartin Matuska.Ar new , 725caf54c4fSMartin Matuska~ is substituted with the match, \e1 to \e9 with the content of 726caf54c4fSMartin Matuskathe corresponding captured group. 727caf54c4fSMartin MatuskaThe optional trailing g specifies that matching should continue 7286c95142eSMartin Matuskaafter the matched part and stop on the first unmatched pattern. 729caf54c4fSMartin MatuskaThe optional trailing s specifies that the pattern applies to the value 730caf54c4fSMartin Matuskaof symbolic links. 731caf54c4fSMartin MatuskaThe optional trailing p specifies that after a successful substitution 732caf54c4fSMartin Matuskathe original path name and the new path name should be printed to 733caf54c4fSMartin Matuskastandard error. 7346c95142eSMartin MatuskaOptional trailing H, R, or S characters suppress substitutions 7356c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets, 7366c95142eSMartin Matuskarespectively. 7376c95142eSMartin MatuskaOptional trailing h, r, or s characters enable substitutions 7386c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets, 7396c95142eSMartin Matuskarespectively. 7406c95142eSMartin MatuskaThe default is 7416c95142eSMartin Matuska.Ar hrs 7426c95142eSMartin Matuskawhich applies substitutions to all names. 7436c95142eSMartin MatuskaIn particular, it is never necessary to specify h, r, or s. 7446c95142eSMartin Matuska.It Fl Fl same-owner 7456c95142eSMartin Matuska(x mode only) 7466c95142eSMartin MatuskaExtract owner and group IDs. 7476c95142eSMartin MatuskaThis is the reverse of 7486c95142eSMartin Matuska.Fl Fl no-same-owner 7496c95142eSMartin Matuskaand the default behavior if 7506c95142eSMartin Matuska.Nm 7516c95142eSMartin Matuskais run as root. 7526c95142eSMartin Matuska.It Fl Fl strip-components Ar count 7536c95142eSMartin MatuskaRemove the specified number of leading path elements. 7546c95142eSMartin MatuskaPathnames with fewer elements will be silently skipped. 7556c95142eSMartin MatuskaNote that the pathname is edited after checking inclusion/exclusion patterns 7566c95142eSMartin Matuskabut before security checks. 757c5d360f8SMartin Matuska.It Fl T Ar filename , Fl Fl files-from Ar filename 758caf54c4fSMartin MatuskaIn x or t mode, 759caf54c4fSMartin Matuska.Nm 760caf54c4fSMartin Matuskawill read the list of names to be extracted from 761caf54c4fSMartin Matuska.Pa filename . 762caf54c4fSMartin MatuskaIn c mode, 763caf54c4fSMartin Matuska.Nm 764caf54c4fSMartin Matuskawill read names to be archived from 765caf54c4fSMartin Matuska.Pa filename . 766caf54c4fSMartin MatuskaThe special name 767caf54c4fSMartin Matuska.Dq -C 768caf54c4fSMartin Matuskaon a line by itself will cause the current directory to be changed to 769caf54c4fSMartin Matuskathe directory specified on the following line. 770caf54c4fSMartin MatuskaNames are terminated by newlines unless 771c5d360f8SMartin Matuska.Fl Fl null 772caf54c4fSMartin Matuskais specified. 773caf54c4fSMartin MatuskaNote that 774c5d360f8SMartin Matuska.Fl Fl null 775caf54c4fSMartin Matuskaalso disables the special handling of lines containing 776caf54c4fSMartin Matuska.Dq -C . 777acc60b03SMartin MatuskaNote: If you are generating lists of files using 778acc60b03SMartin Matuska.Xr find 1 , 779acc60b03SMartin Matuskayou probably want to use 780acc60b03SMartin Matuska.Fl n 781acc60b03SMartin Matuskaas well. 782c5d360f8SMartin Matuska.It Fl Fl totals 78364287048SMartin Matuska(c, r, u modes only) 784c5d360f8SMartin MatuskaAfter archiving all files, print a summary to stderr. 785c5d360f8SMartin Matuska.It Fl U , Fl Fl unlink , Fl Fl unlink-first 786caf54c4fSMartin Matuska(x mode only) 787caf54c4fSMartin MatuskaUnlink files before creating them. 788c5d360f8SMartin MatuskaThis can be a minor performance optimization if most files 789c5d360f8SMartin Matuskaalready exist, but can make things slower if most files 790c5d360f8SMartin Matuskado not already exist. 791c5d360f8SMartin MatuskaThis flag also causes 792caf54c4fSMartin Matuska.Nm 793c5d360f8SMartin Matuskato remove intervening directory symlinks instead of 794c5d360f8SMartin Matuskareporting an error. 795c5d360f8SMartin MatuskaSee the SECURITY section below for more details. 796caf54c4fSMartin Matuska.It Fl Fl uid Ar id 797caf54c4fSMartin MatuskaUse the provided user id number and ignore the user 798caf54c4fSMartin Matuskaname from the archive. 799caf54c4fSMartin MatuskaOn create, if 800caf54c4fSMartin Matuska.Fl Fl uname 801caf54c4fSMartin Matuskais not also specified, the user name will be set to 802caf54c4fSMartin Matuskamatch the user id. 803caf54c4fSMartin Matuska.It Fl Fl uname Ar name 804caf54c4fSMartin MatuskaUse the provided user name. 805caf54c4fSMartin MatuskaOn extract, this overrides the user name in the archive; 806caf54c4fSMartin Matuskaif the provided user name does not exist on the system, 807caf54c4fSMartin Matuskait will be ignored and the user id 808caf54c4fSMartin Matuska(from the archive or from the 809caf54c4fSMartin Matuska.Fl Fl uid 810caf54c4fSMartin Matuskaoption) 811caf54c4fSMartin Matuskawill be used instead. 812caf54c4fSMartin MatuskaOn create, this sets the user name that will be stored 813caf54c4fSMartin Matuskain the archive; 814caf54c4fSMartin Matuskathe name is not verified against the system user database. 815caf54c4fSMartin Matuska.It Fl Fl use-compress-program Ar program 816caf54c4fSMartin MatuskaPipe the input (in x or t mode) or the output (in c mode) through 817caf54c4fSMartin Matuska.Pa program 818caf54c4fSMartin Matuskainstead of using the builtin compression support. 819c5d360f8SMartin Matuska.It Fl v , Fl Fl verbose 820caf54c4fSMartin MatuskaProduce verbose output. 821caf54c4fSMartin MatuskaIn create and extract modes, 822caf54c4fSMartin Matuska.Nm 823caf54c4fSMartin Matuskawill list each file name as it is read from or written to 824caf54c4fSMartin Matuskathe archive. 825caf54c4fSMartin MatuskaIn list mode, 826caf54c4fSMartin Matuska.Nm 827caf54c4fSMartin Matuskawill produce output similar to that of 828caf54c4fSMartin Matuska.Xr ls 1 . 829cdf63a70SMartin MatuskaAn additional 830caf54c4fSMartin Matuska.Fl v 831cdf63a70SMartin Matuskaoption will also provide ls-like details in create and extract mode. 832c5d360f8SMartin Matuska.It Fl Fl version 833caf54c4fSMartin MatuskaPrint version of 834caf54c4fSMartin Matuska.Nm 835caf54c4fSMartin Matuskaand 836caf54c4fSMartin Matuska.Nm libarchive , 837caf54c4fSMartin Matuskaand exit. 838c5d360f8SMartin Matuska.It Fl w , Fl Fl confirmation , Fl Fl interactive 839caf54c4fSMartin MatuskaAsk for confirmation for every action. 840c5d360f8SMartin Matuska.It Fl X Ar filename , Fl Fl exclude-from Ar filename 841caf54c4fSMartin MatuskaRead a list of exclusion patterns from the specified file. 842caf54c4fSMartin MatuskaSee 843c5d360f8SMartin Matuska.Fl Fl exclude 844caf54c4fSMartin Matuskafor more information about the handling of exclusions. 84564287048SMartin Matuska.It Fl Fl xattrs 84664287048SMartin Matuska(c, r, u, x modes only) 84764287048SMartin MatuskaArchive or extract extended attributes. This is the reverse of 84864287048SMartin Matuska.Fl Fl no-xattrs 84964287048SMartin Matuskaand the default behavior in c, r, and u modes or if 85064287048SMartin Matuska.Nm 85164287048SMartin Matuskais run in x mode as root. 852caf54c4fSMartin Matuska.It Fl y 853caf54c4fSMartin Matuska(c mode only) 854caf54c4fSMartin MatuskaCompress the resulting archive with 855caf54c4fSMartin Matuska.Xr bzip2 1 . 856caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 8575c831a5bSMartin MatuskaNote that this 858caf54c4fSMartin Matuska.Nm tar 8595c831a5bSMartin Matuskaimplementation recognizes bzip2 compression automatically when reading 8605c831a5bSMartin Matuskaarchives. 861c5d360f8SMartin Matuska.It Fl Z , Fl Fl compress , Fl Fl uncompress 862caf54c4fSMartin Matuska(c mode only) 863caf54c4fSMartin MatuskaCompress the resulting archive with 864caf54c4fSMartin Matuska.Xr compress 1 . 865caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 8665c831a5bSMartin MatuskaNote that this 867caf54c4fSMartin Matuska.Nm tar 8685c831a5bSMartin Matuskaimplementation recognizes compress compression automatically when reading 8695c831a5bSMartin Matuskaarchives. 870c5d360f8SMartin Matuska.It Fl z , Fl Fl gunzip , Fl Fl gzip 871c5d360f8SMartin Matuska(c mode only) 872c5d360f8SMartin MatuskaCompress the resulting archive with 873c5d360f8SMartin Matuska.Xr gzip 1 . 874c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored. 8755c831a5bSMartin MatuskaNote that this 876c5d360f8SMartin Matuska.Nm tar 8775c831a5bSMartin Matuskaimplementation recognizes gzip compression automatically when reading 8785c831a5bSMartin Matuskaarchives. 879caf54c4fSMartin Matuska.El 880caf54c4fSMartin Matuska.Sh ENVIRONMENT 881caf54c4fSMartin MatuskaThe following environment variables affect the execution of 882caf54c4fSMartin Matuska.Nm : 883caf54c4fSMartin Matuska.Bl -tag -width ".Ev BLOCKSIZE" 884acc60b03SMartin Matuska.It Ev TAR_READER_OPTIONS 885acc60b03SMartin MatuskaThe default options for format readers and compression readers. 886acc60b03SMartin MatuskaThe 887acc60b03SMartin Matuska.Fl Fl options 888acc60b03SMartin Matuskaoption overrides this. 889acc60b03SMartin Matuska.It Ev TAR_WRITER_OPTIONS 890acc60b03SMartin MatuskaThe default options for format writers and compression writers. 891acc60b03SMartin MatuskaThe 892acc60b03SMartin Matuska.Fl Fl options 893acc60b03SMartin Matuskaoption overrides this. 894caf54c4fSMartin Matuska.It Ev LANG 895caf54c4fSMartin MatuskaThe locale to use. 896caf54c4fSMartin MatuskaSee 897caf54c4fSMartin Matuska.Xr environ 7 898caf54c4fSMartin Matuskafor more information. 899caf54c4fSMartin Matuska.It Ev TAPE 900c5d360f8SMartin MatuskaThe default device. 901caf54c4fSMartin MatuskaThe 902caf54c4fSMartin Matuska.Fl f 903caf54c4fSMartin Matuskaoption overrides this. 904c5d360f8SMartin MatuskaPlease see the description of the 905c5d360f8SMartin Matuska.Fl f 906c5d360f8SMartin Matuskaoption above for more details. 907caf54c4fSMartin Matuska.It Ev TZ 908caf54c4fSMartin MatuskaThe timezone to use when displaying dates. 909caf54c4fSMartin MatuskaSee 910caf54c4fSMartin Matuska.Xr environ 7 911caf54c4fSMartin Matuskafor more information. 912caf54c4fSMartin Matuska.El 913c5d360f8SMartin Matuska.Sh EXIT STATUS 914c5d360f8SMartin Matuska.Ex -std 915caf54c4fSMartin Matuska.Sh EXAMPLES 916caf54c4fSMartin MatuskaThe following creates a new archive 917caf54c4fSMartin Matuskacalled 918caf54c4fSMartin Matuska.Ar file.tar.gz 919caf54c4fSMartin Matuskathat contains two files 920caf54c4fSMartin Matuska.Ar source.c 921caf54c4fSMartin Matuskaand 922caf54c4fSMartin Matuska.Ar source.h : 923caf54c4fSMartin Matuska.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h 924caf54c4fSMartin Matuska.Pp 925caf54c4fSMartin MatuskaTo view a detailed table of contents for this 926caf54c4fSMartin Matuskaarchive: 927caf54c4fSMartin Matuska.Dl Nm Fl tvf Pa file.tar.gz 928caf54c4fSMartin Matuska.Pp 929caf54c4fSMartin MatuskaTo extract all entries from the archive on 930caf54c4fSMartin Matuskathe default tape drive: 931caf54c4fSMartin Matuska.Dl Nm Fl x 932caf54c4fSMartin Matuska.Pp 933caf54c4fSMartin MatuskaTo examine the contents of an ISO 9660 cdrom image: 934caf54c4fSMartin Matuska.Dl Nm Fl tf Pa image.iso 935caf54c4fSMartin Matuska.Pp 936caf54c4fSMartin MatuskaTo move file hierarchies, invoke 937caf54c4fSMartin Matuska.Nm 938caf54c4fSMartin Matuskaas 939caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir 940caf54c4fSMartin Matuskaor more traditionally 941caf54c4fSMartin Matuska.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - ) 942caf54c4fSMartin Matuska.Pp 943caf54c4fSMartin MatuskaIn create mode, the list of files and directories to be archived 944caf54c4fSMartin Matuskacan also include directory change instructions of the form 945caf54c4fSMartin Matuska.Cm -C Ns Pa foo/baz 946caf54c4fSMartin Matuskaand archive inclusions of the form 947caf54c4fSMartin Matuska.Cm @ Ns Pa archive-file . 948caf54c4fSMartin MatuskaFor example, the command line 949caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2 950caf54c4fSMartin Matuskawill create a new archive 951caf54c4fSMartin Matuska.Pa new.tar . 952caf54c4fSMartin Matuska.Nm 953caf54c4fSMartin Matuskawill read the file 954caf54c4fSMartin Matuska.Pa foo1 955caf54c4fSMartin Matuskafrom the current directory and add it to the output archive. 956caf54c4fSMartin MatuskaIt will then read each entry from 957caf54c4fSMartin Matuska.Pa old.tgz 958caf54c4fSMartin Matuskaand add those entries to the output archive. 959caf54c4fSMartin MatuskaFinally, it will switch to the 960caf54c4fSMartin Matuska.Pa /tmp 961caf54c4fSMartin Matuskadirectory and add 962caf54c4fSMartin Matuska.Pa foo2 963caf54c4fSMartin Matuskato the output archive. 964caf54c4fSMartin Matuska.Pp 965caf54c4fSMartin MatuskaAn input file in 966caf54c4fSMartin Matuska.Xr mtree 5 967caf54c4fSMartin Matuskaformat can be used to create an output archive with arbitrary ownership, 968caf54c4fSMartin Matuskapermissions, or names that differ from existing data on disk: 969caf54c4fSMartin Matuska.Pp 970cdf63a70SMartin Matuska.Bd -literal -offset indent 971cdf63a70SMartin Matuska$ cat input.mtree 972cdf63a70SMartin Matuska#mtree 973cdf63a70SMartin Matuskausr/bin uid=0 gid=0 mode=0755 type=dir 974cdf63a70SMartin Matuskausr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls 975cdf63a70SMartin Matuska$ tar -cvf output.tar @input.mtree 976cdf63a70SMartin Matuska.Ed 977caf54c4fSMartin Matuska.Pp 978caf54c4fSMartin MatuskaThe 979c5d360f8SMartin Matuska.Fl Fl newer 980caf54c4fSMartin Matuskaand 981c5d360f8SMartin Matuska.Fl Fl newer-mtime 982caf54c4fSMartin Matuskaswitches accept a variety of common date and time specifications, including 983caf54c4fSMartin Matuska.Dq 12 Mar 2005 7:14:29pm , 984caf54c4fSMartin Matuska.Dq 2005-03-12 19:14 , 985caf54c4fSMartin Matuska.Dq 5 minutes ago , 986caf54c4fSMartin Matuskaand 987caf54c4fSMartin Matuska.Dq 19:14 PST May 1 . 988caf54c4fSMartin Matuska.Pp 989caf54c4fSMartin MatuskaThe 990c5d360f8SMartin Matuska.Fl Fl options 991caf54c4fSMartin Matuskaargument can be used to control various details of archive generation 992caf54c4fSMartin Matuskaor reading. 993caf54c4fSMartin MatuskaFor example, you can generate mtree output which only contains 994caf54c4fSMartin Matuska.Cm type , Cm time , 995caf54c4fSMartin Matuskaand 996caf54c4fSMartin Matuska.Cm uid 997caf54c4fSMartin Matuskakeywords: 998c5d360f8SMartin Matuska.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir 999caf54c4fSMartin Matuskaor you can set the compression level used by gzip or xz compression: 1000c5d360f8SMartin Matuska.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' . 1001caf54c4fSMartin MatuskaFor more details, see the explanation of the 1002caf54c4fSMartin Matuska.Fn archive_read_set_options 1003caf54c4fSMartin Matuskaand 1004caf54c4fSMartin Matuska.Fn archive_write_set_options 1005caf54c4fSMartin MatuskaAPI calls that are described in 1006caf54c4fSMartin Matuska.Xr archive_read 3 1007caf54c4fSMartin Matuskaand 1008caf54c4fSMartin Matuska.Xr archive_write 3 . 1009caf54c4fSMartin Matuska.Sh COMPATIBILITY 1010caf54c4fSMartin MatuskaThe bundled-arguments format is supported for compatibility 1011caf54c4fSMartin Matuskawith historic implementations. 1012caf54c4fSMartin MatuskaIt consists of an initial word (with no leading - character) in which 1013caf54c4fSMartin Matuskaeach character indicates an option. 1014caf54c4fSMartin MatuskaArguments follow as separate words. 1015caf54c4fSMartin MatuskaThe order of the arguments must match the order 1016caf54c4fSMartin Matuskaof the corresponding characters in the bundled command word. 1017caf54c4fSMartin MatuskaFor example, 1018caf54c4fSMartin Matuska.Dl Nm Cm tbf 32 Pa file.tar 1019caf54c4fSMartin Matuskaspecifies three flags 1020caf54c4fSMartin Matuska.Cm t , 1021caf54c4fSMartin Matuska.Cm b , 1022caf54c4fSMartin Matuskaand 1023caf54c4fSMartin Matuska.Cm f . 1024caf54c4fSMartin MatuskaThe 1025caf54c4fSMartin Matuska.Cm b 1026caf54c4fSMartin Matuskaand 1027caf54c4fSMartin Matuska.Cm f 1028caf54c4fSMartin Matuskaflags both require arguments, 1029caf54c4fSMartin Matuskaso there must be two additional items 1030caf54c4fSMartin Matuskaon the command line. 1031caf54c4fSMartin MatuskaThe 1032caf54c4fSMartin Matuska.Ar 32 1033caf54c4fSMartin Matuskais the argument to the 1034caf54c4fSMartin Matuska.Cm b 1035caf54c4fSMartin Matuskaflag, and 1036caf54c4fSMartin Matuska.Ar file.tar 1037caf54c4fSMartin Matuskais the argument to the 1038caf54c4fSMartin Matuska.Cm f 1039caf54c4fSMartin Matuskaflag. 1040caf54c4fSMartin Matuska.Pp 1041caf54c4fSMartin MatuskaThe mode options c, r, t, u, and x and the options 1042caf54c4fSMartin Matuskab, f, l, m, o, v, and w comply with SUSv2. 1043caf54c4fSMartin Matuska.Pp 1044caf54c4fSMartin MatuskaFor maximum portability, scripts that invoke 1045caf54c4fSMartin Matuska.Nm tar 1046caf54c4fSMartin Matuskashould use the bundled-argument format above, should limit 1047caf54c4fSMartin Matuskathemselves to the 1048caf54c4fSMartin Matuska.Cm c , 1049caf54c4fSMartin Matuska.Cm t , 1050caf54c4fSMartin Matuskaand 1051caf54c4fSMartin Matuska.Cm x 1052caf54c4fSMartin Matuskamodes, and the 1053caf54c4fSMartin Matuska.Cm b , 1054caf54c4fSMartin Matuska.Cm f , 1055caf54c4fSMartin Matuska.Cm m , 1056caf54c4fSMartin Matuska.Cm v , 1057caf54c4fSMartin Matuskaand 1058caf54c4fSMartin Matuska.Cm w 1059caf54c4fSMartin Matuskaoptions. 1060caf54c4fSMartin Matuska.Pp 1061caf54c4fSMartin MatuskaAdditional long options are provided to improve compatibility with other 1062caf54c4fSMartin Matuskatar implementations. 1063caf54c4fSMartin Matuska.Sh SECURITY 1064caf54c4fSMartin MatuskaCertain security issues are common to many archiving programs, including 1065caf54c4fSMartin Matuska.Nm . 1066caf54c4fSMartin MatuskaIn particular, carefully-crafted archives can request that 1067caf54c4fSMartin Matuska.Nm 1068caf54c4fSMartin Matuskaextract files to locations outside of the target directory. 1069caf54c4fSMartin MatuskaThis can potentially be used to cause unwitting users to overwrite 1070caf54c4fSMartin Matuskafiles they did not intend to overwrite. 1071caf54c4fSMartin MatuskaIf the archive is being extracted by the superuser, any file 1072caf54c4fSMartin Matuskaon the system can potentially be overwritten. 1073caf54c4fSMartin MatuskaThere are three ways this can happen. 1074caf54c4fSMartin MatuskaAlthough 1075caf54c4fSMartin Matuska.Nm 1076caf54c4fSMartin Matuskahas mechanisms to protect against each one, 1077caf54c4fSMartin Matuskasavvy users should be aware of the implications: 1078caf54c4fSMartin Matuska.Bl -bullet -width indent 1079caf54c4fSMartin Matuska.It 1080caf54c4fSMartin MatuskaArchive entries can have absolute pathnames. 1081caf54c4fSMartin MatuskaBy default, 1082caf54c4fSMartin Matuska.Nm 1083caf54c4fSMartin Matuskaremoves the leading 1084caf54c4fSMartin Matuska.Pa / 1085caf54c4fSMartin Matuskacharacter from filenames before restoring them to guard against this problem. 1086caf54c4fSMartin Matuska.It 1087caf54c4fSMartin MatuskaArchive entries can have pathnames that include 1088caf54c4fSMartin Matuska.Pa .. 1089caf54c4fSMartin Matuskacomponents. 1090caf54c4fSMartin MatuskaBy default, 1091caf54c4fSMartin Matuska.Nm 1092caf54c4fSMartin Matuskawill not extract files containing 1093caf54c4fSMartin Matuska.Pa .. 1094caf54c4fSMartin Matuskacomponents in their pathname. 1095caf54c4fSMartin Matuska.It 1096caf54c4fSMartin MatuskaArchive entries can exploit symbolic links to restore 1097caf54c4fSMartin Matuskafiles to other directories. 1098caf54c4fSMartin MatuskaAn archive can restore a symbolic link to another directory, 1099caf54c4fSMartin Matuskathen use that link to restore a file into that directory. 1100caf54c4fSMartin MatuskaTo guard against this, 1101caf54c4fSMartin Matuska.Nm 1102caf54c4fSMartin Matuskachecks each extracted path for symlinks. 1103caf54c4fSMartin MatuskaIf the final path element is a symlink, it will be removed 1104caf54c4fSMartin Matuskaand replaced with the archive entry. 1105caf54c4fSMartin MatuskaIf 1106caf54c4fSMartin Matuska.Fl U 1107caf54c4fSMartin Matuskais specified, any intermediate symlink will also be unconditionally removed. 1108caf54c4fSMartin MatuskaIf neither 1109caf54c4fSMartin Matuska.Fl U 1110caf54c4fSMartin Matuskanor 1111caf54c4fSMartin Matuska.Fl P 1112caf54c4fSMartin Matuskais specified, 1113caf54c4fSMartin Matuska.Nm 1114caf54c4fSMartin Matuskawill refuse to extract the entry. 1115caf54c4fSMartin Matuska.El 1116caf54c4fSMartin MatuskaTo protect yourself, you should be wary of any archives that 1117caf54c4fSMartin Matuskacome from untrusted sources. 1118caf54c4fSMartin MatuskaYou should examine the contents of an archive with 1119caf54c4fSMartin Matuska.Dl Nm Fl tf Pa filename 1120caf54c4fSMartin Matuskabefore extraction. 1121caf54c4fSMartin MatuskaYou should use the 1122caf54c4fSMartin Matuska.Fl k 1123caf54c4fSMartin Matuskaoption to ensure that 1124caf54c4fSMartin Matuska.Nm 1125caf54c4fSMartin Matuskawill not overwrite any existing files or the 1126caf54c4fSMartin Matuska.Fl U 1127caf54c4fSMartin Matuskaoption to remove any pre-existing files. 1128caf54c4fSMartin MatuskaYou should generally not extract archives while running with super-user 1129caf54c4fSMartin Matuskaprivileges. 1130caf54c4fSMartin MatuskaNote that the 1131caf54c4fSMartin Matuska.Fl P 1132caf54c4fSMartin Matuskaoption to 1133caf54c4fSMartin Matuska.Nm 1134caf54c4fSMartin Matuskadisables the security checks above and allows you to extract 1135caf54c4fSMartin Matuskaan archive while preserving any absolute pathnames, 1136caf54c4fSMartin Matuska.Pa .. 1137caf54c4fSMartin Matuskacomponents, or symlinks to other directories. 1138caf54c4fSMartin Matuska.Sh SEE ALSO 1139caf54c4fSMartin Matuska.Xr bzip2 1 , 1140caf54c4fSMartin Matuska.Xr compress 1 , 1141caf54c4fSMartin Matuska.Xr cpio 1 , 1142caf54c4fSMartin Matuska.Xr gzip 1 , 1143caf54c4fSMartin Matuska.Xr mt 1 , 1144caf54c4fSMartin Matuska.Xr pax 1 , 1145caf54c4fSMartin Matuska.Xr shar 1 , 1146c5d360f8SMartin Matuska.Xr xz 1 , 1147caf54c4fSMartin Matuska.Xr libarchive 3 , 1148caf54c4fSMartin Matuska.Xr libarchive-formats 5 , 1149caf54c4fSMartin Matuska.Xr tar 5 1150caf54c4fSMartin Matuska.Sh STANDARDS 1151caf54c4fSMartin MatuskaThere is no current POSIX standard for the tar command; it appeared 1152caf54c4fSMartin Matuskain 1153caf54c4fSMartin Matuska.St -p1003.1-96 1154caf54c4fSMartin Matuskabut was dropped from 1155caf54c4fSMartin Matuska.St -p1003.1-2001 . 1156c5d360f8SMartin MatuskaThe options supported by this implementation were developed by surveying a 1157caf54c4fSMartin Matuskanumber of existing tar implementations as well as the old POSIX specification 1158caf54c4fSMartin Matuskafor tar and the current POSIX specification for pax. 1159caf54c4fSMartin Matuska.Pp 1160caf54c4fSMartin MatuskaThe ustar and pax interchange file formats are defined by 1161caf54c4fSMartin Matuska.St -p1003.1-2001 1162caf54c4fSMartin Matuskafor the pax command. 1163caf54c4fSMartin Matuska.Sh HISTORY 1164caf54c4fSMartin MatuskaA 1165caf54c4fSMartin Matuska.Nm tar 1166caf54c4fSMartin Matuskacommand appeared in Seventh Edition Unix, which was released in January, 1979. 1167caf54c4fSMartin MatuskaThere have been numerous other implementations, 1168caf54c4fSMartin Matuskamany of which extended the file format. 1169caf54c4fSMartin MatuskaJohn Gilmore's 1170caf54c4fSMartin Matuska.Nm pdtar 1171caf54c4fSMartin Matuskapublic-domain implementation (circa November, 1987) 1172caf54c4fSMartin Matuskawas quite influential, and formed the basis of GNU tar. 1173caf54c4fSMartin MatuskaGNU tar was included as the standard system tar 1174caf54c4fSMartin Matuskain 1175caf54c4fSMartin Matuska.Fx 1176caf54c4fSMartin Matuskabeginning with 1177caf54c4fSMartin Matuska.Fx 1.0 . 1178caf54c4fSMartin Matuska.Pp 1179caf54c4fSMartin MatuskaThis is a complete re-implementation based on the 1180caf54c4fSMartin Matuska.Xr libarchive 3 1181caf54c4fSMartin Matuskalibrary. 1182c5d360f8SMartin MatuskaIt was first released with 1183c5d360f8SMartin Matuska.Fx 5.4 1184c5d360f8SMartin Matuskain May, 2005. 1185caf54c4fSMartin Matuska.Sh BUGS 1186caf54c4fSMartin MatuskaThis program follows 1187caf54c4fSMartin Matuska.St -p1003.1-96 1188caf54c4fSMartin Matuskafor the definition of the 1189caf54c4fSMartin Matuska.Fl l 1190caf54c4fSMartin Matuskaoption. 1191caf54c4fSMartin MatuskaNote that GNU tar prior to version 1.15 treated 1192caf54c4fSMartin Matuska.Fl l 1193caf54c4fSMartin Matuskaas a synonym for the 1194c5d360f8SMartin Matuska.Fl Fl one-file-system 1195caf54c4fSMartin Matuskaoption. 1196caf54c4fSMartin Matuska.Pp 1197caf54c4fSMartin MatuskaThe 1198caf54c4fSMartin Matuska.Fl C Pa dir 1199caf54c4fSMartin Matuskaoption may differ from historic implementations. 1200caf54c4fSMartin Matuska.Pp 1201caf54c4fSMartin MatuskaAll archive output is written in correctly-sized blocks, even 1202caf54c4fSMartin Matuskaif the output is being compressed. 1203caf54c4fSMartin MatuskaWhether or not the last output block is padded to a full 1204caf54c4fSMartin Matuskablock size varies depending on the format and the 1205caf54c4fSMartin Matuskaoutput device. 1206caf54c4fSMartin MatuskaFor tar and cpio formats, the last block of output is padded 1207caf54c4fSMartin Matuskato a full block size if the output is being 1208caf54c4fSMartin Matuskawritten to standard output or to a character or block device such as 1209caf54c4fSMartin Matuskaa tape drive. 1210caf54c4fSMartin MatuskaIf the output is being written to a regular file, the last block 1211caf54c4fSMartin Matuskawill not be padded. 1212caf54c4fSMartin MatuskaMany compressors, including 1213caf54c4fSMartin Matuska.Xr gzip 1 1214caf54c4fSMartin Matuskaand 1215caf54c4fSMartin Matuska.Xr bzip2 1 , 1216caf54c4fSMartin Matuskacomplain about the null padding when decompressing an archive created by 1217caf54c4fSMartin Matuska.Nm , 1218caf54c4fSMartin Matuskaalthough they still extract it correctly. 1219caf54c4fSMartin Matuska.Pp 1220caf54c4fSMartin MatuskaThe compression and decompression is implemented internally, so 1221caf54c4fSMartin Matuskathere may be insignificant differences between the compressed output 1222caf54c4fSMartin Matuskagenerated by 1223caf54c4fSMartin Matuska.Dl Nm Fl czf Pa - file 1224caf54c4fSMartin Matuskaand that generated by 1225caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - file | Nm gzip 1226caf54c4fSMartin Matuska.Pp 1227caf54c4fSMartin MatuskaThe default should be to read and write archives to the standard I/O paths, 1228caf54c4fSMartin Matuskabut tradition (and POSIX) dictates otherwise. 1229caf54c4fSMartin Matuska.Pp 1230caf54c4fSMartin MatuskaThe 1231caf54c4fSMartin Matuska.Cm r 1232caf54c4fSMartin Matuskaand 1233caf54c4fSMartin Matuska.Cm u 1234caf54c4fSMartin Matuskamodes require that the archive be uncompressed 1235caf54c4fSMartin Matuskaand located in a regular file on disk. 1236caf54c4fSMartin MatuskaOther archives can be modified using 1237caf54c4fSMartin Matuska.Cm c 1238caf54c4fSMartin Matuskamode with the 1239caf54c4fSMartin Matuska.Pa @archive-file 1240caf54c4fSMartin Matuskaextension. 1241caf54c4fSMartin Matuska.Pp 1242caf54c4fSMartin MatuskaTo archive a file called 1243caf54c4fSMartin Matuska.Pa @foo 1244caf54c4fSMartin Matuskaor 1245caf54c4fSMartin Matuska.Pa -foo 1246caf54c4fSMartin Matuskayou must specify it as 1247caf54c4fSMartin Matuska.Pa ./@foo 1248caf54c4fSMartin Matuskaor 1249caf54c4fSMartin Matuska.Pa ./-foo , 1250caf54c4fSMartin Matuskarespectively. 1251caf54c4fSMartin Matuska.Pp 1252caf54c4fSMartin MatuskaIn create mode, a leading 1253caf54c4fSMartin Matuska.Pa ./ 1254caf54c4fSMartin Matuskais always removed. 1255caf54c4fSMartin MatuskaA leading 1256caf54c4fSMartin Matuska.Pa / 1257caf54c4fSMartin Matuskais stripped unless the 1258caf54c4fSMartin Matuska.Fl P 1259caf54c4fSMartin Matuskaoption is specified. 1260caf54c4fSMartin Matuska.Pp 1261caf54c4fSMartin MatuskaThere needs to be better support for file selection on both create 1262caf54c4fSMartin Matuskaand extract. 1263caf54c4fSMartin Matuska.Pp 1264cdf63a70SMartin MatuskaThere is not yet any support for multi-volume archives. 1265caf54c4fSMartin Matuska.Pp 1266caf54c4fSMartin MatuskaConverting between dissimilar archive formats (such as tar and cpio) using the 1267caf54c4fSMartin Matuska.Cm @ Ns Pa - 1268caf54c4fSMartin Matuskaconvention can cause hard link information to be lost. 1269caf54c4fSMartin Matuska(This is a consequence of the incompatible ways that different archive 1270caf54c4fSMartin Matuskaformats store hardlink information.) 1271