1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
TAR(1) BSD General Commands Manual TAR(1)
1mNAME0m
1mtar 22m— manipulate tape archives
1mSYNOPSIS0m
1mtar 22m[4mbundled-flags24m ⟨args⟩] [⟨4mfile24m⟩ | ⟨4mpattern24m⟩ ...]
1mtar 22m{1m-c22m} [4moptions24m] [4mfiles24m | 4mdirectories24m]
1mtar 22m{1m-r 22m| 1m-u22m} 1m-f 4m22marchive-file24m [4moptions24m] [4mfiles24m | 4mdirectories24m]
1mtar 22m{1m-t 22m| 1m-x22m} [4moptions24m] [4mpatterns24m]
1mDESCRIPTION0m
1mtar 22mcreates and manipulates streaming archive files. This implementation
can extract from tar, pax, cpio, zip, jar, ar, xar, rpm, 7-zip, and ISO
9660 cdrom images and can create tar, pax, cpio, ar, zip, 7-zip, and shar
archives.
The first synopsis form shows a “bundled” option word. This usage is
provided for compatibility with historical implementations. See COMPATI‐
BILITY below for details.
The other synopsis forms show the preferred usage. The first option to
1mtar 22mis a mode indicator from the following list:
1m-c 22mCreate a new archive containing the specified items. The long
option form is 1m--create22m.
1m-r 22mLike 1m-c22m, but new entries are appended to the archive. Note that
this only works on uncompressed archives stored in regular files.
The 1m-f 22moption is required. The long option form is 1m--append22m.
1m-t 22mList archive contents to stdout. The long option form is 1m--list22m.
1m-u 22mLike 1m-r22m, but new entries are added only if they have a modifica‐
tion date newer than the corresponding entry in the archive.
Note that this only works on uncompressed archives stored in reg‐
ular files. The 1m-f 22moption is required. The long form is
1m--update22m.
1m-x 22mExtract to disk from the archive. If a file with the same name
appears more than once in the archive, each copy will be
extracted, with later copies overwriting (replacing) earlier
copies. The long option form is 1m--extract22m.
In 1m-c22m, 1m-r22m, or 1m-u 22mmode, each specified file or directory is added to the
archive in the order specified on the command line. By default, the con‐
tents of each directory are also archived.
In extract or list mode, the entire command line is read and parsed
before the archive is opened. The pathnames or patterns on the command
line indicate which items in the archive should be processed. Patterns
are shell-style globbing patterns as documented in tcsh(1).
1mOPTIONS0m
Unless specifically stated otherwise, options are applicable in all oper‐
ating modes.
1m@4m22marchive0m
(c and r modes only) The specified archive is opened and the
entries in it will be appended to the current archive. As a sim‐
ple example,
1mtar -c -f 4m22m-24m 4mnewfile24m 1m@4m22moriginal.tar0m
writes a new archive to standard output containing a file 4mnewfile0m
and all of the entries from 4moriginal.tar24m. In contrast,
1mtar -c -f 4m22m-24m 4mnewfile24m 4moriginal.tar0m
creates a new archive with only two entries. Similarly,
1mtar -czf 4m22m-24m 1m--format pax @4m22m-0m
reads an archive from standard input (whose format will be deter‐
mined automatically) and converts it into a gzip-compressed pax-
format archive on stdout. In this way, 1mtar 22mcan be used to con‐
vert archives from one format to another.
1m-a22m, 1m--auto-compress0m
(c mode only) Use the archive suffix to decide a set of the for‐
mat and the compressions. As a simple example,
1mtar -a -cf 4m22marchive.tgz24m 4msource.c24m 4msource.h0m
creates a new archive with restricted pax format and gzip com‐
pression,
1mtar -a -cf 4m22marchive.tar.bz2.uu24m 4msource.c24m 4msource.h0m
creates a new archive with restricted pax format and bzip2 com‐
pression and uuencode compression,
1mtar -a -cf 4m22marchive.zip24m 4msource.c24m 4msource.h0m
creates a new archive with zip format,
1mtar -a -jcf 4m22marchive.tgz24m 4msource.c24m 4msource.h0m
ignores the “-j” option, and creates a new archive with
restricted pax format and gzip compression,
1mtar -a -jcf 4m22marchive.xxx24m 4msource.c24m 4msource.h0m
if it is unknown suffix or no suffix, creates a new archive with
restricted pax format and bzip2 compression.
1m--acls 22m(c, r, u, x modes only) Archive or extract POSIX.1e or NFSv4
ACLs. This is the reverse of 1m--no-acls 22mand the default behavior
in c, r, and u modes (except Mac OS X) or if 1mtar 22mis run in x mode
as root. On Mac OS X this option translates extended ACLs to
NFSv4 ACLs. To store extended ACLs the 1m--mac-metadata 22moption is
preferred.
1m-B22m, 1m--read-full-blocks0m
Ignored for compatibility with other tar(1) implementations.
1m-b 4m22mblocksize24m, 1m--block-size 4m22mblocksize0m
Specify the block size, in 512-byte records, for tape drive I/O.
As a rule, this argument is only needed when reading from or
writing to tape drives, and usually not even then as the default
block size of 20 records (10240 bytes) is very common.
1m-C 4m22mdirectory24m, 1m--cd 4m22mdirectory24m, 1m--directory 4m22mdirectory0m
In c and r mode, this changes the directory before adding the
following files. In x mode, change directories after opening the
archive but before extracting entries from the archive.
1m--chroot0m
(x mode only) 1mchroot22m() to the current directory after processing
any 1m-C 22moptions and before extracting any files.
1m--clear-nochange-fflags0m
(x mode only) Before removing file system objects to replace
them, clear platform-specific file flags that might prevent
removal.
1m--exclude 4m22mpattern0m
Do not process files or directories that match the specified pat‐
tern. Note that exclusions take precedence over patterns or
filenames specified on the command line.
1m--fflags0m
(c, r, u, x modes only) Archive or extract file flags. This is
the reverse of 1m--no-fflags 22mand the default behavior in c, r, and
u modes or if 1mtar 22mis run in x mode as root.
1m--format 4m22mformat0m
(c, r, u mode only) Use the specified format for the created ar‐
chive. Supported formats include “cpio”, “pax”, “shar”, and
“ustar”. Other formats may also be supported; see
libarchive-formats(5) for more information about currently-sup‐
ported formats. In r and u modes, when extending an existing ar‐
chive, the format specified here must be compatible with the for‐
mat of the existing archive on disk.
1m-f 4m22mfile24m, 1m--file 4m22mfile0m
Read the archive from or write the archive to the specified file.
The filename can be 4m-24m for standard input or standard output. The
default varies by system; on FreeBSD, the default is 4m/dev/sa024m; on
Linux, the default is 4m/dev/st024m.
1m--gid 4m22mid0m
Use the provided group id number. On extract, this overrides the
group id in the archive; the group name in the archive will be
ignored. On create, this overrides the group id read from disk;
if 1m--gname 22mis not also specified, the group name will be set to
match the group id.
1m--gname 4m22mname0m
Use the provided group name. On extract, this overrides the
group name in the archive; if the provided group name does not
exist on the system, the group id (from the archive or from the
1m--gid 22moption) will be used instead. On create, this sets the
group name that will be stored in the archive; the name will not
be verified against the system group database.
1m-H 22m(c and r modes only) Symbolic links named on the command line
will be followed; the target of the link will be archived, not
the link itself.
1m-h 22m(c and r modes only) Synonym for 1m-L22m.
1m-I 22mSynonym for 1m-T22m.
1m--help 22mShow usage.
1m--hfsCompression0m
(x mode only) Mac OS X specific (v10.6 or later). Compress
extracted regular files with HFS+ compression.
1m--ignore-zeros0m
An alias of 1m--options read_concatenated_archives 22mfor compatibil‐
ity with GNU tar.
1m--include 4m22mpattern0m
Process only files or directories that match the specified pat‐
tern. Note that exclusions specified with 1m--exclude 22mtake prece‐
dence over inclusions. If no inclusions are explicitly speci‐
fied, all entries are processed by default. The 1m--include 22moption
is especially useful when filtering archives. For example, the
command
1mtar -c -f 4m22mnew.tar24m 1m--include='*foo*' @4m22mold.tgz0m
creates a new archive 4mnew.tar24m containing only the entries from
4mold.tgz24m containing the string ‘foo’.
1m-J22m, 1m--xz0m
(c mode only) Compress the resulting archive with xz(1). In
extract or list modes, this option is ignored. Note that, unlike
other 1mtar 22mimplementations, this implementation recognizes XZ com‐
pression automatically when reading archives.
1m-j22m, 1m--bzip22m, 1m--bzip222m, 1m--bunzip20m
(c mode only) Compress the resulting archive with bzip2(1). In
extract or list modes, this option is ignored. Note that, unlike
other 1mtar 22mimplementations, this implementation recognizes bzip2
compression automatically when reading archives.
1m-k22m, 1m--keep-old-files0m
(x mode only) Do not overwrite existing files. In particular, if
a file appears more than once in an archive, later copies will
not overwrite earlier copies.
1m--keep-newer-files0m
(x mode only) Do not overwrite existing files that are newer than
the versions appearing in the archive being extracted.
1m-L22m, 1m--dereference0m
(c and r modes only) All symbolic links will be followed. Nor‐
mally, symbolic links are archived as such. With this option,
the target of the link will be archived instead.
1m-l22m, 1m--check-links0m
(c and r modes only) Issue a warning message unless all links to
each file are archived.
1m--lrzip0m
(c mode only) Compress the resulting archive with lrzip(1). In
extract or list modes, this option is ignored.
1m--lz4 22m(c mode only) Compress the archive with lz4-compatible compres‐
sion before writing it. In input mode, this option is ignored;
lz4 compression is recognized automatically on input.
1m--lzma 22m(c mode only) Compress the resulting archive with the original
LZMA algorithm. Use of this option is discouraged and new ar‐
chives should be created with 1m--xz 22minstead. Note that, unlike
other 1mtar 22mimplementations, this implementation recognizes LZMA
compression automatically when reading archives.
1m--lzop 22m(c mode only) Compress the resulting archive with lzop(1). In
extract or list modes, this option is ignored.
1m-m22m, 1m--modification-time0m
(x mode only) Do not extract modification time. By default, the
modification time is set to the time stored in the archive.
1m--mac-metadata0m
(c, r, u and x mode only) Mac OS X specific. Archive or extract
extended ACLs and extended attributes using copyfile(3) in Apple‐
Double format. This is the reverse of 1m--no-mac-metadata22m. and the
default behavior in c, r, and u modes or if 1mtar 22mis run in x mode
as root.
1m-n22m, 1m--norecurse22m, 1m--no-recursion0m
(c, r, u modes only) Do not recursively archive the contents of
directories.
1m--newer 4m22mdate0m
(c, r, u modes only) Only include files and directories newer
than the specified date. This compares ctime entries.
1m--newer-mtime 4m22mdate0m
(c, r, u modes only) Like 1m--newer22m, except it compares mtime
entries instead of ctime entries.
1m--newer-than 4m22mfile0m
(c, r, u modes only) Only include files and directories newer
than the specified file. This compares ctime entries.
1m--newer-mtime-than 4m22mfile0m
(c, r, u modes only) Like 1m--newer-than22m, except it compares mtime
entries instead of ctime entries.
1m--nodump0m
(c and r modes only) Honor the nodump file flag by skipping this
file.
1m--nopreserveHFSCompression0m
(x mode only) Mac OS X specific(v10.6 or later). Do not compress
extracted regular files which were compressed with HFS+ compres‐
sion before archived. By default, compress the regular files
again with HFS+ compression.
1m--null 22m(use with 1m-I 22mor 1m-T22m) Filenames or patterns are separated by null
characters, not by newlines. This is often used to read file‐
names output by the 1m-print0 22moption to find(1).
1m--no-acls0m
(c, r, u, x modes only) Do not archive or extract POSIX.1e or
NFSv4 ACLs. This is the reverse of 1m--acls 22mand the default behav‐
ior if 1mtar 22mis run as non-root in x mode (on Mac OS X also in c, r
and u modes).
1m--no-fflags0m
(c, r, u, x modes only) Do not archive or extract file flags.
This is the reverse of 1m--fflags 22mand the default behavior if 1mtar0m
is run as non-root in x mode.
1m--no-mac-metadata0m
(x mode only) Mac OS X specific. Do not archive or extract ACLs
and extended attributes using copyfile(3) in AppleDouble format.
This is the reverse of 1m--mac-metadata22m. and the default behavior
if 1mtar 22mis run as non-root in x mode.
1m-n22m, 1m--norecurse22m, 1m--no-recursion0m
1m--no-same-owner0m
(x mode only) Do not extract owner and group IDs. This is the
reverse of 1m--same-owner 22mand the default behavior if 1mtar 22mis run as
non-root.
1m--no-same-permissions0m
(x mode only) Do not extract full permissions (SGID, SUID, sticky
bit, ACLs, extended attributes or extended file flags). This is
the reverse of 1m-p 22mand the default behavior if 1mtar 22mis run as non-
root and can be overridden by also specifying 1m--acls22m, 1m--fflags22m,
1m--mac-metadata, --same-owner22m, 1m--same-permissions 22mand 1m--xattrs22m.
1m--no-xattrs0m
(c, r, u, x modes only) Do not archive or extract extended
attributes. This is the reverse of 1m--xattrs 22mand the default
behavior if 1mtar 22mis run as non-root in x mode.
1m--numeric-owner0m
This is equivalent to 1m--uname 22m"" 1m--gname 22m"". On extract, it
causes user and group names in the archive to be ignored in favor
of the numeric user and group ids. On create, it causes user and
group names to not be stored in the archive.
1m-O22m, 1m--to-stdout0m
(x, t modes only) In extract (-x) mode, files will be written to
standard out rather than being extracted to disk. In list (-t)
mode, the file listing will be written to stderr rather than the
usual stdout.
1m-o 22m(x mode) Use the user and group of the user running the program
rather than those specified in the archive. Note that this has
no significance unless 1m-p 22mis specified, and the program is being
run by the root user. In this case, the file modes and flags
from the archive will be restored, but ACLs or owner information
in the archive will be discarded.
1m-o 22m(c, r, u mode) A synonym for 1m--format 4m22mustar0m
1m--older 4m22mdate0m
(c, r, u modes only) Only include files and directories older
than the specified date. This compares ctime entries.
1m--older-mtime 4m22mdate0m
(c, r, u modes only) Like 1m--older22m, except it compares mtime
entries instead of ctime entries.
1m--older-than 4m22mfile0m
(c, r, u modes only) Only include files and directories older
than the specified file. This compares ctime entries.
1m--older-mtime-than 4m22mfile0m
(c, r, u modes only) Like 1m--older-than22m, except it compares mtime
entries instead of ctime entries.
1m--one-file-system0m
(c, r, and u modes) Do not cross mount points.
1m--options 4m22moptions0m
Select optional behaviors for particular modules. The argument
is a text string containing comma-separated keywords and values.
These are passed to the modules that handle particular formats to
control how those formats will behave. Each option has one of
the following forms:
4mkey=value0m
The key will be set to the specified value in every mod‐
ule that supports it. Modules that do not support this
key will ignore it.
4mkey24m The key will be enabled in every module that supports it.
This is equivalent to 4mkey24m1m=122m.
4m!key24m The key will be disabled in every module that supports
it.
4mmodule:key=value24m, 4mmodule:key24m, 4mmodule:!key0m
As above, but the corresponding key and value will be
provided only to modules whose name matches 4mmodule24m.
The currently supported modules and keys are:
1miso9660:joliet0m
Support Joliet extensions. This is enabled by default,
use 1m!joliet 22mor 1miso9660:!joliet 22mto disable.
1miso9660:rockridge0m
Support Rock Ridge extensions. This is enabled by
default, use 1m!rockridge 22mor 1miso9660:!rockridge 22mto disable.
1mgzip:compression-level0m
A decimal integer from 1 to 9 specifying the gzip com‐
pression level.
1mgzip:timestamp0m
Store timestamp. This is enabled by default, use
1m!timestamp 22mor 1mgzip:!timestamp 22mto disable.
1mlrzip:compression22m=4mtype0m
Use 4mtype24m as compression method. Supported values are
bzip2, gzip, lzo (ultra fast), and zpaq (best, extremely
slow).
1mlrzip:compression-level0m
A decimal integer from 1 to 9 specifying the lrzip com‐
pression level.
1mlz4:compression-level0m
A decimal integer from 1 to 9 specifying the lzop com‐
pression level.
1mlz4:stream-checksum0m
Enable stream checksum. This is by default, use
1mlz4:!stream-checksum 22mto disable.
1mlz4:block-checksum0m
Enable block checksum (Disabled by default).
1mlz4:block-size0m
A decimal integer from 4 to 7 specifying the lz4 compres‐
sion block size (7 is set by default).
1mlz4:block-dependence0m
Use the previous block of the block being compressed for
a compression dictionary to improve compression ratio.
1mlzop:compression-level0m
A decimal integer from 1 to 9 specifying the lzop com‐
pression level.
1mxz:compression-level0m
A decimal integer from 0 to 9 specifying the xz compres‐
sion level.
1mmtree:4m22mkeyword0m
The mtree writer module allows you to specify which mtree
keywords will be included in the output. Supported key‐
words include: 1mcksum22m, 1mdevice22m, 1mflags22m, 1mgid22m, 1mgname22m, 1mindent22m,
1mlink22m, 1mmd522m, 1mmode22m, 1mnlink22m, 1mrmd16022m, 1msha122m, 1msha25622m, 1msha38422m,
1msha51222m, 1msize22m, 1mtime22m, 1muid22m, 1muname22m. The default is equiva‐
lent to: “device, flags, gid, gname, link, mode, nlink,
size, time, type, uid, uname”.
1mmtree:all0m
Enables all of the above keywords. You can also use
1mmtree:!all 22mto disable all keywords.
1mmtree:use-set0m
Enable generation of 1m/set 22mlines in the output.
1mmtree:indent0m
Produce human-readable output by indenting options and
splitting lines to fit into 80 columns.
1mzip:compression22m=4mtype0m
Use 4mtype24m as compression method. Supported values are
store (uncompressed) and deflate (gzip algorithm).
1mzip:encryption0m
Enable encryption using traditional zip encryption.
1mzip:encryption22m=4mtype0m
Use 4mtype24m as encryption type. Supported values are
zipcrypt (traditional zip encryption), aes128 (WinZip
AES-128 encryption) and aes256 (WinZip AES-256 encryp‐
tion).
1mread_concatenated_archives0m
Ignore zeroed blocks in the archive, which occurs when
multiple tar archives have been concatenated together.
Without this option, only the contents of the first con‐
catenated archive would be read. This option is compara‐
ble to the 1m-i22m, 1m--ignore-zeros 22moption of GNU tar.
If a provided option is not supported by any module, that is a
fatal error.
1m-P22m, 1m--absolute-paths0m
Preserve pathnames. By default, absolute pathnames (those that
begin with a / character) have the leading slash removed both
when creating archives and extracting from them. Also, 1mtar 22mwill
refuse to extract archive entries whose pathnames contain 4m..24m or
whose target directory would be altered by a symlink. This
option suppresses these behaviors.
1m-p22m, 1m--insecure22m, 1m--preserve-permissions0m
(x mode only) Preserve file permissions. Attempt to restore the
full permissions, including owner, file modes, ACLs, extended
atributes and extended file flags, if available, for each item
extracted from the archive. This is the default, if 1mtar 22mis being
run by root and can be overridden by also specifying 1m--no-acls22m,
1m--no-fflags22m, 1m--no-mac-metadata, --no-same-owner22m,
1m--no-same-permissions 22mand 1m--no-xattrs22m.
1m--passphrase 4m22mpassphrase0m
The 4mpassphrase24m is used to extract or create an encrypted archive.
Currently, zip is the only supported format that supports encryp‐
tion. You shouldn't use this option unless you realize how inse‐
cure use of this option is.
1m--posix0m
(c, r, u mode only) Synonym for 1m--format 4m22mpax0m
1m-q22m, 1m--fast-read0m
(x and t mode only) Extract or list only the first archive entry
that matches each pattern or filename operand. Exit as soon as
each specified pattern or filename has been matched. By default,
the archive is always read to the very end, since there can be
multiple entries with the same name and, by convention, later
entries overwrite earlier entries. This option is provided as a
performance optimization.
1m-S 22m(x mode only) Extract files as sparse files. For every block on
disk, check first if it contains only NULL bytes and seek over it
otherwise. This works similar to the conv=sparse option of dd.
1m-s 4m22mpattern0m
Modify file or archive member names according to 4mpattern24m. The
pattern has the format 4m/old/new/24m[ghHprRsS] where 4mold24m is a basic
regular expression, 4mnew24m is the replacement string of the matched
part, and the optional trailing letters modify how the replace‐
ment is handled. If 4mold24m is not matched, the pattern is skipped.
Within 4mnew24m, ~ is substituted with the match, \1 to \9 with the
content of the corresponding captured group. The optional trail‐
ing g specifies that matching should continue after the matched
part and stop on the first unmatched pattern. The optional
trailing s specifies that the pattern applies to the value of
symbolic links. The optional trailing p specifies that after a
successful substitution the original path name and the new path
name should be printed to standard error. Optional trailing H,
R, or S characters suppress substitutions for hardlink targets,
regular filenames, or symlink targets, respectively. Optional
trailing h, r, or s characters enable substitutions for hardlink
targets, regular filenames, or symlink targets, respectively.
The default is 4mhrs24m which applies substitutions to all names. In
particular, it is never necessary to specify h, r, or s.
1m--same-owner0m
(x mode only) Extract owner and group IDs. This is the reverse
of 1m--no-same-owner 22mand the default behavior if 1mtar 22mis run as
root.
1m--strip-components 4m22mcount0m
Remove the specified number of leading path elements. Pathnames
with fewer elements will be silently skipped. Note that the
pathname is edited after checking inclusion/exclusion patterns
but before security checks.
1m-T 4m22mfilename24m, 1m--files-from 4m22mfilename0m
In x or t mode, 1mtar 22mwill read the list of names to be extracted
from 4mfilename24m. In c mode, 1mtar 22mwill read names to be archived
from 4mfilename24m. The special name “-C” on a line by itself will
cause the current directory to be changed to the directory speci‐
fied on the following line. Names are terminated by newlines
unless 1m--null 22mis specified. Note that 1m--null 22malso disables the
special handling of lines containing “-C”. Note: If you are
generating lists of files using find(1), you probably want to use
1m-n 22mas well.
1m--totals0m
(c, r, u modes only) After archiving all files, print a summary
to stderr.
1m-U22m, 1m--unlink22m, 1m--unlink-first0m
(x mode only) Unlink files before creating them. This can be a
minor performance optimization if most files already exist, but
can make things slower if most files do not already exist. This
flag also causes 1mtar 22mto remove intervening directory symlinks
instead of reporting an error. See the SECURITY section below
for more details.
1m--uid 4m22mid0m
Use the provided user id number and ignore the user name from the
archive. On create, if 1m--uname 22mis not also specified, the user
name will be set to match the user id.
1m--uname 4m22mname0m
Use the provided user name. On extract, this overrides the user
name in the archive; if the provided user name does not exist on
the system, it will be ignored and the user id (from the archive
or from the 1m--uid 22moption) will be used instead. On create, this
sets the user name that will be stored in the archive; the name
is not verified against the system user database.
1m--use-compress-program 4m22mprogram0m
Pipe the input (in x or t mode) or the output (in c mode) through
4mprogram24m instead of using the builtin compression support.
1m-v22m, 1m--verbose0m
Produce verbose output. In create and extract modes, 1mtar 22mwill
list each file name as it is read from or written to the archive.
In list mode, 1mtar 22mwill produce output similar to that of ls(1).
An additional 1m-v 22moption will also provide ls-like details in cre‐
ate and extract mode.
1m--version0m
Print version of 1mtar 22mand 1mlibarchive22m, and exit.
1m-w22m, 1m--confirmation22m, 1m--interactive0m
Ask for confirmation for every action.
1m-X 4m22mfilename24m, 1m--exclude-from 4m22mfilename0m
Read a list of exclusion patterns from the specified file. See
1m--exclude 22mfor more information about the handling of exclusions.
1m--xattrs0m
(c, r, u, x modes only) Archive or extract extended attributes.
This is the reverse of 1m--no-xattrs 22mand the default behavior in c,
r, and u modes or if 1mtar 22mis run in x mode as root.
1m-y 22m(c mode only) Compress the resulting archive with bzip2(1). In
extract or list modes, this option is ignored. Note that, unlike
other 1mtar 22mimplementations, this implementation recognizes bzip2
compression automatically when reading archives.
1m-Z22m, 1m--compress22m, 1m--uncompress0m
(c mode only) Compress the resulting archive with compress(1).
In extract or list modes, this option is ignored. Note that,
unlike other 1mtar 22mimplementations, this implementation recognizes
compress compression automatically when reading archives.
1m-z22m, 1m--gunzip22m, 1m--gzip0m
(c mode only) Compress the resulting archive with gzip(1). In
extract or list modes, this option is ignored. Note that, unlike
other 1mtar 22mimplementations, this implementation recognizes gzip
compression automatically when reading archives.
1mENVIRONMENT0m
The following environment variables affect the execution of 1mtar22m:
TAR_READER_OPTIONS
The default options for format readers and compression read‐
ers. The 1m--options 22moption overrides this.
TAR_WRITER_OPTIONS
The default options for format writers and compression writ‐
ers. The 1m--options 22moption overrides this.
LANG The locale to use. See environ(7) for more information.
TAPE The default device. The 1m-f 22moption overrides this. Please see
the description of the 1m-f 22moption above for more details.
TZ The timezone to use when displaying dates. See environ(7) for
more information.
1mEXIT STATUS0m
The 1mtar 22mutility exits 0 on success, and >0 if an error occurs.
1mEXAMPLES0m
The following creates a new archive called 4mfile.tar.gz24m that contains two
files 4msource.c24m and 4msource.h24m:
1mtar -czf 4m22mfile.tar.gz24m 4msource.c24m 4msource.h0m
To view a detailed table of contents for this archive:
1mtar -tvf 4m22mfile.tar.gz0m
To extract all entries from the archive on the default tape drive:
1mtar -x0m
To examine the contents of an ISO 9660 cdrom image:
1mtar -tf 4m22mimage.iso0m
To move file hierarchies, invoke 1mtar 22mas
1mtar -cf 4m22m-24m 1m-C 4m22msrcdir24m 4m.24m | 1mtar -xpf 4m22m-24m 1m-C 4m22mdestdir0m
or more traditionally
cd srcdir ; 1mtar -cf 4m22m-24m 4m.24m | (4mcd24m 4mdestdir24m 4m;24m 1mtar -xpf 4m22m-24m)
In create mode, the list of files and directories to be archived can also
include directory change instructions of the form 1m-C4m22mfoo/baz24m and archive
inclusions of the form 1m@4m22marchive-file24m. For example, the command line
1mtar -c -f 4m22mnew.tar24m 4mfoo124m 1m@4m22mold.tgz24m 1m-C4m22m/tmp24m 4mfoo20m
will create a new archive 4mnew.tar24m. 1mtar 22mwill read the file 4mfoo124m from the
current directory and add it to the output archive. It will then read
each entry from 4mold.tgz24m and add those entries to the output archive.
Finally, it will switch to the 4m/tmp24m directory and add 4mfoo224m to the output
archive.
An input file in mtree(5) format can be used to create an output archive
with arbitrary ownership, permissions, or names that differ from existing
data on disk:
$ cat input.mtree
#mtree
usr/bin uid=0 gid=0 mode=0755 type=dir
usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
$ tar -cvf output.tar @input.mtree
The 1m--newer 22mand 1m--newer-mtime 22mswitches accept a variety of common date
and time specifications, including “12 Mar 2005 7:14:29pm”, “2005-03-12
19:14”, “5 minutes ago”, and “19:14 PST May 1”.
The 1m--options 22margument can be used to control various details of archive
generation or reading. For example, you can generate mtree output which
only contains 1mtype22m, 1mtime22m, and 1muid 22mkeywords:
1mtar -cf 4m22mfile.tar24m 1m--format=mtree --options='!all,type,time,uid' 4m22mdir0m
or you can set the compression level used by gzip or xz compression:
1mtar -czf 4m22mfile.tar24m 1m--options='compression-level=9'22m.
For more details, see the explanation of the 1marchive_read_set_options22m()
and 1marchive_write_set_options22m() API calls that are described in
archive_read(3) and archive_write(3).
1mCOMPATIBILITY0m
The bundled-arguments format is supported for compatibility with historic
implementations. It consists of an initial word (with no leading - char‐
acter) in which each character indicates an option. Arguments follow as
separate words. The order of the arguments must match the order of the
corresponding characters in the bundled command word. For example,
1mtar tbf 32 4m22mfile.tar0m
specifies three flags 1mt22m, 1mb22m, and 1mf22m. The 1mb 22mand 1mf 22mflags both require argu‐
ments, so there must be two additional items on the command line. The 4m320m
is the argument to the 1mb 22mflag, and 4mfile.tar24m is the argument to the 1mf0m
flag.
The mode options c, r, t, u, and x and the options b, f, l, m, o, v, and
w comply with SUSv2.
For maximum portability, scripts that invoke 1mtar 22mshould use the bundled-
argument format above, should limit themselves to the 1mc22m, 1mt22m, and 1mx 22mmodes,
and the 1mb22m, 1mf22m, 1mm22m, 1mv22m, and 1mw 22moptions.
Additional long options are provided to improve compatibility with other
tar implementations.
1mSECURITY0m
Certain security issues are common to many archiving programs, including
1mtar22m. In particular, carefully-crafted archives can request that 1mtar0m
extract files to locations outside of the target directory. This can
potentially be used to cause unwitting users to overwrite files they did
not intend to overwrite. If the archive is being extracted by the supe‐
ruser, any file on the system can potentially be overwritten. There are
three ways this can happen. Although 1mtar 22mhas mechanisms to protect
against each one, savvy users should be aware of the implications:
1m· 22mArchive entries can have absolute pathnames. By default, 1mtar0m
removes the leading 4m/24m character from filenames before restoring
them to guard against this problem.
1m· 22mArchive entries can have pathnames that include 4m..24m components.
By default, 1mtar 22mwill not extract files containing 4m..24m components
in their pathname.
1m· 22mArchive entries can exploit symbolic links to restore files to
other directories. An archive can restore a symbolic link to
another directory, then use that link to restore a file into that
directory. To guard against this, 1mtar 22mchecks each extracted path
for symlinks. If the final path element is a symlink, it will be
removed and replaced with the archive entry. If 1m-U 22mis specified,
any intermediate symlink will also be unconditionally removed.
If neither 1m-U 22mnor 1m-P 22mis specified, 1mtar 22mwill refuse to extract the
entry.
To protect yourself, you should be wary of any archives that come from
untrusted sources. You should examine the contents of an archive with
1mtar -tf 4m22mfilename0m
before extraction. You should use the 1m-k 22moption to ensure that 1mtar 22mwill
not overwrite any existing files or the 1m-U 22moption to remove any pre-
existing files. You should generally not extract archives while running
with super-user privileges. Note that the 1m-P 22moption to 1mtar 22mdisables the
security checks above and allows you to extract an archive while preserv‐
ing any absolute pathnames, 4m..24m components, or symlinks to other directo‐
ries.
1mSEE ALSO0m
bzip2(1), compress(1), cpio(1), gzip(1), mt(1), pax(1), shar(1), xz(1),
libarchive(3), libarchive-formats(5), tar(5)
1mSTANDARDS0m
There is no current POSIX standard for the tar command; it appeared in
ISO/IEC 9945-1:1996 (“POSIX.1”) but was dropped from IEEE Std 1003.1-2001
(“POSIX.1”). The options supported by this implementation were developed
by surveying a number of existing tar implementations as well as the old
POSIX specification for tar and the current POSIX specification for pax.
The ustar and pax interchange file formats are defined by IEEE Std
1003.1-2001 (“POSIX.1”) for the pax command.
1mHISTORY0m
A 1mtar 22mcommand appeared in Seventh Edition Unix, which was released in
January, 1979. There have been numerous other implementations, many of
which extended the file format. John Gilmore's 1mpdtar 22mpublic-domain
implementation (circa November, 1987) was quite influential, and formed
the basis of GNU tar. GNU tar was included as the standard system tar in
FreeBSD beginning with FreeBSD 1.0.
This is a complete re-implementation based on the libarchive(3) library.
It was first released with FreeBSD 5.4 in May, 2005.
1mBUGS0m
This program follows ISO/IEC 9945-1:1996 (“POSIX.1”) for the definition
of the 1m-l 22moption. Note that GNU tar prior to version 1.15 treated 1m-l 22mas
a synonym for the 1m--one-file-system 22moption.
The 1m-C 4m22mdir24m option may differ from historic implementations.
All archive output is written in correctly-sized blocks, even if the out‐
put is being compressed. Whether or not the last output block is padded
to a full block size varies depending on the format and the output
device. For tar and cpio formats, the last block of output is padded to
a full block size if the output is being written to standard output or to
a character or block device such as a tape drive. If the output is being
written to a regular file, the last block will not be padded. Many com‐
pressors, including gzip(1) and bzip2(1), complain about the null padding
when decompressing an archive created by 1mtar22m, although they still extract
it correctly.
The compression and decompression is implemented internally, so there may
be insignificant differences between the compressed output generated by
1mtar -czf 4m22m-24m 4mfile0m
and that generated by
1mtar -cf 4m22m-24m 4mfile24m | 1mgzip0m
The default should be to read and write archives to the standard I/O
paths, but tradition (and POSIX) dictates otherwise.
The 1mr 22mand 1mu 22mmodes require that the archive be uncompressed and located in
a regular file on disk. Other archives can be modified using 1mc 22mmode with
the 4m@archive-file24m extension.
To archive a file called 4m@foo24m or 4m-foo24m you must specify it as 4m./@foo24m or
4m./-foo24m, respectively.
In create mode, a leading 4m./24m is always removed. A leading 4m/24m is stripped
unless the 1m-P 22moption is specified.
There needs to be better support for file selection on both create and
extract.
There is not yet any support for multi-volume archives.
Converting between dissimilar archive formats (such as tar and cpio)
using the 1m@4m22m-24m convention can cause hard link information to be lost.
(This is a consequence of the incompatible ways that different archive
formats store hardlink information.)
BSD February 24, 2017 BSD
|