]> icculus.org git repositories - icculus/xz.git/blob - src/xz/xz.1
Some updates to xz man page.
[icculus/xz.git] / src / xz / xz.1
1 '\" t
2 .\"
3 .\" Author: Lasse Collin
4 .\"
5 .\" This file has been put into the public domain.
6 .\" You can do whatever you want with this file.
7 .\"
8 .TH XZ 1 "2009-11-14" "Tukaani" "XZ Utils"
9 .SH NAME
10 xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
11 .SH SYNOPSIS
12 .B xz
13 .RI [ option ]...
14 .RI [ file ]...
15 .PP
16 .B unxz
17 is equivalent to
18 .BR "xz \-\-decompress" .
19 .br
20 .B xzcat
21 is equivalent to
22 .BR "xz \-\-decompress \-\-stdout" .
23 .br
24 .B lzma
25 is equivalent to
26 .BR "xz \-\-format=lzma" .
27 .br
28 .B unlzma
29 is equivalent to
30 .BR "xz \-\-format=lzma \-\-decompress" .
31 .br
32 .B lzcat
33 is equivalent to
34 .BR "xz \-\-format=lzma \-\-decompress \-\-stdout" .
35 .PP
36 When writing scripts that need to decompress files, it is recommended to
37 always use the name
38 .B xz
39 with appropriate arguments
40 .RB ( "xz \-d"
41 or
42 .BR "xz \-dc" )
43 instead of the names
44 .B unxz
45 and
46 .BR xzcat.
47 .SH DESCRIPTION
48 .B xz
49 is a general-purpose data compression tool with command line syntax similar to
50 .BR gzip (1)
51 and
52 .BR bzip2 (1).
53 The native file format is the
54 .B .xz
55 format, but also the legacy
56 .B .lzma
57 format and raw compressed streams with no container format headers
58 are supported.
59 .PP
60 .B xz
61 compresses or decompresses each
62 .I file
63 according to the selected operation mode.
64 If no
65 .I files
66 are given or
67 .I file
68 is
69 .BR \- ,
70 .B xz
71 reads from standard input and writes the processed data to standard output.
72 .B xz
73 will refuse (display an error and skip the
74 .IR file )
75 to write compressed data to standard output if it is a terminal. Similarly,
76 .B xz
77 will refuse to read compressed data from standard input if it is a terminal.
78 .PP
79 Unless
80 .B \-\-stdout
81 is specified,
82 .I files
83 other than
84 .B \-
85 are written to a new file whose name is derived from the source
86 .I file
87 name:
88 .IP \(bu 3
89 When compressing, the suffix of the target file format
90 .RB ( .xz
91 or
92 .BR .lzma )
93 is appended to the source filename to get the target filename.
94 .IP \(bu 3
95 When decompressing, the
96 .B .xz
97 or
98 .B .lzma
99 suffix is removed from the filename to get the target filename.
100 .B xz
101 also recognizes the suffixes
102 .B .txz
103 and
104 .BR .tlz ,
105 and replaces them with the
106 .B .tar
107 suffix.
108 .PP
109 If the target file already exists, an error is displayed and the
110 .I file
111 is skipped.
112 .PP
113 Unless writing to standard output,
114 .B xz
115 will display a warning and skip the
116 .I file
117 if any of the following applies:
118 .IP \(bu 3
119 .I File
120 is not a regular file. Symbolic links are not followed, thus they
121 are never considered to be regular files.
122 .IP \(bu 3
123 .I File
124 has more than one hardlink.
125 .IP \(bu 3
126 .I File
127 has setuid, setgid, or sticky bit set.
128 .IP \(bu 3
129 The operation mode is set to compress, and the
130 .I file
131 already has a suffix of the target file format
132 .RB ( .xz
133 or
134 .B .txz
135 when compressing to the
136 .B .xz
137 format, and
138 .B .lzma
139 or
140 .B .tlz
141 when compressing to the
142 .B .lzma
143 format).
144 .IP \(bu 3
145 The operation mode is set to decompress, and the
146 .I file
147 doesn't have a suffix of any of the supported file formats
148 .RB ( .xz ,
149 .BR .txz ,
150 .BR .lzma ,
151 or
152 .BR .tlz ).
153 .PP
154 After successfully compressing or decompressing the
155 .IR file ,
156 .B xz
157 copies the owner, group, permissions, access time, and modification time
158 from the source
159 .I file
160 to the target file. If copying the group fails, the permissions are modified
161 so that the target file doesn't become accessible to users who didn't have
162 permission to access the source
163 .IR file .
164 .B xz
165 doesn't support copying other metadata like access control lists
166 or extended attributes yet.
167 .PP
168 Once the target file has been successfully closed, the source
169 .I file
170 is removed unless
171 .B \-\-keep
172 was specified. The source
173 .I file
174 is never removed if the output is written to standard output.
175 .PP
176 Sending
177 .B SIGINFO
178 or
179 .B SIGUSR1
180 to the
181 .B xz
182 process makes it print progress information to standard error.
183 This has only limited use since when standard error is a terminal, using
184 .B \-\-verbose
185 will display an automatically updating progress indicator.
186 .SS "Memory usage"
187 The memory usage of
188 .B xz
189 varies from a few hundred kilobytes to several gigabytes depending on
190 the compression settings. The settings used when compressing a file
191 affect also the memory usage of the decompressor. Typically the decompressor
192 needs only 5\ % to 20\ % of the amount of RAM that the compressor needed when
193 creating the file. Still, the worst-case memory usage of the decompressor
194 is several gigabytes.
195 .PP
196 To prevent uncomfortable surprises caused by huge memory usage,
197 .B xz
198 has a built-in memory usage limiter. The default limit is 40 % of total
199 physical RAM. While operating systems provide ways to limit the memory usage
200 of processes, relying on it wasn't deemed to be flexible enough.
201 .PP
202 When compressing, if the selected compression settings exceed the memory
203 usage limit, the settings are automatically adjusted downwards and a notice
204 about this is displayed. As an exception, if the memory usage limit is
205 exceeded when compressing with
206 .BR \-\-format=raw ,
207 an error is displayed and
208 .B xz
209 will exit with exit status
210 .BR 1 .
211 .PP
212 If source
213 .I file
214 cannot be decompressed without exceeding the memory usage limit, an error
215 message is displayed and the file is skipped. Note that compressed files
216 may contain many blocks, which may have been compressed with different
217 settings. Typically all blocks will have roughly the same memory requirements,
218 but it is possible that a block later in the file will exceed the memory usage
219 limit, and an error about too low memory usage limit gets displayed after some
220 data has already been decompressed.
221 .PP
222 The absolute value of the active memory usage limit can be seen near
223 the bottom of the output of
224 .BR \-\-long\-help .
225 The default limit can be overriden with
226 \fB\-\-memory=\fIlimit\fR.
227 .SH OPTIONS
228 .SS "Integer suffixes and special values"
229 In most places where an integer argument is expected, an optional suffix
230 is supported to easily indicate large integers. There must be no space
231 between the integer and the suffix.
232 .TP
233 .BR k " or " kB
234 The integer is multiplied by 1,000 (10^3). For example,
235 .B "5k"
236 or
237 .B "5kB"
238 equals
239 .BR "5000" .
240 .TP
241 .BR Ki " or " KiB
242 The integer is multiplied by 1,024 (2^10).
243 .TP
244 .BR M " or " MB
245 The integer is multiplied by 1,000,000 (10^6).
246 .TP
247 .BR Mi " or " MiB
248 The integer is multiplied by 1,048,576 (2^20).
249 .TP
250 .BR G " or " GB
251 The integer is multiplied by 1,000,000,000 (10^9).
252 .TP
253 .BR Gi " or " GiB
254 The integer is multiplied by 1,073,741,824 (2^30).
255 .PP
256 A special value
257 .B max
258 can be used to indicate the maximum integer value supported by the option.
259 .SS "Operation mode"
260 If multiple operation mode options are given, the last one takes effect.
261 .TP
262 .BR \-z ", " \-\-compress
263 Compress. This is the default operation mode when no operation mode option
264 is specified, and no other operation mode is implied from the command name
265 (for example,
266 .B unxz
267 implies
268 .BR \-\-decompress ).
269 .TP
270 .BR \-d ", " \-\-decompress ", " \-\-uncompress
271 Decompress.
272 .TP
273 .BR \-t ", " \-\-test
274 Test the integrity of compressed
275 .IR files .
276 No files are created or removed. This option is equivalent to
277 .B "\-\-decompress \-\-stdout"
278 except that the decompressed data is discarded instead of being
279 written to standard output.
280 .TP
281 .BR \-l ", " \-\-list
282 View information about the compressed files. No uncompressed output is
283 produced, and no files are created or removed. In list mode, the program
284 cannot read the compressed data from standard input or from other
285 unseekable sources.
286 .IP
287 .B "This feature has not been implemented yet."
288 .SS "Operation modifiers"
289 .TP
290 .BR \-k ", " \-\-keep
291 Keep (don't delete) the input files.
292 .TP
293 .BR \-f ", " \-\-force
294 This option has several effects:
295 .RS
296 .IP \(bu 3
297 If the target file already exists, delete it before compressing or
298 decompressing.
299 .IP \(bu 3
300 Compress or decompress even if the input is not a regular file,
301 has more than one hardlink, or has setuid, setgid, or sticky bit set.
302 The setuid, setgid, and sticky bits are not copied to the target file.
303 .IP \(bu 3
304 If combined with
305 .B \-\-decompress
306 .BR \-\-stdout
307 and
308 .B xz
309 doesn't recognize the type of the source file,
310 .B xz
311 will copy the source file as is to standard output. This allows using
312 .B xzcat
313 .B \--force
314 like
315 .BR cat (1)
316 for files that have not been compressed with
317 .BR xz .
318 Note that in future,
319 .B xz
320 might support new compressed file formats, which may make
321 .B xz
322 decompress more types of files instead of copying them as is to
323 standard output.
324 .BI \-\-format= format
325 can be used to restrict
326 .B xz
327 to decompress only a single file format.
328 .IP \(bu 3
329 Allow writing compressed data to a terminal, and reading compressed data
330 from a terminal.
331 .RE
332 .TP
333 .BR \-c ", " \-\-stdout ", " \-\-to-stdout
334 Write the compressed or decompressed data to standard output instead of
335 a file. This implies
336 .BR \-\-keep .
337 .TP
338 \fB\-S\fR \fI.suf\fR, \fB\-\-suffix=\fI.suf
339 When compressing, use
340 .I .suf
341 as the suffix for the target file instead of
342 .B .xz
343 or
344 .BR .lzma .
345 If not writing to standard output and the source file already has the suffix
346 .IR .suf ,
347 a warning is displayed and the file is skipped.
348 .IP
349 When decompressing, recognize also files with the suffix
350 .I .suf
351 in addition to files with the
352 .BR .xz ,
353 .BR .txz ,
354 .BR .lzma ,
355 or
356 .B .tlz
357 suffix. If the source file has the suffix
358 .IR .suf ,
359 the suffix is removed to get the target filename.
360 .IP
361 When compressing or decompressing raw streams
362 .RB ( \-\-format=raw ),
363 the suffix must always be specified unless writing to standard output,
364 because there is no default suffix for raw streams.
365 .TP
366 \fB\-\-files\fR[\fB=\fIfile\fR]
367 Read the filenames to process from
368 .IR file ;
369 if
370 .I file
371 is omitted, filenames are read from standard input. Filenames must be
372 terminated with the newline character. A dash
373 .RB ( \- )
374 is taken as a regular filename; it doesn't mean standard input.
375 If filenames are given also as command line arguments, they are
376 processed before the filenames read from
377 .IR file .
378 .TP
379 \fB\-\-files0\fR[\fB=\fIfile\fR]
380 This is identical to \fB\-\-files\fR[\fB=\fIfile\fR] except that the
381 filenames must be terminated with the null character.
382 .SS "Basic file format and compression options"
383 .TP
384 \fB\-F\fR \fIformat\fR, \fB\-\-format=\fIformat
385 Specify the file format to compress or decompress:
386 .RS
387 .IP \(bu 3
388 .BR auto :
389 This is the default. When compressing,
390 .B auto
391 is equivalent to
392 .BR xz .
393 When decompressing, the format of the input file is autodetected. Note that
394 raw streams (created with
395 .BR \-\-format=raw )
396 cannot be autodetected.
397 .IP \(bu 3
398 .BR xz :
399 Compress to the
400 .B .xz
401 file format, or accept only
402 .B .xz
403 files when decompressing.
404 .IP \(bu 3
405 .B lzma
406 or
407 .BR alone :
408 Compress to the legacy
409 .B .lzma
410 file format, or accept only
411 .B .lzma
412 files when decompressing. The alternative name
413 .B alone
414 is provided for backwards compatibility with LZMA Utils.
415 .IP \(bu 3
416 .BR raw :
417 Compress or uncompress a raw stream (no headers). This is meant for advanced
418 users only. To decode raw streams, you need to set not only
419 .B \-\-format=raw
420 but also specify the filter chain, which would normally be stored in the
421 container format headers.
422 .RE
423 .TP
424 \fB\-C\fR \fIcheck\fR, \fB\-\-check=\fIcheck
425 Specify the type of the integrity check, which is calculated from the
426 uncompressed data. This option has an effect only when compressing into the
427 .B .xz
428 format; the
429 .B .lzma
430 format doesn't support integrity checks.
431 The integrity check (if any) is verified when the
432 .B .xz
433 file is decompressed.
434 .IP
435 Supported
436 .I check
437 types:
438 .RS
439 .IP \(bu 3
440 .BR none :
441 Don't calculate an integrity check at all. This is usually a bad idea. This
442 can be useful when integrity of the data is verified by other means anyway.
443 .IP \(bu 3
444 .BR crc32 :
445 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
446 .IP \(bu 3
447 .BR crc64 :
448 Calculate CRC64 using the polynomial from ECMA-182. This is the default, since
449 it is slightly better than CRC32 at detecting damaged files and the speed
450 difference is negligible.
451 .IP \(bu 3
452 .BR sha256 :
453 Calculate SHA-256. This is somewhat slower than CRC32 and CRC64.
454 .RE
455 .IP
456 Integrity of the
457 .B .xz
458 headers is always verified with CRC32. It is not possible to change or
459 disable it.
460 .TP
461 .BR \-0 " ... " \-9
462 Select compression preset. If a preset level is specified multiple times,
463 the last one takes effect.
464 .IP
465 The compression preset levels can be categorised roughly into three
466 categories:
467 .RS
468 .IP "\fB\-0\fR ... \fB\-2"
469 Fast presets with relatively low memory usage.
470 .B \-1
471 and
472 .B \-2
473 should give compression speed and ratios comparable to
474 .B "bzip2 \-1"
475 and
476 .BR "bzip2 \-9" ,
477 respectively.
478 Currently
479 .B \-0
480 is not very good (not much faster than
481 .B \-1
482 but much worse compression). In future,
483 .B \-0
484 may be indicate some fast algorithm instead of LZMA2.
485 .IP "\fB\-3\fR ... \fB\-5"
486 Good compression ratio with low to medium memory usage.
487 These are significantly slower than levels 0\-2.
488 .IP "\fB\-6\fR ... \fB\-9"
489 Excellent compression with medium to high memory usage. These are also
490 slower than the lower preset levels. The default is
491 .BR \-6 .
492 Unless you want to maximize the compression ratio, you probably don't want
493 a higher preset level than
494 .B \-7
495 due to speed and memory usage.
496 .RE
497 .IP
498 The exact compression settings (filter chain) used by each preset may
499 vary between
500 .B xz
501 versions. The settings may also vary between files being compressed, if
502 .B xz
503 determines that modified settings will probably give better compression
504 ratio without significantly affecting compression time or memory usage.
505 .IP
506 Because the settings may vary, the memory usage may vary too. The following
507 table lists the maximum memory usage of each preset level, which won't be
508 exceeded even in future versions of
509 .BR xz .
510 .IP
511 .B "FIXME: The table below is just a rough idea."
512 .RS
513 .RS
514 .TS
515 tab(;);
516 c c c
517 n n n.
518 Preset;Compression;Decompression
519 \-0;6 MiB;1 MiB
520 \-1;6 MiB;1 MiB
521 \-2;10 MiB;1 MiB
522 \-3;20 MiB;2 MiB
523 \-4;30 MiB;3 MiB
524 \-5;60 MiB;6 MiB
525 \-6;100 MiB;10 MiB
526 \-7;200 MiB;20 MiB
527 \-8;400 MiB;40 MiB
528 \-9;800 MiB;80 MiB
529 .TE
530 .RE
531 .RE
532 .IP
533 When compressing,
534 .B xz
535 automatically adjusts the compression settings downwards if
536 the memory usage limit would be exceeded, so it is safe to specify
537 a high preset level even on systems that don't have lots of RAM.
538 .TP
539 .BR \-\-fast " and " \-\-best
540 These are somewhat misleading aliases for
541 .B \-0
542 and
543 .BR \-9 ,
544 respectively.
545 These are provided only for backwards compatibility with LZMA Utils.
546 Avoid using these options.
547 .IP
548 Especially the name of
549 .B \-\-best
550 is misleading, because the definition of best depends on the input data,
551 and that usually people don't want the very best compression ratio anyway,
552 because it would be very slow.
553 .TP
554 .BR \-e ", " \-\-extreme
555 Modify the compression preset (\fB\-0\fR ... \fB\-9\fR) so that a little bit
556 better compression ratio can be achieved without increasing memory usage
557 of the compressor or decompressor (exception: compressor memory usage may
558 increase a little with presets \fB\-0\fR ... \fB\-2\fR). The downside is that
559 the compression time will increase dramatically (it can easily double).
560 .TP
561 \fB\-M\fR \fIlimit\fR, \fB\-\-memory=\fIlimit
562 Set the memory usage limit. If this option is specied multiple times,
563 the last one takes effect. The
564 .I limit
565 can be specified in multiple ways:
566 .RS
567 .IP \(bu 3
568 The
569 .I limit
570 can be an absolute value in bytes. Using an integer suffix like
571 .B MiB
572 can be useful. Example:
573 .B "\-\-memory=80MiB"
574 .IP \(bu 3
575 The
576 .I limit
577 can be specified as a percentage of physical RAM. Example:
578 .B "\-\-memory=70%"
579 .IP \(bu 3
580 The
581 .I limit
582 can be reset back to its default value (currently 40 % of physical RAM)
583 by setting it to
584 .BR 0 .
585 .IP \(bu 3
586 The memory usage limiting can be effectively disabled by setting
587 .I limit
588 to
589 .BR max .
590 This isn't recommended. It's usually better to use, for example,
591 .BR \-\-memory=90% .
592 .RE
593 .IP
594 The current
595 .I limit
596 can be seen near the bottom of the output of the
597 .B \-\-long-help
598 option.
599 .TP
600 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
601 Specify the maximum number of worker threads to use. The default is
602 the number of available CPU cores. You can see the current value of
603 .I threads
604 near the end of the output of the
605 .B \-\-long\-help
606 option.
607 .IP
608 The actual number of worker threads can be less than
609 .I threads
610 if using more threads would exceed the memory usage limit.
611 In addition to CPU-intensive worker threads,
612 .B xz
613 may use a few auxiliary threads, which don't use a lot of CPU time.
614 .IP
615 .B "Multithreaded compression and decompression are not implemented yet,"
616 .B "so this option has no effect for now."
617 .SS Custom compressor filter chains
618 A custom filter chain allows specifying the compression settings in detail
619 instead of relying on the settings associated to the preset levels.
620 When a custom filter chain is specified, the compression preset level options
621 (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR) are silently ignored.
622 .PP
623 A filter chain is comparable to piping on the UN*X command line.
624 When compressing, the uncompressed input goes to the first filter, whose
625 output goes to the next filter (if any). The output of the last filter
626 gets written to the compressed file. The maximum number of filters in
627 the chain is four, but typically a filter chain has only one or two filters.
628 .PP
629 Many filters have limitations where they can be in the filter chain:
630 some filters can work only as the last filter in the chain, some only
631 as a non-last filter, and some work in any position in the chain. Depending
632 on the filter, this limitation is either inherent to the filter design or
633 exists to prevent security issues.
634 .PP
635 A custom filter chain is specified by using one or more filter options in
636 the order they are wanted in the filter chain. That is, the order of filter
637 options is significant! When decoding raw streams
638 .RB ( \-\-format=raw ),
639 the filter chain is specified in the same order as it was specified when
640 compressing.
641 .PP
642 Filters take filter-specific
643 .I options
644 as a comma-separated list. Extra commas in
645 .I options
646 are ignored. Every option has a default value, so you need to
647 specify only those you want to change.
648 .TP
649 \fB\-\-lzma1\fR[\fB=\fIoptions\fR], \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
650 Add LZMA1 or LZMA2 filter to the filter chain. These filter can be used
651 only as the last filter in the chain.
652 .IP
653 LZMA1 is a legacy filter, which is supported almost solely due to the legacy
654 .B .lzma
655 file format, which supports only LZMA1. LZMA2 is an updated
656 version of LZMA1 to fix some practical issues of LZMA1. The
657 .B .xz
658 format uses LZMA2, and doesn't support LZMA1 at all. Compression speed and
659 ratios of LZMA1 and LZMA2 are practically the same.
660 .IP
661 LZMA1 and LZMA2 share the same set of
662 .IR options :
663 .RS
664 .TP
665 .BI preset= preset
666 Reset all LZMA1 or LZMA2
667 .I options
668 to
669 .IR preset .
670 .I Preset
671 consist of an integer, which may be followed by single-letter preset
672 modifiers. The integer can be from
673 .B 0
674 to
675 .BR 9 ,
676 matching the command line options \fB\-0\fR ... \fB\-9\fR.
677 The only supported modifier is currently
678 .BR e ,
679 which matches
680 .BR \-\-extreme .
681 .IP
682 The default
683 .I preset
684 is
685 .BR 6 ,
686 from which the default values for the rest of the LZMA1 or LZMA2
687 .I options
688 are taken.
689 .TP
690 .BI dict= size
691 Dictionary (history buffer) size indicates how many bytes of the recently
692 processed uncompressed data is kept in memory. One method to reduce size of
693 the uncompressed data is to store distance-length pairs, which
694 indicate what data to repeat from the dictionary buffer. The bigger
695 the dictionary, the better the compression ratio usually is,
696 but dictionaries bigger than the uncompressed data are waste of RAM.
697 .IP
698 Typical dictionary size is from 64 KiB to 64 MiB. The minimum is 4 KiB.
699 The maximum for compression is currently 1.5 GiB. The decompressor already
700 supports dictionaries up to one byte less than 4 GiB, which is the
701 maximum for LZMA1 and LZMA2 stream formats.
702 .IP
703 Dictionary size has the biggest effect on compression ratio.
704 Dictionary size and match finder together determine the memory usage of
705 the LZMA1 or LZMA2 encoder. The same dictionary size is required
706 for decompressing that was used when compressing, thus the memory usage of
707 the decoder is determined by the dictionary size used when compressing.
708 .TP
709 .BI lc= lc
710 Specify the number of literal context bits. The minimum is
711 .B 0
712 and the maximum is
713 .BR 4 ;
714 the default is
715 .BR 3 .
716 In addition, the sum of
717 .I lc
718 and
719 .I lp
720 must not exceed
721 .BR 4 .
722 .TP
723 .BI lp= lp
724 Specify the number of literal position bits. The minimum is
725 .B 0
726 and the maximum is
727 .BR 4 ;
728 the default is
729 .BR 0 .
730 .TP
731 .BI pb= pb
732 Specify the number of position bits. The minimum is
733 .B 0
734 and the maximum is
735 .BR 4 ;
736 the default is
737 .BR 2 .
738 .TP
739 .BI mode= mode
740 Compression
741 .I mode
742 specifies the function used to analyze the data produced by the match finder.
743 Supported
744 .I modes
745 are
746 .B fast
747 and
748 .BR normal .
749 The default is
750 .B fast
751 for
752 .I presets
753 .BR 0 \- 2
754 and
755 .B normal
756 for
757 .I presets
758 .BR 3 \- 9 .
759 .TP
760 .BI mf= mf
761 Match finder has a major effect on encoder speed, memory usage, and
762 compression ratio. Usually Hash Chain match finders are faster than
763 Binary Tree match finders. Hash Chains are usually used together with
764 .B mode=fast
765 and Binary Trees with
766 .BR mode=normal .
767 The memory usage formulas are only rough estimates,
768 which are closest to reality when
769 .I dict
770 is a power of two.
771 .RS
772 .TP
773 .B hc3
774 Hash Chain with 2- and 3-byte hashing
775 .br
776 Minimum value for
777 .IR nice :
778 3
779 .br
780 Memory usage:
781 .I dict
782 * 7.5 (if
783 .I dict
784 <= 16 MiB);
785 .br
786 .I dict
787 * 5.5 + 64 MiB (if
788 .I dict
789 > 16 MiB)
790 .TP
791 .B hc4
792 Hash Chain with 2-, 3-, and 4-byte hashing
793 .br
794 Minimum value for
795 .IR nice :
796 4
797 .br
798 Memory usage:
799 .I dict
800 * 7.5
801 .TP
802 .B bt2
803 Binary Tree with 2-byte hashing
804 .br
805 Minimum value for
806 .IR nice :
807 2
808 .br
809 Memory usage:
810 .I dict
811 * 9.5
812 .TP
813 .B bt3
814 Binary Tree with 2- and 3-byte hashing
815 .br
816 Minimum value for
817 .IR nice :
818 3
819 .br
820 Memory usage:
821 .I dict
822 * 11.5 (if
823 .I dict
824 <= 16 MiB);
825 .br
826 .I dict
827 * 9.5 + 64 MiB (if
828 .I dict
829 > 16 MiB)
830 .TP
831 .B bt4
832 Binary Tree with 2-, 3-, and 4-byte hashing
833 .br
834 Minimum value for
835 .IR nice :
836 4
837 .br
838 Memory usage:
839 .I dict
840 * 11.5
841 .RE
842 .TP
843 .BI nice= nice
844 Specify what is considered to be a nice length for a match. Once a match
845 of at least
846 .I nice
847 bytes is found, the algorithm stops looking for possibly better matches.
848 .IP
849 .I nice
850 can be 2\-273 bytes. Higher values tend to give better compression ratio
851 at expense of speed. The default depends on the
852 .I preset
853 level.
854 .TP
855 .BI depth= depth
856 Specify the maximum search depth in the match finder. The default is the
857 special value
858 .BR 0 ,
859 which makes the compressor determine a reasonable
860 .I depth
861 from
862 .I mf
863 and
864 .IR nice .
865 .IP
866 Using very high values for
867 .I depth
868 can make the encoder extremely slow with carefully crafted files.
869 Avoid setting the
870 .I depth
871 over 1000 unless you are prepared to interrupt the compression in case it
872 is taking too long.
873 .RE
874 .IP
875 When decoding raw streams
876 .RB ( \-\-format=raw ),
877 LZMA2 needs only the value of
878 .BR dict .
879 LZMA1 needs also
880 .BR lc ,
881 .BR lp ,
882 and
883 .BR pb.
884 .TP
885 \fB\-\-x86\fR[\fB=\fIoptions\fR]
886 .TP
887 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
888 .TP
889 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
890 .TP
891 \fB\-\-arm\fR[\fB=\fIoptions\fR]
892 .TP
893 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
894 .TP
895 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
896 Add a branch/call/jump (BCJ) filter to the filter chain. These filters
897 can be used only as non-last filter in the filter chain.
898 .IP
899 A BCJ filter converts relative addresses in the machine code to their
900 absolute counterparts. This doesn't change the size of the data, but
901 it increases redundancy, which allows e.g. LZMA2 to get better
902 compression ratio.
903 .IP
904 The BCJ filters are always reversible, so using a BCJ filter for wrong
905 type of data doesn't cause any data loss. However, applying a BCJ filter
906 for wrong type of data is a bad idea, because it tends to make the
907 compression ratio worse.
908 .IP
909 Different instruction sets have have different alignment:
910 .RS
911 .RS
912 .TS
913 tab(;);
914 l n l
915 l n l.
916 Filter;Alignment;Notes
917 x86;1;32-bit and 64-bit x86
918 PowerPC;4;Big endian only
919 ARM;4;Little endian only
920 ARM-Thumb;2;Little endian only
921 IA-64;16;Big or little endian
922 SPARC;4;Big or little endian
923 .TE
924 .RE
925 .RE
926 .IP
927 Since the BCJ-filtered data is usually compressed with LZMA2, the compression
928 ratio may be improved slightly if the LZMA2 options are set to match the
929 alignment of the selected BCJ filter. For example, with the IA-64 filter,
930 it's good to set
931 .B pb=4
932 with LZMA2 (2^4=16). The x86 filter is an exception; it's usually good to
933 stick to LZMA2's default four-byte alignment when compressing x86 executables.
934 .IP
935 All BCJ filters support the same
936 .IR options :
937 .RS
938 .TP
939 .BI start= offset
940 Specify the start
941 .I offset
942 that is used when converting between relative and absolute addresses.
943 The
944 .I offset
945 must be a multiple of the alignment of the filter (see the table above).
946 The default is zero. In practice, the default is good; specifying
947 a custom
948 .I offset
949 is almost never useful.
950 .IP
951 Specifying a non-zero start
952 .I offset
953 is probably useful only if the executable has multiple sections, and there
954 are many cross-section jumps or calls. Applying a BCJ filter separately for
955 each section with proper start offset and then compressing the result as
956 a single chunk may give some improvement in compression ratio compared
957 to applying the BCJ filter with the default
958 .I offset
959 for the whole executable.
960 .RE
961 .TP
962 \fB\-\-delta\fR[\fB=\fIoptions\fR]
963 Add Delta filter to the filter chain. The Delta filter
964 can be used only as non-last filter in the filter chain.
965 .IP
966 Currently only simple byte-wise delta calculation is supported. It can
967 be useful when compressing e.g. uncompressed bitmap images or uncompressed
968 PCM audio. However, special purpose algorithms may give significantly better
969 results than Delta + LZMA2. This is true especially with audio, which
970 compresses faster and better e.g. with FLAC.
971 .IP
972 Supported
973 .IR options :
974 .RS
975 .TP
976 .BI dist= distance
977 Specify the
978 .I distance
979 of the delta calculation as bytes.
980 .I distance
981 must be 1\-256. The default is 1.
982 .IP
983 For example, with
984 .B dist=2
985 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
986 A1 B1 01 02 01 02 01 02.
987 .RE
988 .SS "Other options"
989 .TP
990 .BR \-q ", " \-\-quiet
991 Suppress warnings and notices. Specify this twice to suppress errors too.
992 This option has no effect on the exit status. That is, even if a warning
993 was suppressed, the exit status to indicate a warning is still used.
994 .TP
995 .BR \-v ", " \-\-verbose
996 Be verbose. If standard error is connected to a terminal,
997 .B xz
998 will display a progress indicator.
999 Specifying
1000 .B \-\-verbose
1001 twice will give even more verbose output (useful mostly for debugging).
1002 .IP
1003 The progress indicator shows the following information:
1004 .RS
1005 .IP \(bu 3
1006 Completion percentage is shown if the size of the input file is known.
1007 That is, percentage cannot be shown in pipes.
1008 .IP \(bu 3
1009 Amount of compressed data produced (compressing) or consumed (decompressing).
1010 .IP \(bu 3
1011 Amount of uncompressed data consumed (compressing) or produced
1012 (decompressing).
1013 .IP \(bu 3
1014 Compression ratio, which is calculated by dividing the amount of
1015 compressed data processed so far by the amount of uncompressed data
1016 processed so far.
1017 .IP \(bu 3
1018 Compression or decompression speed. This is measured as the amount of
1019 uncompressed data consumed (compression) or produced (decompression)
1020 per second. It is shown once a few seconds have passed since
1021 .B xz
1022 started processing the file.
1023 .IP \(bu 3
1024 Elapsed time or estimated time remaining.
1025 Elapsed time is displayed in the format M:SS or H:MM:SS.
1026 The estimated remaining time is displayed in a less precise format
1027 which never has colons, for example, 2 min 30 s. The estimate can
1028 be shown only when the size of the input file is known and a couple of
1029 seconds have already passed since
1030 .B xz
1031 started processing the file.
1032 .RE
1033 .IP
1034 When standard error is not a terminal,
1035 .B \-\-verbose
1036 will make
1037 .B xz
1038 print the filename, compressed size, uncompressed size, compression ratio,
1039 speed, and elapsed time on a single line to standard error after
1040 compressing or decompressing the file. If operating took at least a few
1041 seconds, also the speed and elapsed time are printed. If the operation
1042 didn't finish, for example due to user interruption, also the completion
1043 percentage is printed if the size of the input file is known.
1044 .TP
1045 .BR \-Q ", " \-\-no\-warn
1046 Don't set the exit status to
1047 .B 2
1048 even if a condition worth a warning was detected. This option doesn't affect
1049 the verbosity level, thus both
1050 .B \-\-quiet
1051 and
1052 .B \-\-no\-warn
1053 have to be used to not display warnings and to not alter the exit status.
1054 .TP
1055 .BR \-h ", " \-\-help
1056 Display a help message describing the most commonly used options,
1057 and exit successfully.
1058 .TP
1059 .BR \-H ", " \-\-long\-help
1060 Display a help message describing all features of
1061 .BR xz ,
1062 and exit successfully
1063 .TP
1064 .BR \-V ", " \-\-version
1065 Display the version number of
1066 .B xz
1067 and liblzma.
1068 .SH "EXIT STATUS"
1069 .TP
1070 .B 0
1071 All is good.
1072 .TP
1073 .B 1
1074 An error occurred.
1075 .TP
1076 .B 2
1077 Something worth a warning occurred, but no actual errors occurred.
1078 .PP
1079 Notices (not warnings or errors) printed on standard error don't affect
1080 the exit status.
1081 .SH ENVIRONMENT
1082 .TP
1083 .B XZ_OPT
1084 A space-separated list of options is parsed from
1085 .B XZ_OPT
1086 before parsing the options given on the command line. Note that only
1087 options are parsed from
1088 .BR XZ_OPT ;
1089 all non-options are silently ignored. Parsing is done with
1090 .BR getopt_long (3)
1091 which is used also for the command line arguments.
1092 .SH "LZMA UTILS COMPATIBILITY"
1093 The command line syntax of
1094 .B xz
1095 is practically a superset of
1096 .BR lzma ,
1097 .BR unlzma ,
1098 and
1099 .BR lzcat
1100 as found from LZMA Utils 4.32.x. In most cases, it is possible to replace
1101 LZMA Utils with XZ Utils without breaking existing scripts. There are some
1102 incompatibilities though, which may sometimes cause problems.
1103 .SS "Compression preset levels"
1104 The numbering of the compression level presets is not identical in
1105 .B xz
1106 and LZMA Utils.
1107 The most important difference is how dictionary sizes are mapped to different
1108 presets. Dictionary size is roughly equal to the decompressor memory usage.
1109 .RS
1110 .TS
1111 tab(;);
1112 c c c
1113 c n n.
1114 Level;xz;LZMA Utils
1115 \-1;64 KiB;64 KiB
1116 \-2;512 KiB;1 MiB
1117 \-3;1 MiB;512 KiB
1118 \-4;2 MiB;1 MiB
1119 \-5;4 MiB;2 MiB
1120 \-6;8 MiB;4 MiB
1121 \-7;16 MiB;8 MiB
1122 \-8;32 MiB;16 MiB
1123 \-9;64 MiB;32 MiB
1124 .TE
1125 .RE
1126 .PP
1127 The dictionary size differences affect the compressor memory usage too,
1128 but there are some other differences between LZMA Utils and XZ Utils, which
1129 make the difference even bigger:
1130 .RS
1131 .TS
1132 tab(;);
1133 c c c
1134 c n n.
1135 Level;xz;LZMA Utils 4.32.x
1136 \-1;2 MiB;2 MiB
1137 \-2;5 MiB;12 MiB
1138 \-3;13 MiB;12 MiB
1139 \-4;25 MiB;16 MiB
1140 \-5;48 MiB;26 MiB
1141 \-6;94 MiB;45 MiB
1142 \-7;186 MiB;83 MiB
1143 \-8;370 MiB;159 MiB
1144 \-9;674 MiB;311 MiB
1145 .TE
1146 .RE
1147 .PP
1148 The default preset level in LZMA Utils is
1149 .B \-7
1150 while in XZ Utils it is
1151 .BR \-6 ,
1152 so both use 8 MiB dictionary by default.
1153 .SS "Streamed vs. non-streamed .lzma files"
1154 Uncompressed size of the file can be stored in the
1155 .B .lzma
1156 header. LZMA Utils does that when compressing regular files.
1157 The alternative is to mark that uncompressed size is unknown and
1158 use end of payload marker to indicate where the decompressor should stop.
1159 LZMA Utils uses this method when uncompressed size isn't known, which is
1160 the case for example in pipes.
1161 .PP
1162 .B xz
1163 supports decompressing
1164 .B .lzma
1165 files with or without end of payload marker, but all
1166 .B .lzma
1167 files created by
1168 .B xz
1169 will use end of payload marker and have uncompressed size marked as unknown
1170 in the
1171 .B .lzma
1172 header. This may be a problem in some (uncommon) situations. For example, a
1173 .B .lzma
1174 decompressor in an embedded device might work only with files that have known
1175 uncompressed size. If you hit this problem, you need to use LZMA Utils or
1176 LZMA SDK to create
1177 .B .lzma
1178 files with known uncompressed size.
1179 .SS "Unsupported .lzma files"
1180 The
1181 .B .lzma
1182 format allows
1183 .I lc
1184 values up to 8, and
1185 .I lp
1186 values up to 4. LZMA Utils can decompress files with any
1187 .I lc
1188 and
1189 .IR lp ,
1190 but always creates files with
1191 .B lc=3
1192 and
1193 .BR lp=0 .
1194 Creating files with other
1195 .I lc
1196 and
1197 .I lp
1198 is possible with
1199 .B xz
1200 and with LZMA SDK.
1201 .PP
1202 The implementation of the LZMA1 filter in liblzma requires
1203 that the sum of
1204 .I lc
1205 and
1206 .I lp
1207 must not exceed 4. Thus,
1208 .B .lzma
1209 files which exceed this limitation, cannot be decompressed with
1210 .BR xz .
1211 .PP
1212 LZMA Utils creates only
1213 .B .lzma
1214 files which have dictionary size of
1215 .RI "2^" n
1216 (a power of 2), but accepts files with any dictionary size.
1217 liblzma accepts only
1218 .B .lzma
1219 files which have dictionary size of
1220 .RI "2^" n
1221 or
1222 .RI "2^" n " + 2^(" n "\-1)."
1223 This is to decrease false positives when autodetecting
1224 .B .lzma
1225 files.
1226 .PP
1227 These limitations shouldn't be a problem in practice, since practically all
1228 .B .lzma
1229 files have been compressed with settings that liblzma will accept.
1230 .SS "Trailing garbage"
1231 When decompressing, LZMA Utils silently ignore everything after the first
1232 .B .lzma
1233 stream. In most situations, this is a bug. This also means that LZMA Utils
1234 don't support decompressing concatenated
1235 .B .lzma
1236 files.
1237 .PP
1238 If there is data left after the first
1239 .B .lzma
1240 stream,
1241 .B xz
1242 considers the file to be corrupt. This may break obscure scripts which have
1243 assumed that trailing garbage is ignored.
1244 .SH NOTES
1245 .SS Compressed output may vary
1246 The exact compressed output produced from the same uncompressed input file
1247 may vary between XZ Utils versions even if compression options are identical.
1248 This is because the encoder can be improved (faster or better compression)
1249 without affecting the file format. The output can vary even between different
1250 builds of the same XZ Utils version, if different build options are used.
1251 .PP
1252 The above means that implementing
1253 .B \-\-rsyncable
1254 to create rsyncable
1255 .B .xz
1256 files is not going to happen without freezing a part of the encoder
1257 implementation, which can then be used with
1258 .BR \-\-rsyncable .
1259 .SS Embedded .xz decompressors
1260 Embedded
1261 .B .xz
1262 decompressor implementations like XZ Embedded don't necessarily support files
1263 created with
1264 .I check
1265 types other than
1266 .B none
1267 and
1268 .BR crc32 .
1269 Since the default is \fB\-\-check=\fIcrc64\fR, you must use
1270 .B \-\-check=none
1271 or
1272 .B \-\-check=crc32
1273 when creating files for embedded systems.
1274 .PP
1275 Outside embedded systems, all
1276 .B .xz
1277 format decompressors support all the
1278 .I check
1279 types, or at least are able to decompress the file without verifying the
1280 integrity check if the particular
1281 .I check
1282 is not supported.
1283 .PP
1284 XZ Embedded supports BCJ filters, but only with the default start offset.
1285 .SH "SEE ALSO"
1286 .BR xzdec (1),
1287 .BR gzip (1),
1288 .BR bzip2 (1)
1289 .PP
1290 XZ Utils: <http://tukaani.org/xz/>
1291 .br
1292 XZ Embedded: <http://tukaani.org/xz/embedded.html>
1293 .br
1294 LZMA SDK: <http://7-zip.org/sdk.html>