1*caf54c4fSMartin Matuska.\" Copyright (c) 2003-2007 Tim Kientzle 2*caf54c4fSMartin Matuska.\" All rights reserved. 3*caf54c4fSMartin Matuska.\" 4*caf54c4fSMartin Matuska.\" Redistribution and use in source and binary forms, with or without 5*caf54c4fSMartin Matuska.\" modification, are permitted provided that the following conditions 6*caf54c4fSMartin Matuska.\" are met: 7*caf54c4fSMartin Matuska.\" 1. Redistributions of source code must retain the above copyright 8*caf54c4fSMartin Matuska.\" notice, this list of conditions and the following disclaimer. 9*caf54c4fSMartin Matuska.\" 2. Redistributions in binary form must reproduce the above copyright 10*caf54c4fSMartin Matuska.\" notice, this list of conditions and the following disclaimer in the 11*caf54c4fSMartin Matuska.\" documentation and/or other materials provided with the distribution. 12*caf54c4fSMartin Matuska.\" 13*caf54c4fSMartin Matuska.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*caf54c4fSMartin Matuska.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*caf54c4fSMartin Matuska.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*caf54c4fSMartin Matuska.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*caf54c4fSMartin Matuska.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*caf54c4fSMartin Matuska.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*caf54c4fSMartin Matuska.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*caf54c4fSMartin Matuska.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*caf54c4fSMartin Matuska.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*caf54c4fSMartin Matuska.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*caf54c4fSMartin Matuska.\" SUCH DAMAGE. 24*caf54c4fSMartin Matuska.\" 25*caf54c4fSMartin Matuska.\" $FreeBSD: src/usr.bin/tar/bsdtar.1,v 1.46 2008/12/06 07:37:55 kientzle Exp $ 26*caf54c4fSMartin Matuska.\" 27*caf54c4fSMartin Matuska.Dd Oct 12, 2009 28*caf54c4fSMartin Matuska.Dt BSDTAR 1 29*caf54c4fSMartin Matuska.Os 30*caf54c4fSMartin Matuska.Sh NAME 31*caf54c4fSMartin Matuska.Nm tar 32*caf54c4fSMartin Matuska.Nd manipulate tape archives 33*caf54c4fSMartin Matuska.Sh SYNOPSIS 34*caf54c4fSMartin Matuska.Nm 35*caf54c4fSMartin Matuska.Op Ar bundled-flags Ao args Ac 36*caf54c4fSMartin Matuska.Op Ao Ar file Ac | Ao Ar pattern Ac ... 37*caf54c4fSMartin Matuska.Nm 38*caf54c4fSMartin Matuska.Brq Fl c 39*caf54c4fSMartin Matuska.Op Ar options 40*caf54c4fSMartin Matuska.Op Ar files | Ar directories 41*caf54c4fSMartin Matuska.Nm 42*caf54c4fSMartin Matuska.Brq Fl r | Fl u 43*caf54c4fSMartin Matuska.Fl f Ar archive-file 44*caf54c4fSMartin Matuska.Op Ar options 45*caf54c4fSMartin Matuska.Op Ar files | Ar directories 46*caf54c4fSMartin Matuska.Nm 47*caf54c4fSMartin Matuska.Brq Fl t | Fl x 48*caf54c4fSMartin Matuska.Op Ar options 49*caf54c4fSMartin Matuska.Op Ar patterns 50*caf54c4fSMartin Matuska.Sh DESCRIPTION 51*caf54c4fSMartin Matuska.Nm 52*caf54c4fSMartin Matuskacreates and manipulates streaming archive files. 53*caf54c4fSMartin MatuskaThis implementation can extract from tar, pax, cpio, zip, jar, ar, 54*caf54c4fSMartin Matuskaand ISO 9660 cdrom images and can create tar, pax, cpio, ar, 55*caf54c4fSMartin Matuskaand shar archives. 56*caf54c4fSMartin Matuska.Pp 57*caf54c4fSMartin MatuskaThe first synopsis form shows a 58*caf54c4fSMartin Matuska.Dq bundled 59*caf54c4fSMartin Matuskaoption word. 60*caf54c4fSMartin MatuskaThis usage is provided for compatibility with historical implementations. 61*caf54c4fSMartin MatuskaSee COMPATIBILITY below for details. 62*caf54c4fSMartin Matuska.Pp 63*caf54c4fSMartin MatuskaThe other synopsis forms show the preferred usage. 64*caf54c4fSMartin MatuskaThe first option to 65*caf54c4fSMartin Matuska.Nm 66*caf54c4fSMartin Matuskais a mode indicator from the following list: 67*caf54c4fSMartin Matuska.Bl -tag -compact -width indent 68*caf54c4fSMartin Matuska.It Fl c 69*caf54c4fSMartin MatuskaCreate a new archive containing the specified items. 70*caf54c4fSMartin Matuska.It Fl r 71*caf54c4fSMartin MatuskaLike 72*caf54c4fSMartin Matuska.Fl c , 73*caf54c4fSMartin Matuskabut new entries are appended to the archive. 74*caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files. 75*caf54c4fSMartin MatuskaThe 76*caf54c4fSMartin Matuska.Fl f 77*caf54c4fSMartin Matuskaoption is required. 78*caf54c4fSMartin Matuska.It Fl t 79*caf54c4fSMartin MatuskaList archive contents to stdout. 80*caf54c4fSMartin Matuska.It Fl u 81*caf54c4fSMartin MatuskaLike 82*caf54c4fSMartin Matuska.Fl r , 83*caf54c4fSMartin Matuskabut new entries are added only if they have a modification date 84*caf54c4fSMartin Matuskanewer than the corresponding entry in the archive. 85*caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files. 86*caf54c4fSMartin MatuskaThe 87*caf54c4fSMartin Matuska.Fl f 88*caf54c4fSMartin Matuskaoption is required. 89*caf54c4fSMartin Matuska.It Fl x 90*caf54c4fSMartin MatuskaExtract to disk from the archive. 91*caf54c4fSMartin MatuskaIf a file with the same name appears more than once in the archive, 92*caf54c4fSMartin Matuskaeach copy will be extracted, with later copies overwriting (replacing) 93*caf54c4fSMartin Matuskaearlier copies. 94*caf54c4fSMartin Matuska.El 95*caf54c4fSMartin Matuska.Pp 96*caf54c4fSMartin MatuskaIn 97*caf54c4fSMartin Matuska.Fl c , 98*caf54c4fSMartin Matuska.Fl r , 99*caf54c4fSMartin Matuskaor 100*caf54c4fSMartin Matuska.Fl u 101*caf54c4fSMartin Matuskamode, each specified file or directory is added to the 102*caf54c4fSMartin Matuskaarchive in the order specified on the command line. 103*caf54c4fSMartin MatuskaBy default, the contents of each directory are also archived. 104*caf54c4fSMartin Matuska.Pp 105*caf54c4fSMartin MatuskaIn extract or list mode, the entire command line 106*caf54c4fSMartin Matuskais read and parsed before the archive is opened. 107*caf54c4fSMartin MatuskaThe pathnames or patterns on the command line indicate 108*caf54c4fSMartin Matuskawhich items in the archive should be processed. 109*caf54c4fSMartin MatuskaPatterns are shell-style globbing patterns as 110*caf54c4fSMartin Matuskadocumented in 111*caf54c4fSMartin Matuska.Xr tcsh 1 . 112*caf54c4fSMartin Matuska.Sh OPTIONS 113*caf54c4fSMartin MatuskaUnless specifically stated otherwise, options are applicable in 114*caf54c4fSMartin Matuskaall operating modes. 115*caf54c4fSMartin Matuska.Bl -tag -width indent 116*caf54c4fSMartin Matuska.It Cm @ Ns Pa archive 117*caf54c4fSMartin Matuska(c and r mode only) 118*caf54c4fSMartin MatuskaThe specified archive is opened and the entries 119*caf54c4fSMartin Matuskain it will be appended to the current archive. 120*caf54c4fSMartin MatuskaAs a simple example, 121*caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar 122*caf54c4fSMartin Matuskawrites a new archive to standard output containing a file 123*caf54c4fSMartin Matuska.Pa newfile 124*caf54c4fSMartin Matuskaand all of the entries from 125*caf54c4fSMartin Matuska.Pa original.tar . 126*caf54c4fSMartin MatuskaIn contrast, 127*caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar 128*caf54c4fSMartin Matuskacreates a new archive with only two entries. 129*caf54c4fSMartin MatuskaSimilarly, 130*caf54c4fSMartin Matuska.Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa - 131*caf54c4fSMartin Matuskareads an archive from standard input (whose format will be determined 132*caf54c4fSMartin Matuskaautomatically) and converts it into a gzip-compressed 133*caf54c4fSMartin Matuskapax-format archive on stdout. 134*caf54c4fSMartin MatuskaIn this way, 135*caf54c4fSMartin Matuska.Nm 136*caf54c4fSMartin Matuskacan be used to convert archives from one format to another. 137*caf54c4fSMartin Matuska.It Fl b Ar blocksize 138*caf54c4fSMartin MatuskaSpecify the block size, in 512-byte records, for tape drive I/O. 139*caf54c4fSMartin MatuskaAs a rule, this argument is only needed when reading from or writing 140*caf54c4fSMartin Matuskato tape drives, and usually not even then as the default block size of 141*caf54c4fSMartin Matuska20 records (10240 bytes) is very common. 142*caf54c4fSMartin Matuska.It Fl C Ar directory 143*caf54c4fSMartin MatuskaIn c and r mode, this changes the directory before adding 144*caf54c4fSMartin Matuskathe following files. 145*caf54c4fSMartin MatuskaIn x mode, change directories after opening the archive 146*caf54c4fSMartin Matuskabut before extracting entries from the archive. 147*caf54c4fSMartin Matuska.It Fl -check-links 148*caf54c4fSMartin Matuska(c and r modes only) 149*caf54c4fSMartin MatuskaIssue a warning message unless all links to each file are archived. 150*caf54c4fSMartin Matuska.It Fl -chroot 151*caf54c4fSMartin Matuska(x mode only) 152*caf54c4fSMartin Matuska.Fn chroot 153*caf54c4fSMartin Matuskato the current directory after processing any 154*caf54c4fSMartin Matuska.Fl C 155*caf54c4fSMartin Matuskaoptions and before extracting any files. 156*caf54c4fSMartin Matuska.It Fl -exclude Ar pattern 157*caf54c4fSMartin MatuskaDo not process files or directories that match the 158*caf54c4fSMartin Matuskaspecified pattern. 159*caf54c4fSMartin MatuskaNote that exclusions take precedence over patterns or filenames 160*caf54c4fSMartin Matuskaspecified on the command line. 161*caf54c4fSMartin Matuska.It Fl -format Ar format 162*caf54c4fSMartin Matuska(c, r, u mode only) 163*caf54c4fSMartin MatuskaUse the specified format for the created archive. 164*caf54c4fSMartin MatuskaSupported formats include 165*caf54c4fSMartin Matuska.Dq cpio , 166*caf54c4fSMartin Matuska.Dq pax , 167*caf54c4fSMartin Matuska.Dq shar , 168*caf54c4fSMartin Matuskaand 169*caf54c4fSMartin Matuska.Dq ustar . 170*caf54c4fSMartin MatuskaOther formats may also be supported; see 171*caf54c4fSMartin Matuska.Xr libarchive-formats 5 172*caf54c4fSMartin Matuskafor more information about currently-supported formats. 173*caf54c4fSMartin MatuskaIn r and u modes, when extending an existing archive, the format specified 174*caf54c4fSMartin Matuskahere must be compatible with the format of the existing archive on disk. 175*caf54c4fSMartin Matuska.It Fl f Ar file 176*caf54c4fSMartin MatuskaRead the archive from or write the archive to the specified file. 177*caf54c4fSMartin MatuskaThe filename can be 178*caf54c4fSMartin Matuska.Pa - 179*caf54c4fSMartin Matuskafor standard input or standard output. 180*caf54c4fSMartin MatuskaIf not specified, the default tape device will be used. 181*caf54c4fSMartin Matuska(On 182*caf54c4fSMartin Matuska.Fx , 183*caf54c4fSMartin Matuskathe default tape device is 184*caf54c4fSMartin Matuska.Pa /dev/sa0 . ) 185*caf54c4fSMartin Matuska.It Fl Fl gid Ar id 186*caf54c4fSMartin MatuskaUse the provided group id number. 187*caf54c4fSMartin MatuskaOn extract, this overrides the group id in the archive; 188*caf54c4fSMartin Matuskathe group name in the archive will be ignored. 189*caf54c4fSMartin MatuskaOn create, this overrides the group id read from disk; 190*caf54c4fSMartin Matuskaif 191*caf54c4fSMartin Matuska.Fl Fl gname 192*caf54c4fSMartin Matuskais not also specified, the group name will be set to 193*caf54c4fSMartin Matuskamatch the group id. 194*caf54c4fSMartin Matuska.It Fl Fl gname Ar name 195*caf54c4fSMartin MatuskaUse the provided group name. 196*caf54c4fSMartin MatuskaOn extract, this overrides the group name in the archive; 197*caf54c4fSMartin Matuskaif the provided group name does not exist on the system, 198*caf54c4fSMartin Matuskathe group id 199*caf54c4fSMartin Matuska(from the archive or from the 200*caf54c4fSMartin Matuska.Fl Fl gid 201*caf54c4fSMartin Matuskaoption) 202*caf54c4fSMartin Matuskawill be used instead. 203*caf54c4fSMartin MatuskaOn create, this sets the group name that will be stored 204*caf54c4fSMartin Matuskain the archive; 205*caf54c4fSMartin Matuskathe name will not be verified against the system group database. 206*caf54c4fSMartin Matuska.It Fl H 207*caf54c4fSMartin Matuska(c and r mode only) 208*caf54c4fSMartin MatuskaSymbolic links named on the command line will be followed; the 209*caf54c4fSMartin Matuskatarget of the link will be archived, not the link itself. 210*caf54c4fSMartin Matuska.It Fl h 211*caf54c4fSMartin Matuska(c and r mode only) 212*caf54c4fSMartin MatuskaSynonym for 213*caf54c4fSMartin Matuska.Fl L . 214*caf54c4fSMartin Matuska.It Fl I 215*caf54c4fSMartin MatuskaSynonym for 216*caf54c4fSMartin Matuska.Fl T . 217*caf54c4fSMartin Matuska.It Fl -include Ar pattern 218*caf54c4fSMartin MatuskaProcess only files or directories that match the specified pattern. 219*caf54c4fSMartin MatuskaNote that exclusions specified with 220*caf54c4fSMartin Matuska.Fl -exclude 221*caf54c4fSMartin Matuskatake precedence over inclusions. 222*caf54c4fSMartin MatuskaIf no inclusions are explicitly specified, all entries are processed by 223*caf54c4fSMartin Matuskadefault. 224*caf54c4fSMartin MatuskaThe 225*caf54c4fSMartin Matuska.Fl -include 226*caf54c4fSMartin Matuskaoption is especially useful when filtering archives. 227*caf54c4fSMartin MatuskaFor example, the command 228*caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz 229*caf54c4fSMartin Matuskacreates a new archive 230*caf54c4fSMartin Matuska.Pa new.tar 231*caf54c4fSMartin Matuskacontaining only the entries from 232*caf54c4fSMartin Matuska.Pa old.tgz 233*caf54c4fSMartin Matuskacontaining the string 234*caf54c4fSMartin Matuska.Sq foo . 235*caf54c4fSMartin Matuska.It Fl j 236*caf54c4fSMartin Matuska(c mode only) 237*caf54c4fSMartin MatuskaCompress the resulting archive with 238*caf54c4fSMartin Matuska.Xr bzip2 1 . 239*caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 240*caf54c4fSMartin MatuskaNote that, unlike other 241*caf54c4fSMartin Matuska.Nm tar 242*caf54c4fSMartin Matuskaimplementations, this implementation recognizes bzip2 compression 243*caf54c4fSMartin Matuskaautomatically when reading archives. 244*caf54c4fSMartin Matuska.It Fl k 245*caf54c4fSMartin Matuska(x mode only) 246*caf54c4fSMartin MatuskaDo not overwrite existing files. 247*caf54c4fSMartin MatuskaIn particular, if a file appears more than once in an archive, 248*caf54c4fSMartin Matuskalater copies will not overwrite earlier copies. 249*caf54c4fSMartin Matuska.It Fl -keep-newer-files 250*caf54c4fSMartin Matuska(x mode only) 251*caf54c4fSMartin MatuskaDo not overwrite existing files that are newer than the 252*caf54c4fSMartin Matuskaversions appearing in the archive being extracted. 253*caf54c4fSMartin Matuska.It Fl L 254*caf54c4fSMartin Matuska(c and r mode only) 255*caf54c4fSMartin MatuskaAll symbolic links will be followed. 256*caf54c4fSMartin MatuskaNormally, symbolic links are archived as such. 257*caf54c4fSMartin MatuskaWith this option, the target of the link will be archived instead. 258*caf54c4fSMartin Matuska.It Fl l 259*caf54c4fSMartin MatuskaThis is a synonym for the 260*caf54c4fSMartin Matuska.Fl -check-links 261*caf54c4fSMartin Matuskaoption. 262*caf54c4fSMartin Matuska.It Fl m 263*caf54c4fSMartin Matuska(x mode only) 264*caf54c4fSMartin MatuskaDo not extract modification time. 265*caf54c4fSMartin MatuskaBy default, the modification time is set to the time stored in the archive. 266*caf54c4fSMartin Matuska.It Fl n 267*caf54c4fSMartin Matuska(c, r, u modes only) 268*caf54c4fSMartin MatuskaDo not recursively archive the contents of directories. 269*caf54c4fSMartin Matuska.It Fl -newer Ar date 270*caf54c4fSMartin Matuska(c, r, u modes only) 271*caf54c4fSMartin MatuskaOnly include files and directories newer than the specified date. 272*caf54c4fSMartin MatuskaThis compares ctime entries. 273*caf54c4fSMartin Matuska.It Fl -newer-mtime Ar date 274*caf54c4fSMartin Matuska(c, r, u modes only) 275*caf54c4fSMartin MatuskaLike 276*caf54c4fSMartin Matuska.Fl -newer , 277*caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries. 278*caf54c4fSMartin Matuska.It Fl -newer-than Pa file 279*caf54c4fSMartin Matuska(c, r, u modes only) 280*caf54c4fSMartin MatuskaOnly include files and directories newer than the specified file. 281*caf54c4fSMartin MatuskaThis compares ctime entries. 282*caf54c4fSMartin Matuska.It Fl -newer-mtime-than Pa file 283*caf54c4fSMartin Matuska(c, r, u modes only) 284*caf54c4fSMartin MatuskaLike 285*caf54c4fSMartin Matuska.Fl -newer-than , 286*caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries. 287*caf54c4fSMartin Matuska.It Fl -nodump 288*caf54c4fSMartin Matuska(c and r modes only) 289*caf54c4fSMartin MatuskaHonor the nodump file flag by skipping this file. 290*caf54c4fSMartin Matuska.It Fl -null 291*caf54c4fSMartin Matuska(use with 292*caf54c4fSMartin Matuska.Fl I , 293*caf54c4fSMartin Matuska.Fl T , 294*caf54c4fSMartin Matuskaor 295*caf54c4fSMartin Matuska.Fl X ) 296*caf54c4fSMartin MatuskaFilenames or patterns are separated by null characters, 297*caf54c4fSMartin Matuskanot by newlines. 298*caf54c4fSMartin MatuskaThis is often used to read filenames output by the 299*caf54c4fSMartin Matuska.Fl print0 300*caf54c4fSMartin Matuskaoption to 301*caf54c4fSMartin Matuska.Xr find 1 . 302*caf54c4fSMartin Matuska.It Fl -numeric-owner 303*caf54c4fSMartin Matuska(x mode only) 304*caf54c4fSMartin MatuskaIgnore symbolic user and group names when restoring archives to disk, 305*caf54c4fSMartin Matuskaonly numeric uid and gid values will be obeyed. 306*caf54c4fSMartin Matuska.It Fl Fl no-same-owner 307*caf54c4fSMartin Matuska(x mode only) 308*caf54c4fSMartin MatuskaDo not extract owner and group IDs. 309*caf54c4fSMartin MatuskaThis is the reverse of 310*caf54c4fSMartin Matuska.Fl Fl same-owner 311*caf54c4fSMartin Matuskaand the default behavior if 312*caf54c4fSMartin Matuska.Nm 313*caf54c4fSMartin Matuskais run as non-root. 314*caf54c4fSMartin Matuska.It Fl Fl no-same-permissions 315*caf54c4fSMartin Matuska(x mode only) 316*caf54c4fSMartin MatuskaDo not extract full permissions (SGID, SUID, sticky bit, ACLs, 317*caf54c4fSMartin Matuskaextended attributes or extended file flags). 318*caf54c4fSMartin MatuskaThis is the reverse of 319*caf54c4fSMartin Matuska.Fl p 320*caf54c4fSMartin Matuskaand the default behavior if 321*caf54c4fSMartin Matuska.Nm 322*caf54c4fSMartin Matuskais run as non-root. 323*caf54c4fSMartin Matuska.It Fl Fl numeric-owner 324*caf54c4fSMartin MatuskaThis is equivalent to 325*caf54c4fSMartin Matuska.Fl Fl uname 326*caf54c4fSMartin Matuska.Qq 327*caf54c4fSMartin Matuska.Fl Fl gname 328*caf54c4fSMartin Matuska.Qq . 329*caf54c4fSMartin MatuskaOn extract, it causes user and group names in the archive 330*caf54c4fSMartin Matuskato be ignored in favor of the numeric user and group ids. 331*caf54c4fSMartin MatuskaOn create, it causes user and group names to not be stored 332*caf54c4fSMartin Matuskain the archive. 333*caf54c4fSMartin Matuska.It Fl O 334*caf54c4fSMartin Matuska(x, t modes only) 335*caf54c4fSMartin MatuskaIn extract (-x) mode, files will be written to standard out rather than 336*caf54c4fSMartin Matuskabeing extracted to disk. 337*caf54c4fSMartin MatuskaIn list (-t) mode, the file listing will be written to stderr rather than 338*caf54c4fSMartin Matuskathe usual stdout. 339*caf54c4fSMartin Matuska.It Fl o 340*caf54c4fSMartin Matuska(x mode) 341*caf54c4fSMartin MatuskaUse the user and group of the user running the program rather 342*caf54c4fSMartin Matuskathan those specified in the archive. 343*caf54c4fSMartin MatuskaNote that this has no significance unless 344*caf54c4fSMartin Matuska.Fl p 345*caf54c4fSMartin Matuskais specified, and the program is being run by the root user. 346*caf54c4fSMartin MatuskaIn this case, the file modes and flags from 347*caf54c4fSMartin Matuskathe archive will be restored, but ACLs or owner information in 348*caf54c4fSMartin Matuskathe archive will be discarded. 349*caf54c4fSMartin Matuska.It Fl o 350*caf54c4fSMartin Matuska(c, r, u mode) 351*caf54c4fSMartin MatuskaA synonym for 352*caf54c4fSMartin Matuska.Fl -format Ar ustar 353*caf54c4fSMartin Matuska.It Fl -one-file-system 354*caf54c4fSMartin Matuska(c, r, and u modes) 355*caf54c4fSMartin MatuskaDo not cross mount points. 356*caf54c4fSMartin Matuska.It Fl -options Ar options 357*caf54c4fSMartin MatuskaSelect optional behaviors for particular modules. 358*caf54c4fSMartin MatuskaThe argument is a text string containing comma-separated 359*caf54c4fSMartin Matuskakeywords and values. 360*caf54c4fSMartin MatuskaThese are passed to the modules that handle particular 361*caf54c4fSMartin Matuskaformats to control how those formats will behave. 362*caf54c4fSMartin MatuskaEach option has one of the following forms: 363*caf54c4fSMartin Matuska.Bl -tag -compact -width indent 364*caf54c4fSMartin Matuska.It Ar key=value 365*caf54c4fSMartin MatuskaThe key will be set to the specified value in every module that supports it. 366*caf54c4fSMartin MatuskaModules that do not support this key will ignore it. 367*caf54c4fSMartin Matuska.It Ar key 368*caf54c4fSMartin MatuskaThe key will be enabled in every module that supports it. 369*caf54c4fSMartin MatuskaThis is equivalent to 370*caf54c4fSMartin Matuska.Ar key Ns Cm =1 . 371*caf54c4fSMartin Matuska.It Ar !key 372*caf54c4fSMartin MatuskaThe key will be disabled in every module that supports it. 373*caf54c4fSMartin Matuska.It Ar module:key=value , Ar module:key , Ar module:!key 374*caf54c4fSMartin MatuskaAs above, but the corresponding key and value will be provided 375*caf54c4fSMartin Matuskaonly to modules whose name matches 376*caf54c4fSMartin Matuska.Ar module . 377*caf54c4fSMartin Matuska.El 378*caf54c4fSMartin MatuskaThe currently supported modules and keys are: 379*caf54c4fSMartin Matuska.Bl -tag -compact -width indent 380*caf54c4fSMartin Matuska.It Cm iso9660:joliet 381*caf54c4fSMartin MatuskaSupport Joliet extensions. 382*caf54c4fSMartin MatuskaThis is enabled by default, use 383*caf54c4fSMartin Matuska.Cm !joliet 384*caf54c4fSMartin Matuskaor 385*caf54c4fSMartin Matuska.Cm iso9660:!joliet 386*caf54c4fSMartin Matuskato disable. 387*caf54c4fSMartin Matuska.It Cm iso9660:rockridge 388*caf54c4fSMartin MatuskaSupport Rock Ridge extensions. 389*caf54c4fSMartin MatuskaThis is enabled by default, use 390*caf54c4fSMartin Matuska.Cm !rockridge 391*caf54c4fSMartin Matuskaor 392*caf54c4fSMartin Matuska.Cm iso9660:!rockridge 393*caf54c4fSMartin Matuskato disable. 394*caf54c4fSMartin Matuska.It Cm gzip:compression-level 395*caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the gzip compression level. 396*caf54c4fSMartin Matuska.It Cm xz:compression-level 397*caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the xz compression level. 398*caf54c4fSMartin Matuska.It Cm mtree: Ns Ar keyword 399*caf54c4fSMartin MatuskaThe mtree writer module allows you to specify which mtree keywords 400*caf54c4fSMartin Matuskawill be included in the output. 401*caf54c4fSMartin MatuskaSupported keywords include: 402*caf54c4fSMartin Matuska.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , 403*caf54c4fSMartin Matuska.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , 404*caf54c4fSMartin Matuska.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname . 405*caf54c4fSMartin MatuskaThe default is equivalent to: 406*caf54c4fSMartin Matuska.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname . 407*caf54c4fSMartin Matuska.It Cm mtree:all 408*caf54c4fSMartin MatuskaEnables all of the above keywords. 409*caf54c4fSMartin MatuskaYou can also use 410*caf54c4fSMartin Matuska.Cm mtree:!all 411*caf54c4fSMartin Matuskato disable all keywords. 412*caf54c4fSMartin Matuska.It Cm mtree:use-set 413*caf54c4fSMartin MatuskaEnable generation of 414*caf54c4fSMartin Matuska.Cm /set 415*caf54c4fSMartin Matuskalines in the output. 416*caf54c4fSMartin Matuska.It Cm mtree:indent 417*caf54c4fSMartin MatuskaProduce human-readable output by indenting options and splitting lines 418*caf54c4fSMartin Matuskato fit into 80 columns. 419*caf54c4fSMartin Matuska.It Cm zip:compression Ns = Ns Ar type 420*caf54c4fSMartin MatuskaUse 421*caf54c4fSMartin Matuska.Ar type 422*caf54c4fSMartin Matuskaas compression method. 423*caf54c4fSMartin MatuskaSupported values are store (uncompressed) and deflate (gzip algorithm). 424*caf54c4fSMartin Matuska.El 425*caf54c4fSMartin MatuskaIf a provided option is not supported by any module, that 426*caf54c4fSMartin Matuskais a fatal error. 427*caf54c4fSMartin Matuska.It Fl P 428*caf54c4fSMartin MatuskaPreserve pathnames. 429*caf54c4fSMartin MatuskaBy default, absolute pathnames (those that begin with a / 430*caf54c4fSMartin Matuskacharacter) have the leading slash removed both when creating archives 431*caf54c4fSMartin Matuskaand extracting from them. 432*caf54c4fSMartin MatuskaAlso, 433*caf54c4fSMartin Matuska.Nm 434*caf54c4fSMartin Matuskawill refuse to extract archive entries whose pathnames contain 435*caf54c4fSMartin Matuska.Pa .. 436*caf54c4fSMartin Matuskaor whose target directory would be altered by a symlink. 437*caf54c4fSMartin MatuskaThis option suppresses these behaviors. 438*caf54c4fSMartin Matuska.It Fl p 439*caf54c4fSMartin Matuska(x mode only) 440*caf54c4fSMartin MatuskaPreserve file permissions. 441*caf54c4fSMartin MatuskaAttempt to restore the full permissions, including owner, file modes, file 442*caf54c4fSMartin Matuskaflags and ACLs, if available, for each item extracted from the archive. 443*caf54c4fSMartin MatuskaBy default, newly-created files are owned by the user running 444*caf54c4fSMartin Matuska.Nm , 445*caf54c4fSMartin Matuskathe file mode is restored for newly-created regular files, and 446*caf54c4fSMartin Matuskaall other types of entries receive default permissions. 447*caf54c4fSMartin MatuskaIf 448*caf54c4fSMartin Matuska.Nm 449*caf54c4fSMartin Matuskais being run by root, the default is to restore the owner unless the 450*caf54c4fSMartin Matuska.Fl o 451*caf54c4fSMartin Matuskaoption is also specified. 452*caf54c4fSMartin Matuska.It Fl q ( Fl -fast-read ) 453*caf54c4fSMartin Matuska(x and t mode only) 454*caf54c4fSMartin MatuskaExtract or list only the first archive entry that matches each pattern 455*caf54c4fSMartin Matuskaor filename operand. 456*caf54c4fSMartin MatuskaExit as soon as each specified pattern or filename has been matched. 457*caf54c4fSMartin MatuskaBy default, the archive is always read to the very end, since 458*caf54c4fSMartin Matuskathere can be multiple entries with the same name and, by convention, 459*caf54c4fSMartin Matuskalater entries overwrite earlier entries. 460*caf54c4fSMartin MatuskaThis option is provided as a performance optimization. 461*caf54c4fSMartin Matuska.It Fl S 462*caf54c4fSMartin Matuska(x mode only) 463*caf54c4fSMartin MatuskaExtract files as sparse files. 464*caf54c4fSMartin MatuskaFor every block on disk, check first if it contains only NULL bytes and seek 465*caf54c4fSMartin Matuskaover it otherwise. 466*caf54c4fSMartin MatuskaThis works similiar to the conv=sparse option of dd. 467*caf54c4fSMartin Matuska.It Fl -strip-components Ar count 468*caf54c4fSMartin Matuska(x mode only) 469*caf54c4fSMartin MatuskaRemove the specified number of leading path elements. 470*caf54c4fSMartin MatuskaPathnames with fewer elements will be silently skipped. 471*caf54c4fSMartin MatuskaNote that the pathname is edited after checking inclusion/exclusion patterns 472*caf54c4fSMartin Matuskabut before security checks. 473*caf54c4fSMartin Matuska.It Fl s Ar pattern 474*caf54c4fSMartin MatuskaModify file or archive member names according to 475*caf54c4fSMartin Matuska.Pa pattern . 476*caf54c4fSMartin MatuskaThe pattern has the format 477*caf54c4fSMartin Matuska.Ar /old/new/ Ns Op gps 478*caf54c4fSMartin Matuskawhere 479*caf54c4fSMartin Matuska.Ar old 480*caf54c4fSMartin Matuskais a basic regular expression, 481*caf54c4fSMartin Matuska.Ar new 482*caf54c4fSMartin Matuskais the replacement string of the matched part, 483*caf54c4fSMartin Matuskaand the optional trailing letters modify 484*caf54c4fSMartin Matuskahow the replacement is handled. 485*caf54c4fSMartin MatuskaIf 486*caf54c4fSMartin Matuska.Ar old 487*caf54c4fSMartin Matuskais not matched, the pattern is skipped. 488*caf54c4fSMartin MatuskaWithin 489*caf54c4fSMartin Matuska.Ar new , 490*caf54c4fSMartin Matuska~ is substituted with the match, \e1 to \e9 with the content of 491*caf54c4fSMartin Matuskathe corresponding captured group. 492*caf54c4fSMartin MatuskaThe optional trailing g specifies that matching should continue 493*caf54c4fSMartin Matuskaafter the matched part and stopped on the first unmatched pattern. 494*caf54c4fSMartin MatuskaThe optional trailing s specifies that the pattern applies to the value 495*caf54c4fSMartin Matuskaof symbolic links. 496*caf54c4fSMartin MatuskaThe optional trailing p specifies that after a successful substitution 497*caf54c4fSMartin Matuskathe original path name and the new path name should be printed to 498*caf54c4fSMartin Matuskastandard error. 499*caf54c4fSMartin Matuska.It Fl T Ar filename 500*caf54c4fSMartin MatuskaIn x or t mode, 501*caf54c4fSMartin Matuska.Nm 502*caf54c4fSMartin Matuskawill read the list of names to be extracted from 503*caf54c4fSMartin Matuska.Pa filename . 504*caf54c4fSMartin MatuskaIn c mode, 505*caf54c4fSMartin Matuska.Nm 506*caf54c4fSMartin Matuskawill read names to be archived from 507*caf54c4fSMartin Matuska.Pa filename . 508*caf54c4fSMartin MatuskaThe special name 509*caf54c4fSMartin Matuska.Dq -C 510*caf54c4fSMartin Matuskaon a line by itself will cause the current directory to be changed to 511*caf54c4fSMartin Matuskathe directory specified on the following line. 512*caf54c4fSMartin MatuskaNames are terminated by newlines unless 513*caf54c4fSMartin Matuska.Fl -null 514*caf54c4fSMartin Matuskais specified. 515*caf54c4fSMartin MatuskaNote that 516*caf54c4fSMartin Matuska.Fl -null 517*caf54c4fSMartin Matuskaalso disables the special handling of lines containing 518*caf54c4fSMartin Matuska.Dq -C . 519*caf54c4fSMartin Matuska.It Fl U 520*caf54c4fSMartin Matuska(x mode only) 521*caf54c4fSMartin MatuskaUnlink files before creating them. 522*caf54c4fSMartin MatuskaWithout this option, 523*caf54c4fSMartin Matuska.Nm 524*caf54c4fSMartin Matuskaoverwrites existing files, which preserves existing hardlinks. 525*caf54c4fSMartin MatuskaWith this option, existing hardlinks will be broken, as will any 526*caf54c4fSMartin Matuskasymlink that would affect the location of an extracted file. 527*caf54c4fSMartin Matuska.It Fl Fl uid Ar id 528*caf54c4fSMartin MatuskaUse the provided user id number and ignore the user 529*caf54c4fSMartin Matuskaname from the archive. 530*caf54c4fSMartin MatuskaOn create, if 531*caf54c4fSMartin Matuska.Fl Fl uname 532*caf54c4fSMartin Matuskais not also specified, the user name will be set to 533*caf54c4fSMartin Matuskamatch the user id. 534*caf54c4fSMartin Matuska.It Fl Fl uname Ar name 535*caf54c4fSMartin MatuskaUse the provided user name. 536*caf54c4fSMartin MatuskaOn extract, this overrides the user name in the archive; 537*caf54c4fSMartin Matuskaif the provided user name does not exist on the system, 538*caf54c4fSMartin Matuskait will be ignored and the user id 539*caf54c4fSMartin Matuska(from the archive or from the 540*caf54c4fSMartin Matuska.Fl Fl uid 541*caf54c4fSMartin Matuskaoption) 542*caf54c4fSMartin Matuskawill be used instead. 543*caf54c4fSMartin MatuskaOn create, this sets the user name that will be stored 544*caf54c4fSMartin Matuskain the archive; 545*caf54c4fSMartin Matuskathe name is not verified against the system user database. 546*caf54c4fSMartin Matuska.It Fl Fl use-compress-program Ar program 547*caf54c4fSMartin MatuskaPipe the input (in x or t mode) or the output (in c mode) through 548*caf54c4fSMartin Matuska.Pa program 549*caf54c4fSMartin Matuskainstead of using the builtin compression support. 550*caf54c4fSMartin Matuska.It Fl v 551*caf54c4fSMartin MatuskaProduce verbose output. 552*caf54c4fSMartin MatuskaIn create and extract modes, 553*caf54c4fSMartin Matuska.Nm 554*caf54c4fSMartin Matuskawill list each file name as it is read from or written to 555*caf54c4fSMartin Matuskathe archive. 556*caf54c4fSMartin MatuskaIn list mode, 557*caf54c4fSMartin Matuska.Nm 558*caf54c4fSMartin Matuskawill produce output similar to that of 559*caf54c4fSMartin Matuska.Xr ls 1 . 560*caf54c4fSMartin MatuskaAdditional 561*caf54c4fSMartin Matuska.Fl v 562*caf54c4fSMartin Matuskaoptions will provide additional detail. 563*caf54c4fSMartin Matuska.It Fl -version 564*caf54c4fSMartin MatuskaPrint version of 565*caf54c4fSMartin Matuska.Nm 566*caf54c4fSMartin Matuskaand 567*caf54c4fSMartin Matuska.Nm libarchive , 568*caf54c4fSMartin Matuskaand exit. 569*caf54c4fSMartin Matuska.It Fl w 570*caf54c4fSMartin MatuskaAsk for confirmation for every action. 571*caf54c4fSMartin Matuska.It Fl X Ar filename 572*caf54c4fSMartin MatuskaRead a list of exclusion patterns from the specified file. 573*caf54c4fSMartin MatuskaSee 574*caf54c4fSMartin Matuska.Fl -exclude 575*caf54c4fSMartin Matuskafor more information about the handling of exclusions. 576*caf54c4fSMartin Matuska.It Fl y 577*caf54c4fSMartin Matuska(c mode only) 578*caf54c4fSMartin MatuskaCompress the resulting archive with 579*caf54c4fSMartin Matuska.Xr bzip2 1 . 580*caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 581*caf54c4fSMartin MatuskaNote that, unlike other 582*caf54c4fSMartin Matuska.Nm tar 583*caf54c4fSMartin Matuskaimplementations, this implementation recognizes bzip2 compression 584*caf54c4fSMartin Matuskaautomatically when reading archives. 585*caf54c4fSMartin Matuska.It Fl z 586*caf54c4fSMartin Matuska(c mode only) 587*caf54c4fSMartin MatuskaCompress the resulting archive with 588*caf54c4fSMartin Matuska.Xr gzip 1 . 589*caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 590*caf54c4fSMartin MatuskaNote that, unlike other 591*caf54c4fSMartin Matuska.Nm tar 592*caf54c4fSMartin Matuskaimplementations, this implementation recognizes gzip compression 593*caf54c4fSMartin Matuskaautomatically when reading archives. 594*caf54c4fSMartin Matuska.It Fl Z 595*caf54c4fSMartin Matuska(c mode only) 596*caf54c4fSMartin MatuskaCompress the resulting archive with 597*caf54c4fSMartin Matuska.Xr compress 1 . 598*caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored. 599*caf54c4fSMartin MatuskaNote that, unlike other 600*caf54c4fSMartin Matuska.Nm tar 601*caf54c4fSMartin Matuskaimplementations, this implementation recognizes compress compression 602*caf54c4fSMartin Matuskaautomatically when reading archives. 603*caf54c4fSMartin Matuska.El 604*caf54c4fSMartin Matuska.Sh EXIT STATUS 605*caf54c4fSMartin Matuska.Ex -std 606*caf54c4fSMartin Matuska.Sh ENVIRONMENT 607*caf54c4fSMartin MatuskaThe following environment variables affect the execution of 608*caf54c4fSMartin Matuska.Nm : 609*caf54c4fSMartin Matuska.Bl -tag -width ".Ev BLOCKSIZE" 610*caf54c4fSMartin Matuska.It Ev LANG 611*caf54c4fSMartin MatuskaThe locale to use. 612*caf54c4fSMartin MatuskaSee 613*caf54c4fSMartin Matuska.Xr environ 7 614*caf54c4fSMartin Matuskafor more information. 615*caf54c4fSMartin Matuska.It Ev TAPE 616*caf54c4fSMartin MatuskaThe default tape device. 617*caf54c4fSMartin MatuskaThe 618*caf54c4fSMartin Matuska.Fl f 619*caf54c4fSMartin Matuskaoption overrides this. 620*caf54c4fSMartin Matuska.It Ev TZ 621*caf54c4fSMartin MatuskaThe timezone to use when displaying dates. 622*caf54c4fSMartin MatuskaSee 623*caf54c4fSMartin Matuska.Xr environ 7 624*caf54c4fSMartin Matuskafor more information. 625*caf54c4fSMartin Matuska.El 626*caf54c4fSMartin Matuska.Sh FILES 627*caf54c4fSMartin Matuska.Bl -tag -width ".Ev BLOCKSIZE" 628*caf54c4fSMartin Matuska.It Pa /dev/sa0 629*caf54c4fSMartin MatuskaThe default tape device, if not overridden by the 630*caf54c4fSMartin Matuska.Ev TAPE 631*caf54c4fSMartin Matuskaenvironment variable or the 632*caf54c4fSMartin Matuska.Fl f 633*caf54c4fSMartin Matuskaoption. 634*caf54c4fSMartin Matuska.El 635*caf54c4fSMartin Matuska.Sh EXAMPLES 636*caf54c4fSMartin MatuskaThe following creates a new archive 637*caf54c4fSMartin Matuskacalled 638*caf54c4fSMartin Matuska.Ar file.tar.gz 639*caf54c4fSMartin Matuskathat contains two files 640*caf54c4fSMartin Matuska.Ar source.c 641*caf54c4fSMartin Matuskaand 642*caf54c4fSMartin Matuska.Ar source.h : 643*caf54c4fSMartin Matuska.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h 644*caf54c4fSMartin Matuska.Pp 645*caf54c4fSMartin MatuskaTo view a detailed table of contents for this 646*caf54c4fSMartin Matuskaarchive: 647*caf54c4fSMartin Matuska.Dl Nm Fl tvf Pa file.tar.gz 648*caf54c4fSMartin Matuska.Pp 649*caf54c4fSMartin MatuskaTo extract all entries from the archive on 650*caf54c4fSMartin Matuskathe default tape drive: 651*caf54c4fSMartin Matuska.Dl Nm Fl x 652*caf54c4fSMartin Matuska.Pp 653*caf54c4fSMartin MatuskaTo examine the contents of an ISO 9660 cdrom image: 654*caf54c4fSMartin Matuska.Dl Nm Fl tf Pa image.iso 655*caf54c4fSMartin Matuska.Pp 656*caf54c4fSMartin MatuskaTo move file hierarchies, invoke 657*caf54c4fSMartin Matuska.Nm 658*caf54c4fSMartin Matuskaas 659*caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir 660*caf54c4fSMartin Matuskaor more traditionally 661*caf54c4fSMartin Matuska.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - ) 662*caf54c4fSMartin Matuska.Pp 663*caf54c4fSMartin MatuskaIn create mode, the list of files and directories to be archived 664*caf54c4fSMartin Matuskacan also include directory change instructions of the form 665*caf54c4fSMartin Matuska.Cm -C Ns Pa foo/baz 666*caf54c4fSMartin Matuskaand archive inclusions of the form 667*caf54c4fSMartin Matuska.Cm @ Ns Pa archive-file . 668*caf54c4fSMartin MatuskaFor example, the command line 669*caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2 670*caf54c4fSMartin Matuskawill create a new archive 671*caf54c4fSMartin Matuska.Pa new.tar . 672*caf54c4fSMartin Matuska.Nm 673*caf54c4fSMartin Matuskawill read the file 674*caf54c4fSMartin Matuska.Pa foo1 675*caf54c4fSMartin Matuskafrom the current directory and add it to the output archive. 676*caf54c4fSMartin MatuskaIt will then read each entry from 677*caf54c4fSMartin Matuska.Pa old.tgz 678*caf54c4fSMartin Matuskaand add those entries to the output archive. 679*caf54c4fSMartin MatuskaFinally, it will switch to the 680*caf54c4fSMartin Matuska.Pa /tmp 681*caf54c4fSMartin Matuskadirectory and add 682*caf54c4fSMartin Matuska.Pa foo2 683*caf54c4fSMartin Matuskato the output archive. 684*caf54c4fSMartin Matuska.Pp 685*caf54c4fSMartin MatuskaAn input file in 686*caf54c4fSMartin Matuska.Xr mtree 5 687*caf54c4fSMartin Matuskaformat can be used to create an output archive with arbitrary ownership, 688*caf54c4fSMartin Matuskapermissions, or names that differ from existing data on disk: 689*caf54c4fSMartin Matuska.Pp 690*caf54c4fSMartin Matuska.Dl $ cat input.mtree 691*caf54c4fSMartin Matuska.Dl #mtree 692*caf54c4fSMartin Matuska.Dl usr/bin uid=0 gid=0 mode=0755 type=dir 693*caf54c4fSMartin Matuska.Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls 694*caf54c4fSMartin Matuska.Dl $ tar -cvf output.tar @input.mtree 695*caf54c4fSMartin Matuska.Pp 696*caf54c4fSMartin MatuskaThe 697*caf54c4fSMartin Matuska.Fl -newer 698*caf54c4fSMartin Matuskaand 699*caf54c4fSMartin Matuska.Fl -newer-mtime 700*caf54c4fSMartin Matuskaswitches accept a variety of common date and time specifications, including 701*caf54c4fSMartin Matuska.Dq 12 Mar 2005 7:14:29pm , 702*caf54c4fSMartin Matuska.Dq 2005-03-12 19:14 , 703*caf54c4fSMartin Matuska.Dq 5 minutes ago , 704*caf54c4fSMartin Matuskaand 705*caf54c4fSMartin Matuska.Dq 19:14 PST May 1 . 706*caf54c4fSMartin Matuska.Pp 707*caf54c4fSMartin MatuskaThe 708*caf54c4fSMartin Matuska.Fl -options 709*caf54c4fSMartin Matuskaargument can be used to control various details of archive generation 710*caf54c4fSMartin Matuskaor reading. 711*caf54c4fSMartin MatuskaFor example, you can generate mtree output which only contains 712*caf54c4fSMartin Matuska.Cm type , Cm time , 713*caf54c4fSMartin Matuskaand 714*caf54c4fSMartin Matuska.Cm uid 715*caf54c4fSMartin Matuskakeywords: 716*caf54c4fSMartin Matuska.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa dir 717*caf54c4fSMartin Matuskaor you can set the compression level used by gzip or xz compression: 718*caf54c4fSMartin Matuska.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' . 719*caf54c4fSMartin MatuskaFor more details, see the explanation of the 720*caf54c4fSMartin Matuska.Fn archive_read_set_options 721*caf54c4fSMartin Matuskaand 722*caf54c4fSMartin Matuska.Fn archive_write_set_options 723*caf54c4fSMartin MatuskaAPI calls that are described in 724*caf54c4fSMartin Matuska.Xr archive_read 3 725*caf54c4fSMartin Matuskaand 726*caf54c4fSMartin Matuska.Xr archive_write 3 . 727*caf54c4fSMartin Matuska.Sh COMPATIBILITY 728*caf54c4fSMartin MatuskaThe bundled-arguments format is supported for compatibility 729*caf54c4fSMartin Matuskawith historic implementations. 730*caf54c4fSMartin MatuskaIt consists of an initial word (with no leading - character) in which 731*caf54c4fSMartin Matuskaeach character indicates an option. 732*caf54c4fSMartin MatuskaArguments follow as separate words. 733*caf54c4fSMartin MatuskaThe order of the arguments must match the order 734*caf54c4fSMartin Matuskaof the corresponding characters in the bundled command word. 735*caf54c4fSMartin MatuskaFor example, 736*caf54c4fSMartin Matuska.Dl Nm Cm tbf 32 Pa file.tar 737*caf54c4fSMartin Matuskaspecifies three flags 738*caf54c4fSMartin Matuska.Cm t , 739*caf54c4fSMartin Matuska.Cm b , 740*caf54c4fSMartin Matuskaand 741*caf54c4fSMartin Matuska.Cm f . 742*caf54c4fSMartin MatuskaThe 743*caf54c4fSMartin Matuska.Cm b 744*caf54c4fSMartin Matuskaand 745*caf54c4fSMartin Matuska.Cm f 746*caf54c4fSMartin Matuskaflags both require arguments, 747*caf54c4fSMartin Matuskaso there must be two additional items 748*caf54c4fSMartin Matuskaon the command line. 749*caf54c4fSMartin MatuskaThe 750*caf54c4fSMartin Matuska.Ar 32 751*caf54c4fSMartin Matuskais the argument to the 752*caf54c4fSMartin Matuska.Cm b 753*caf54c4fSMartin Matuskaflag, and 754*caf54c4fSMartin Matuska.Ar file.tar 755*caf54c4fSMartin Matuskais the argument to the 756*caf54c4fSMartin Matuska.Cm f 757*caf54c4fSMartin Matuskaflag. 758*caf54c4fSMartin Matuska.Pp 759*caf54c4fSMartin MatuskaThe mode options c, r, t, u, and x and the options 760*caf54c4fSMartin Matuskab, f, l, m, o, v, and w comply with SUSv2. 761*caf54c4fSMartin Matuska.Pp 762*caf54c4fSMartin MatuskaFor maximum portability, scripts that invoke 763*caf54c4fSMartin Matuska.Nm tar 764*caf54c4fSMartin Matuskashould use the bundled-argument format above, should limit 765*caf54c4fSMartin Matuskathemselves to the 766*caf54c4fSMartin Matuska.Cm c , 767*caf54c4fSMartin Matuska.Cm t , 768*caf54c4fSMartin Matuskaand 769*caf54c4fSMartin Matuska.Cm x 770*caf54c4fSMartin Matuskamodes, and the 771*caf54c4fSMartin Matuska.Cm b , 772*caf54c4fSMartin Matuska.Cm f , 773*caf54c4fSMartin Matuska.Cm m , 774*caf54c4fSMartin Matuska.Cm v , 775*caf54c4fSMartin Matuskaand 776*caf54c4fSMartin Matuska.Cm w 777*caf54c4fSMartin Matuskaoptions. 778*caf54c4fSMartin Matuska.Pp 779*caf54c4fSMartin MatuskaAdditional long options are provided to improve compatibility with other 780*caf54c4fSMartin Matuskatar implementations. 781*caf54c4fSMartin Matuska.Sh SECURITY 782*caf54c4fSMartin MatuskaCertain security issues are common to many archiving programs, including 783*caf54c4fSMartin Matuska.Nm . 784*caf54c4fSMartin MatuskaIn particular, carefully-crafted archives can request that 785*caf54c4fSMartin Matuska.Nm 786*caf54c4fSMartin Matuskaextract files to locations outside of the target directory. 787*caf54c4fSMartin MatuskaThis can potentially be used to cause unwitting users to overwrite 788*caf54c4fSMartin Matuskafiles they did not intend to overwrite. 789*caf54c4fSMartin MatuskaIf the archive is being extracted by the superuser, any file 790*caf54c4fSMartin Matuskaon the system can potentially be overwritten. 791*caf54c4fSMartin MatuskaThere are three ways this can happen. 792*caf54c4fSMartin MatuskaAlthough 793*caf54c4fSMartin Matuska.Nm 794*caf54c4fSMartin Matuskahas mechanisms to protect against each one, 795*caf54c4fSMartin Matuskasavvy users should be aware of the implications: 796*caf54c4fSMartin Matuska.Bl -bullet -width indent 797*caf54c4fSMartin Matuska.It 798*caf54c4fSMartin MatuskaArchive entries can have absolute pathnames. 799*caf54c4fSMartin MatuskaBy default, 800*caf54c4fSMartin Matuska.Nm 801*caf54c4fSMartin Matuskaremoves the leading 802*caf54c4fSMartin Matuska.Pa / 803*caf54c4fSMartin Matuskacharacter from filenames before restoring them to guard against this problem. 804*caf54c4fSMartin Matuska.It 805*caf54c4fSMartin MatuskaArchive entries can have pathnames that include 806*caf54c4fSMartin Matuska.Pa .. 807*caf54c4fSMartin Matuskacomponents. 808*caf54c4fSMartin MatuskaBy default, 809*caf54c4fSMartin Matuska.Nm 810*caf54c4fSMartin Matuskawill not extract files containing 811*caf54c4fSMartin Matuska.Pa .. 812*caf54c4fSMartin Matuskacomponents in their pathname. 813*caf54c4fSMartin Matuska.It 814*caf54c4fSMartin MatuskaArchive entries can exploit symbolic links to restore 815*caf54c4fSMartin Matuskafiles to other directories. 816*caf54c4fSMartin MatuskaAn archive can restore a symbolic link to another directory, 817*caf54c4fSMartin Matuskathen use that link to restore a file into that directory. 818*caf54c4fSMartin MatuskaTo guard against this, 819*caf54c4fSMartin Matuska.Nm 820*caf54c4fSMartin Matuskachecks each extracted path for symlinks. 821*caf54c4fSMartin MatuskaIf the final path element is a symlink, it will be removed 822*caf54c4fSMartin Matuskaand replaced with the archive entry. 823*caf54c4fSMartin MatuskaIf 824*caf54c4fSMartin Matuska.Fl U 825*caf54c4fSMartin Matuskais specified, any intermediate symlink will also be unconditionally removed. 826*caf54c4fSMartin MatuskaIf neither 827*caf54c4fSMartin Matuska.Fl U 828*caf54c4fSMartin Matuskanor 829*caf54c4fSMartin Matuska.Fl P 830*caf54c4fSMartin Matuskais specified, 831*caf54c4fSMartin Matuska.Nm 832*caf54c4fSMartin Matuskawill refuse to extract the entry. 833*caf54c4fSMartin Matuska.El 834*caf54c4fSMartin MatuskaTo protect yourself, you should be wary of any archives that 835*caf54c4fSMartin Matuskacome from untrusted sources. 836*caf54c4fSMartin MatuskaYou should examine the contents of an archive with 837*caf54c4fSMartin Matuska.Dl Nm Fl tf Pa filename 838*caf54c4fSMartin Matuskabefore extraction. 839*caf54c4fSMartin MatuskaYou should use the 840*caf54c4fSMartin Matuska.Fl k 841*caf54c4fSMartin Matuskaoption to ensure that 842*caf54c4fSMartin Matuska.Nm 843*caf54c4fSMartin Matuskawill not overwrite any existing files or the 844*caf54c4fSMartin Matuska.Fl U 845*caf54c4fSMartin Matuskaoption to remove any pre-existing files. 846*caf54c4fSMartin MatuskaYou should generally not extract archives while running with super-user 847*caf54c4fSMartin Matuskaprivileges. 848*caf54c4fSMartin MatuskaNote that the 849*caf54c4fSMartin Matuska.Fl P 850*caf54c4fSMartin Matuskaoption to 851*caf54c4fSMartin Matuska.Nm 852*caf54c4fSMartin Matuskadisables the security checks above and allows you to extract 853*caf54c4fSMartin Matuskaan archive while preserving any absolute pathnames, 854*caf54c4fSMartin Matuska.Pa .. 855*caf54c4fSMartin Matuskacomponents, or symlinks to other directories. 856*caf54c4fSMartin Matuska.Sh SEE ALSO 857*caf54c4fSMartin Matuska.Xr bzip2 1 , 858*caf54c4fSMartin Matuska.Xr compress 1 , 859*caf54c4fSMartin Matuska.Xr cpio 1 , 860*caf54c4fSMartin Matuska.Xr gzip 1 , 861*caf54c4fSMartin Matuska.Xr mt 1 , 862*caf54c4fSMartin Matuska.Xr pax 1 , 863*caf54c4fSMartin Matuska.Xr shar 1 , 864*caf54c4fSMartin Matuska.Xr libarchive 3 , 865*caf54c4fSMartin Matuska.Xr libarchive-formats 5 , 866*caf54c4fSMartin Matuska.Xr tar 5 867*caf54c4fSMartin Matuska.Sh STANDARDS 868*caf54c4fSMartin MatuskaThere is no current POSIX standard for the tar command; it appeared 869*caf54c4fSMartin Matuskain 870*caf54c4fSMartin Matuska.St -p1003.1-96 871*caf54c4fSMartin Matuskabut was dropped from 872*caf54c4fSMartin Matuska.St -p1003.1-2001 . 873*caf54c4fSMartin MatuskaThe options used by this implementation were developed by surveying a 874*caf54c4fSMartin Matuskanumber of existing tar implementations as well as the old POSIX specification 875*caf54c4fSMartin Matuskafor tar and the current POSIX specification for pax. 876*caf54c4fSMartin Matuska.Pp 877*caf54c4fSMartin MatuskaThe ustar and pax interchange file formats are defined by 878*caf54c4fSMartin Matuska.St -p1003.1-2001 879*caf54c4fSMartin Matuskafor the pax command. 880*caf54c4fSMartin Matuska.Sh HISTORY 881*caf54c4fSMartin MatuskaA 882*caf54c4fSMartin Matuska.Nm tar 883*caf54c4fSMartin Matuskacommand appeared in Seventh Edition Unix, which was released in January, 1979. 884*caf54c4fSMartin MatuskaThere have been numerous other implementations, 885*caf54c4fSMartin Matuskamany of which extended the file format. 886*caf54c4fSMartin MatuskaJohn Gilmore's 887*caf54c4fSMartin Matuska.Nm pdtar 888*caf54c4fSMartin Matuskapublic-domain implementation (circa November, 1987) 889*caf54c4fSMartin Matuskawas quite influential, and formed the basis of GNU tar. 890*caf54c4fSMartin MatuskaGNU tar was included as the standard system tar 891*caf54c4fSMartin Matuskain 892*caf54c4fSMartin Matuska.Fx 893*caf54c4fSMartin Matuskabeginning with 894*caf54c4fSMartin Matuska.Fx 1.0 . 895*caf54c4fSMartin Matuska.Pp 896*caf54c4fSMartin MatuskaThis is a complete re-implementation based on the 897*caf54c4fSMartin Matuska.Xr libarchive 3 898*caf54c4fSMartin Matuskalibrary. 899*caf54c4fSMartin Matuska.Sh BUGS 900*caf54c4fSMartin MatuskaThis program follows 901*caf54c4fSMartin Matuska.St -p1003.1-96 902*caf54c4fSMartin Matuskafor the definition of the 903*caf54c4fSMartin Matuska.Fl l 904*caf54c4fSMartin Matuskaoption. 905*caf54c4fSMartin MatuskaNote that GNU tar prior to version 1.15 treated 906*caf54c4fSMartin Matuska.Fl l 907*caf54c4fSMartin Matuskaas a synonym for the 908*caf54c4fSMartin Matuska.Fl -one-file-system 909*caf54c4fSMartin Matuskaoption. 910*caf54c4fSMartin Matuska.Pp 911*caf54c4fSMartin MatuskaThe 912*caf54c4fSMartin Matuska.Fl C Pa dir 913*caf54c4fSMartin Matuskaoption may differ from historic implementations. 914*caf54c4fSMartin Matuska.Pp 915*caf54c4fSMartin MatuskaAll archive output is written in correctly-sized blocks, even 916*caf54c4fSMartin Matuskaif the output is being compressed. 917*caf54c4fSMartin MatuskaWhether or not the last output block is padded to a full 918*caf54c4fSMartin Matuskablock size varies depending on the format and the 919*caf54c4fSMartin Matuskaoutput device. 920*caf54c4fSMartin MatuskaFor tar and cpio formats, the last block of output is padded 921*caf54c4fSMartin Matuskato a full block size if the output is being 922*caf54c4fSMartin Matuskawritten to standard output or to a character or block device such as 923*caf54c4fSMartin Matuskaa tape drive. 924*caf54c4fSMartin MatuskaIf the output is being written to a regular file, the last block 925*caf54c4fSMartin Matuskawill not be padded. 926*caf54c4fSMartin MatuskaMany compressors, including 927*caf54c4fSMartin Matuska.Xr gzip 1 928*caf54c4fSMartin Matuskaand 929*caf54c4fSMartin Matuska.Xr bzip2 1 , 930*caf54c4fSMartin Matuskacomplain about the null padding when decompressing an archive created by 931*caf54c4fSMartin Matuska.Nm , 932*caf54c4fSMartin Matuskaalthough they still extract it correctly. 933*caf54c4fSMartin Matuska.Pp 934*caf54c4fSMartin MatuskaThe compression and decompression is implemented internally, so 935*caf54c4fSMartin Matuskathere may be insignificant differences between the compressed output 936*caf54c4fSMartin Matuskagenerated by 937*caf54c4fSMartin Matuska.Dl Nm Fl czf Pa - file 938*caf54c4fSMartin Matuskaand that generated by 939*caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - file | Nm gzip 940*caf54c4fSMartin Matuska.Pp 941*caf54c4fSMartin MatuskaThe default should be to read and write archives to the standard I/O paths, 942*caf54c4fSMartin Matuskabut tradition (and POSIX) dictates otherwise. 943*caf54c4fSMartin Matuska.Pp 944*caf54c4fSMartin MatuskaThe 945*caf54c4fSMartin Matuska.Cm r 946*caf54c4fSMartin Matuskaand 947*caf54c4fSMartin Matuska.Cm u 948*caf54c4fSMartin Matuskamodes require that the archive be uncompressed 949*caf54c4fSMartin Matuskaand located in a regular file on disk. 950*caf54c4fSMartin MatuskaOther archives can be modified using 951*caf54c4fSMartin Matuska.Cm c 952*caf54c4fSMartin Matuskamode with the 953*caf54c4fSMartin Matuska.Pa @archive-file 954*caf54c4fSMartin Matuskaextension. 955*caf54c4fSMartin Matuska.Pp 956*caf54c4fSMartin MatuskaTo archive a file called 957*caf54c4fSMartin Matuska.Pa @foo 958*caf54c4fSMartin Matuskaor 959*caf54c4fSMartin Matuska.Pa -foo 960*caf54c4fSMartin Matuskayou must specify it as 961*caf54c4fSMartin Matuska.Pa ./@foo 962*caf54c4fSMartin Matuskaor 963*caf54c4fSMartin Matuska.Pa ./-foo , 964*caf54c4fSMartin Matuskarespectively. 965*caf54c4fSMartin Matuska.Pp 966*caf54c4fSMartin MatuskaIn create mode, a leading 967*caf54c4fSMartin Matuska.Pa ./ 968*caf54c4fSMartin Matuskais always removed. 969*caf54c4fSMartin MatuskaA leading 970*caf54c4fSMartin Matuska.Pa / 971*caf54c4fSMartin Matuskais stripped unless the 972*caf54c4fSMartin Matuska.Fl P 973*caf54c4fSMartin Matuskaoption is specified. 974*caf54c4fSMartin Matuska.Pp 975*caf54c4fSMartin MatuskaThere needs to be better support for file selection on both create 976*caf54c4fSMartin Matuskaand extract. 977*caf54c4fSMartin Matuska.Pp 978*caf54c4fSMartin MatuskaThere is not yet any support for multi-volume archives or for archiving 979*caf54c4fSMartin Matuskasparse files. 980*caf54c4fSMartin Matuska.Pp 981*caf54c4fSMartin MatuskaConverting between dissimilar archive formats (such as tar and cpio) using the 982*caf54c4fSMartin Matuska.Cm @ Ns Pa - 983*caf54c4fSMartin Matuskaconvention can cause hard link information to be lost. 984*caf54c4fSMartin Matuska(This is a consequence of the incompatible ways that different archive 985*caf54c4fSMartin Matuskaformats store hardlink information.) 986*caf54c4fSMartin Matuska.Pp 987*caf54c4fSMartin MatuskaThere are alternative long options for many of the short options that 988*caf54c4fSMartin Matuskaare deliberately not documented. 989