Import xz-5.0.0.
[dragonfly.git] / contrib / xz / 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 "2010-10-04" "Tukaani" "XZ Utils"
9 .
10 .SH NAME
11 xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
12 .
13 .SH SYNOPSIS
14 .B xz
15 .RI [ option ]...
16 .RI [ file ]...
17 .PP
18 .B unxz
19 is equivalent to
20 .BR "xz \-\-decompress" .
21 .br
22 .B xzcat
23 is equivalent to
24 .BR "xz \-\-decompress \-\-stdout" .
25 .br
26 .B lzma
27 is equivalent to
28 .BR "xz \-\-format=lzma" .
29 .br
30 .B unlzma
31 is equivalent to
32 .BR "xz \-\-format=lzma \-\-decompress" .
33 .br
34 .B lzcat
35 is equivalent to
36 .BR "xz \-\-format=lzma \-\-decompress \-\-stdout" .
37 .PP
38 When writing scripts that need to decompress files,
39 it is recommended to always use the name
40 .B xz
41 with appropriate arguments
42 .RB ( "xz \-d"
43 or
44 .BR "xz \-dc" )
45 instead of the names
46 .B unxz
47 and
48 .BR xzcat .
49 .
50 .SH DESCRIPTION
51 .B xz
52 is a general-purpose data compression tool with
53 command line syntax similar to
54 .BR gzip (1)
55 and
56 .BR bzip2 (1).
57 The native file format is the
58 .B .xz
59 format, but the legacy
60 .B .lzma
61 format used by LZMA Utils and
62 raw compressed streams with no container format headers
63 are also supported.
64 .PP
65 .B xz
66 compresses or decompresses each
67 .I file
68 according to the selected operation mode.
69 If no
70 .I files
71 are given or
72 .I file
73 is
74 .BR \- ,
75 .B xz
76 reads from standard input and writes the processed data
77 to standard output.
78 .B xz
79 will refuse (display an error and skip the
80 .IR file )
81 to write compressed data to standard output if it is a terminal.
82 Similarly,
83 .B xz
84 will refuse to read compressed data
85 from standard input if it is a terminal.
86 .PP
87 Unless
88 .B \-\-stdout
89 is specified,
90 .I files
91 other than
92 .B \-
93 are written to a new file whose name is derived from the source
94 .I file
95 name:
96 .IP \(bu 3
97 When compressing, the suffix of the target file format
98 .RB ( .xz
99 or
100 .BR .lzma )
101 is appended to the source filename to get the target filename.
102 .IP \(bu 3
103 When decompressing, the
104 .B .xz
105 or
106 .B .lzma
107 suffix is removed from the filename to get the target filename.
108 .B xz
109 also recognizes the suffixes
110 .B .txz
111 and
112 .BR .tlz ,
113 and replaces them with the
114 .B .tar
115 suffix.
116 .PP
117 If the target file already exists, an error is displayed and the
118 .I file
119 is skipped.
120 .PP
121 Unless writing to standard output,
122 .B xz
123 will display a warning and skip the
124 .I file
125 if any of the following applies:
126 .IP \(bu 3
127 .I File
128 is not a regular file.
129 Symbolic links are not followed,
130 and thus they are not considered to be regular files.
131 .IP \(bu 3
132 .I File
133 has more than one hard link.
134 .IP \(bu 3
135 .I File
136 has setuid, setgid, or sticky bit set.
137 .IP \(bu 3
138 The operation mode is set to compress and the
139 .I file
140 already has a suffix of the target file format
141 .RB ( .xz
142 or
143 .B .txz
144 when compressing to the
145 .B .xz
146 format, and
147 .B .lzma
148 or
149 .B .tlz
150 when compressing to the
151 .B .lzma
152 format).
153 .IP \(bu 3
154 The operation mode is set to decompress and the
155 .I file
156 doesn't have a suffix of any of the supported file formats
157 .RB ( .xz ,
158 .BR .txz ,
159 .BR .lzma ,
160 or
161 .BR .tlz ).
162 .PP
163 After successfully compressing or decompressing the
164 .IR file ,
165 .B xz
166 copies the owner, group, permissions, access time,
167 and modification time from the source
168 .I file
169 to the target file.
170 If copying the group fails, the permissions are modified
171 so that the target file doesn't become accessible to users
172 who didn't have permission to access the source
173 .IR file .
174 .B xz
175 doesn't support copying other metadata like access control lists
176 or extended attributes yet.
177 .PP
178 Once the target file has been successfully closed, the source
179 .I file
180 is removed unless
181 .B \-\-keep
182 was specified.
183 The source
184 .I file
185 is never removed if the output is written to standard output.
186 .PP
187 Sending
188 .B SIGINFO
189 or
190 .B SIGUSR1
191 to the
192 .B xz
193 process makes it print progress information to standard error.
194 This has only limited use since when standard error
195 is a terminal, using
196 .B \-\-verbose
197 will display an automatically updating progress indicator.
198 .
199 .SS "Memory usage"
200 The memory usage of
201 .B xz
202 varies from a few hundred kilobytes to several gigabytes
203 depending on the compression settings.
204 The settings used when compressing a file determine
205 the memory requirements of the decompressor.
206 Typically the decompressor needs 5\ % to 20\ % of
207 the amount of memory that the compressor needed when
208 creating the file.
209 For example, decompressing a file created with
210 .B xz \-9
211 currently requires 65\ MiB of memory.
212 Still, it is possible to have
213 .B .xz
214 files that require several gigabytes of memory to decompress.
215 .PP
216 Especially users of older systems may find
217 the possibility of very large memory usage annoying.
218 To prevent uncomfortable surprises,
219 .B xz
220 has a built-in memory usage limiter, which is disabled by default.
221 While some operating systems provide ways to limit
222 the memory usage of processes, relying on it
223 wasn't deemed to be flexible enough (e.g. using
224 .BR ulimit (1)
225 to limit virtual memory tends to cripple
226 .BR mmap (2)).
227 .PP
228 The memory usage limiter can be enabled with
229 the command line option \fB\-\-memlimit=\fIlimit\fR.
230 Often it is more convenient to enable the limiter
231 by default by setting the environment variable
232 .BR XZ_DEFAULTS ,
233 e.g.\&
234 .BR XZ_DEFAULTS=\-\-memlimit=150MiB .
235 It is possible to set the limits separately
236 for compression and decompression
237 by using \fB\-\-memlimit\-compress=\fIlimit\fR and
238 \fB\-\-memlimit\-decompress=\fIlimit\fR.
239 Using these two options outside
240 .B XZ_DEFAULTS
241 is rarely useful because a single run of
242 .B xz
243 cannot do both compression and decompression and
244 .BI \-\-memlimit= limit
245 (or \fB\-M\fR \fIlimit\fR)
246 is shorter to type on the command line.
247 .PP
248 If the specified memory usage limit is exceeded when decompressing,
249 .B xz
250 will display an error and decompressing the file will fail.
251 If the limit is exceeded when compressing,
252 .B xz
253 will try to scale the settings down so that the limit
254 is no longer exceeded (except when using \fB\-\-format=raw\fR
255 or \fB\-\-no\-adjust\fR).
256 This way the operation won't fail unless the limit is very small.
257 The scaling of the settings is done in steps that don't
258 match the compression level presets, e.g. if the limit is
259 only slightly less than the amount required for
260 .BR "xz \-9" ,
261 the settings will be scaled down only a little,
262 not all the way down to
263 .BR "xz \-8" .
264 .
265 .SS "Concatenation and padding with .xz files"
266 It is possible to concatenate
267 .B .xz
268 files as is.
269 .B xz
270 will decompress such files as if they were a single
271 .B .xz
272 file.
273 .PP
274 It is possible to insert padding between the concatenated parts
275 or after the last part.
276 The padding must consist of null bytes and the size
277 of the padding must be a multiple of four bytes.
278 This can be useful e.g. if the
279 .B .xz
280 file is stored on a medium that measures file sizes
281 in 512-byte blocks.
282 .PP
283 Concatenation and padding are not allowed with
284 .B .lzma
285 files or raw streams.
286 .
287 .SH OPTIONS
288 .
289 .SS "Integer suffixes and special values"
290 In most places where an integer argument is expected,
291 an optional suffix is supported to easily indicate large integers.
292 There must be no space between the integer and the suffix.
293 .TP
294 .B KiB
295 Multiply the integer by 1,024 (2^10).
296 .BR Ki ,
297 .BR k ,
298 .BR kB ,
299 .BR K ,
300 and
301 .B KB
302 are accepted as synonyms for
303 .BR KiB .
304 .TP
305 .B MiB
306 Multiply the integer by 1,048,576 (2^20).
307 .BR Mi ,
308 .BR m ,
309 .BR M ,
310 and
311 .B MB
312 are accepted as synonyms for
313 .BR MiB .
314 .TP
315 .B GiB
316 Multiply the integer by 1,073,741,824 (2^30).
317 .BR Gi ,
318 .BR g ,
319 .BR G ,
320 and
321 .B GB
322 are accepted as synonyms for
323 .BR GiB .
324 .PP
325 The special value
326 .B max
327 can be used to indicate the maximum integer value
328 supported by the option.
329 .
330 .SS "Operation mode"
331 If multiple operation mode options are given,
332 the last one takes effect.
333 .TP
334 .BR \-z ", " \-\-compress
335 Compress.
336 This is the default operation mode when no operation mode option
337 is specified and no other operation mode is implied from
338 the command name (for example,
339 .B unxz
340 implies
341 .BR \-\-decompress ).
342 .TP
343 .BR \-d ", " \-\-decompress ", " \-\-uncompress
344 Decompress.
345 .TP
346 .BR \-t ", " \-\-test
347 Test the integrity of compressed
348 .IR files .
349 This option is equivalent to
350 .B "\-\-decompress \-\-stdout"
351 except that the decompressed data is discarded instead of being
352 written to standard output.
353 No files are created or removed.
354 .TP
355 .BR \-l ", " \-\-list
356 Print information about compressed
357 .IR files .
358 No uncompressed output is produced,
359 and no files are created or removed.
360 In list mode, the program cannot read
361 the compressed data from standard
362 input or from other unseekable sources.
363 .IP ""
364 The default listing shows basic information about
365 .IR files ,
366 one file per line.
367 To get more detailed information, use also the
368 .B \-\-verbose
369 option.
370 For even more information, use
371 .B \-\-verbose
372 twice, but note that this may be slow, because getting all the extra
373 information requires many seeks.
374 The width of verbose output exceeds
375 80 characters, so piping the output to e.g.\&
376 .B "less\ \-S"
377 may be convenient if the terminal isn't wide enough.
378 .IP ""
379 The exact output may vary between
380 .B xz
381 versions and different locales.
382 For machine-readable output,
383 .B \-\-robot \-\-list
384 should be used.
385 .
386 .SS "Operation modifiers"
387 .TP
388 .BR \-k ", " \-\-keep
389 Don't delete the input files.
390 .TP
391 .BR \-f ", " \-\-force
392 This option has several effects:
393 .RS
394 .IP \(bu 3
395 If the target file already exists,
396 delete it before compressing or decompressing.
397 .IP \(bu 3
398 Compress or decompress even if the input is
399 a symbolic link to a regular file,
400 has more than one hard link,
401 or has the setuid, setgid, or sticky bit set.
402 The setuid, setgid, and sticky bits are not copied
403 to the target file.
404 .IP \(bu 3
405 When used with
406 .B \-\-decompress
407 .BR \-\-stdout
408 and
409 .B xz
410 cannot recognize the type of the source file,
411 copy the source file as is to standard output.
412 This allows
413 .B xzcat
414 .B \-\-force
415 to be used like
416 .BR cat (1)
417 for files that have not been compressed with
418 .BR xz .
419 Note that in future,
420 .B xz
421 might support new compressed file formats, which may make
422 .B xz
423 decompress more types of files instead of copying them as is to
424 standard output.
425 .BI \-\-format= format
426 can be used to restrict
427 .B xz
428 to decompress only a single file format.
429 .RE
430 .TP
431 .BR \-c ", " \-\-stdout ", " \-\-to\-stdout
432 Write the compressed or decompressed data to
433 standard output instead of a file.
434 This implies
435 .BR \-\-keep .
436 .TP
437 .B \-\-no\-sparse
438 Disable creation of sparse files.
439 By default, if decompressing into a regular file,
440 .B xz
441 tries to make the file sparse if the decompressed data contains
442 long sequences of binary zeros.
443 It also works when writing to standard output
444 as long as standard output is connected to a regular file
445 and certain additional conditions are met to make it safe.
446 Creating sparse files may save disk space and speed up
447 the decompression by reducing the amount of disk I/O.
448 .TP
449 \fB\-S\fR \fI.suf\fR, \fB\-\-suffix=\fI.suf
450 When compressing, use
451 .I .suf
452 as the suffix for the target file instead of
453 .B .xz
454 or
455 .BR .lzma .
456 If not writing to standard output and
457 the source file already has the suffix
458 .IR .suf ,
459 a warning is displayed and the file is skipped.
460 .IP ""
461 When decompressing, recognize files with the suffix
462 .I .suf
463 in addition to files with the
464 .BR .xz ,
465 .BR .txz ,
466 .BR .lzma ,
467 or
468 .B .tlz
469 suffix.
470 If the source file has the suffix
471 .IR .suf ,
472 the suffix is removed to get the target filename.
473 .IP ""
474 When compressing or decompressing raw streams
475 .RB ( \-\-format=raw ),
476 the suffix must always be specified unless
477 writing to standard output,
478 because there is no default suffix for raw streams.
479 .TP
480 \fB\-\-files\fR[\fB=\fIfile\fR]
481 Read the filenames to process from
482 .IR file ;
483 if
484 .I file
485 is omitted, filenames are read from standard input.
486 Filenames must be terminated with the newline character.
487 A dash
488 .RB ( \- )
489 is taken as a regular filename; it doesn't mean standard input.
490 If filenames are given also as command line arguments, they are
491 processed before the filenames read from
492 .IR file .
493 .TP
494 \fB\-\-files0\fR[\fB=\fIfile\fR]
495 This is identical to \fB\-\-files\fR[\fB=\fIfile\fR] except
496 that each filename must be terminated with the null character.
497 .
498 .SS "Basic file format and compression options"
499 .TP
500 \fB\-F\fR \fIformat\fR, \fB\-\-format=\fIformat
501 Specify the file
502 .I format
503 to compress or decompress:
504 .RS
505 .TP
506 .B auto
507 This is the default.
508 When compressing,
509 .B auto
510 is equivalent to
511 .BR xz .
512 When decompressing,
513 the format of the input file is automatically detected.
514 Note that raw streams (created with
515 .BR \-\-format=raw )
516 cannot be auto-detected.
517 .TP
518 .B xz
519 Compress to the
520 .B .xz
521 file format, or accept only
522 .B .xz
523 files when decompressing.
524 .TP
525 .BR lzma ", " alone
526 Compress to the legacy
527 .B .lzma
528 file format, or accept only
529 .B .lzma
530 files when decompressing.
531 The alternative name
532 .B alone
533 is provided for backwards compatibility with LZMA Utils.
534 .TP
535 .B raw
536 Compress or uncompress a raw stream (no headers).
537 This is meant for advanced users only.
538 To decode raw streams, you need use
539 .B \-\-format=raw
540 and explicitly specify the filter chain,
541 which normally would have been stored in the container headers.
542 .RE
543 .TP
544 \fB\-C\fR \fIcheck\fR, \fB\-\-check=\fIcheck
545 Specify the type of the integrity check.
546 The check is calculated from the uncompressed data and
547 stored in the
548 .B .xz
549 file.
550 This option has an effect only when compressing into the
551 .B .xz
552 format; the
553 .B .lzma
554 format doesn't support integrity checks.
555 The integrity check (if any) is verified when the
556 .B .xz
557 file is decompressed.
558 .IP ""
559 Supported
560 .I check
561 types:
562 .RS
563 .TP
564 .B none
565 Don't calculate an integrity check at all.
566 This is usually a bad idea.
567 This can be useful when integrity of the data is verified
568 by other means anyway.
569 .TP
570 .B crc32
571 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
572 .TP
573 .B crc64
574 Calculate CRC64 using the polynomial from ECMA-182.
575 This is the default, since it is slightly better than CRC32
576 at detecting damaged files and the speed difference is negligible.
577 .TP
578 .B sha256
579 Calculate SHA-256.
580 This is somewhat slower than CRC32 and CRC64.
581 .RE
582 .IP ""
583 Integrity of the
584 .B .xz
585 headers is always verified with CRC32.
586 It is not possible to change or disable it.
587 .TP
588 .BR \-0 " ... " \-9
589 Select a compression preset level.
590 The default is
591 .BR \-6 .
592 If multiple preset levels are specified,
593 the last one takes effect.
594 If a custom filter chain was already specified, setting
595 a compression preset level clears the custom filter chain.
596 .IP ""
597 The differences between the presets are more significant than with
598 .BR gzip (1)
599 and
600 .BR bzip2 (1).
601 The selected compression settings determine
602 the memory requirements of the decompressor,
603 thus using a too high preset level might make it painful
604 to decompress the file on an old system with little RAM.
605 Specifically,
606 .B "it's not a good idea to blindly use \-9 for everything"
607 like it often is with
608 .BR gzip (1)
609 and
610 .BR bzip2 (1).
611 .RS
612 .TP
613 .BR "\-0" " ... " "\-3"
614 These are somewhat fast presets.
615 .B \-0
616 is sometimes faster than
617 .B "gzip \-9"
618 while compressing much better.
619 The higher ones often have speed comparable to
620 .BR bzip2 (1)
621 with comparable or better compression ratio,
622 although the results
623 depend a lot on the type of data being compressed.
624 .TP
625 .BR "\-4" " ... " "\-6"
626 Good to very good compression while keeping
627 decompressor memory usage reasonable even for old systems.
628 .B \-6
629 is the default, which is usually a good choice
630 e.g. for distributing files that need to be decompressible
631 even on systems with only 16\ MiB RAM.
632 .RB ( \-5e
633 or
634 .B \-6e
635 may be worth considering too.
636 See
637 .BR \-\-extreme .)
638 .TP
639 .B "\-7 ... \-9"
640 These are like
641 .B \-6
642 but with higher compressor and decompressor memory requirements.
643 These are useful only when compressing files bigger than
644 8\ MiB, 16\ MiB, and 32\ MiB, respectively.
645 .RE
646 .IP ""
647 On the same hardware, the decompression speed is approximately
648 a constant number of bytes of compressed data per second.
649 In other words, the better the compression,
650 the faster the decompression will usually be.
651 This also means that the amount of uncompressed output
652 produced per second can vary a lot.
653 .IP ""
654 The following table summarises the features of the presets:
655 .RS
656 .RS
657 .PP
658 .TS
659 tab(;);
660 c c c c c
661 n n n n n.
662 Preset;DictSize;CompCPU;CompMem;DecMem
663 \-0;256 KiB;0;3 MiB;1 MiB
664 \-1;1 MiB;1;9 MiB;2 MiB
665 \-2;2 MiB;2;17 MiB;3 MiB
666 \-3;4 MiB;3;32 MiB;5 MiB
667 \-4;4 MiB;4;48 MiB;5 MiB
668 \-5;8 MiB;5;94 MiB;9 MiB
669 \-6;8 MiB;6;94 MiB;9 MiB
670 \-7;16 MiB;6;186 MiB;17 MiB
671 \-8;32 MiB;6;370 MiB;33 MiB
672 \-9;64 MiB;6;674 MiB;65 MiB
673 .TE
674 .RE
675 .RE
676 .IP ""
677 Column descriptions:
678 .RS
679 .IP \(bu 3
680 DictSize is the LZMA2 dictionary size.
681 It is waste of memory to use a dictionary bigger than
682 the size of the uncompressed file.
683 This is why it is good to avoid using the presets
684 .BR \-7 " ... " \-9
685 when there's no real need for them.
686 At
687 .B \-6
688 and lower, the amount of memory wasted is
689 usually low enough to not matter.
690 .IP \(bu 3
691 CompCPU is a simplified representation of the LZMA2 settings
692 that affect compression speed.
693 The dictionary size affects speed too,
694 so while CompCPU is the same for levels
695 .BR \-6 " ... " \-9 ,
696 higher levels still tend to be a little slower.
697 To get even slower and thus possibly better compression, see
698 .BR \-\-extreme .
699 .IP \(bu 3
700 CompMem contains the compressor memory requirements
701 in the single-threaded mode.
702 It may vary slightly between
703 .B xz
704 versions.
705 Memory requirements of some of the future multithreaded modes may
706 be dramatically higher than that of the single-threaded mode.
707 .IP \(bu 3
708 DecMem contains the decompressor memory requirements.
709 That is, the compression settings determine
710 the memory requirements of the decompressor.
711 The exact decompressor memory usage is slighly more than
712 the LZMA2 dictionary size, but the values in the table
713 have been rounded up to the next full MiB.
714 .RE
715 .TP
716 .BR \-e ", " \-\-extreme
717 Use a slower variant of the selected compression preset level
718 .RB ( \-0 " ... " \-9 )
719 to hopefully get a little bit better compression ratio,
720 but with bad luck this can also make it worse.
721 Decompressor memory usage is not affected,
722 but compressor memory usage increases a little at preset levels
723 .BR \-0 " ... " \-3 .
724 .IP ""
725 Since there are two presets with dictionary sizes
726 4\ MiB and 8\ MiB, the presets
727 .B \-3e
728 and
729 .B \-5e
730 use slightly faster settings (lower CompCPU) than
731 .B \-4e
732 and
733 .BR \-6e ,
734 respectively.
735 That way no two presets are identical.
736 .RS
737 .RS
738 .PP
739 .TS
740 tab(;);
741 c c c c c
742 n n n n n.
743 Preset;DictSize;CompCPU;CompMem;DecMem
744 \-0e;256 KiB;8;4 MiB;1 MiB
745 \-1e;1 MiB;8;13 MiB;2 MiB
746 \-2e;2 MiB;8;25 MiB;3 MiB
747 \-3e;4 MiB;7;48 MiB;5 MiB
748 \-4e;4 MiB;8;48 MiB;5 MiB
749 \-5e;8 MiB;7;94 MiB;9 MiB
750 \-6e;8 MiB;8;94 MiB;9 MiB
751 \-7e;16 MiB;8;186 MiB;17 MiB
752 \-8e;32 MiB;8;370 MiB;33 MiB
753 \-9e;64 MiB;8;674 MiB;65 MiB
754 .TE
755 .RE
756 .RE
757 .IP ""
758 For example, there are a total of four presets that use
759 8\ MiB dictionary, whose order from the fastest to the slowest is
760 .BR \-5 ,
761 .BR \-6 ,
762 .BR \-5e ,
763 and
764 .BR \-6e .
765 .TP
766 .B \-\-fast
767 .PD 0
768 .TP
769 .B \-\-best
770 .PD
771 These are somewhat misleading aliases for
772 .B \-0
773 and
774 .BR \-9 ,
775 respectively.
776 These are provided only for backwards compatibility
777 with LZMA Utils.
778 Avoid using these options.
779 .TP
780 .BI \-\-memlimit\-compress= limit
781 Set a memory usage limit for compression.
782 If this option is specified multiple times,
783 the last one takes effect.
784 .IP ""
785 If the compression settings exceed the
786 .IR limit ,
787 .B xz
788 will adjust the settings downwards so that
789 the limit is no longer exceeded and display a notice that
790 automatic adjustment was done.
791 Such adjustments are not made when compressing with
792 .B \-\-format=raw
793 or if
794 .B \-\-no\-adjust
795 has been specified.
796 In those cases, an error is displayed and
797 .B xz
798 will exit with exit status 1.
799 .IP ""
800 The
801 .I limit
802 can be specified in multiple ways:
803 .RS
804 .IP \(bu 3
805 The
806 .I limit
807 can be an absolute value in bytes.
808 Using an integer suffix like
809 .B MiB
810 can be useful.
811 Example:
812 .B "\-\-memlimit\-compress=80MiB"
813 .IP \(bu 3
814 The
815 .I limit
816 can be specified as a percentage of total physical memory (RAM).
817 This can be useful especially when setting the
818 .B XZ_DEFAULTS
819 environment variable in a shell initialization script
820 that is shared between different computers.
821 That way the limit is automatically bigger
822 on systems with more memory.
823 Example:
824 .B "\-\-memlimit\-compress=70%"
825 .IP \(bu 3
826 The
827 .I limit
828 can be reset back to its default value by setting it to
829 .BR 0 .
830 This is currently equivalent to setting the
831 .I limit
832 to
833 .B max
834 (no memory usage limit).
835 Once multithreading support has been implemented,
836 there may be a difference between
837 .B 0
838 and
839 .B max
840 for the multithreaded case, so it is recommended to use
841 .B 0
842 instead of
843 .B max
844 until the details have been decided.
845 .RE
846 .IP ""
847 See also the section
848 .BR "Memory usage" .
849 .TP
850 .BI \-\-memlimit\-decompress= limit
851 Set a memory usage limit for decompression.
852 This also affects the
853 .B \-\-list
854 mode.
855 If the operation is not possible without exceeding the
856 .IR limit ,
857 .B xz
858 will display an error and decompressing the file will fail.
859 See
860 .BI \-\-memlimit\-compress= limit
861 for possible ways to specify the
862 .IR limit .
863 .TP
864 \fB\-M\fR \fIlimit\fR, \fB\-\-memlimit=\fIlimit\fR, \fB\-\-memory=\fIlimit
865 This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
866 \fB\-\-memlimit\-decompress=\fIlimit\fR.
867 .TP
868 .B \-\-no\-adjust
869 Display an error and exit if the compression settings exceed the
870 the memory usage limit.
871 The default is to adjust the settings downwards so
872 that the memory usage limit is not exceeded.
873 Automatic adjusting is always disabled when creating raw streams
874 .RB ( \-\-format=raw ).
875 .TP
876 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
877 Specify the number of worker threads to use.
878 The actual number of threads can be less than
879 .I threads
880 if using more threads would exceed the memory usage limit.
881 .IP ""
882 .B "Multithreaded compression and decompression are not"
883 .B "implemented yet, so this option has no effect for now."
884 .IP ""
885 .B "As of writing (2010-09-27), it hasn't been decided"
886 .B "if threads will be used by default on multicore systems"
887 .B "once support for threading has been implemented."
888 .B "Comments are welcome."
889 The complicating factor is that using many threads
890 will increase the memory usage dramatically.
891 Note that if multithreading will be the default,
892 it will probably be done so that single-threaded and
893 multithreaded modes produce the same output,
894 so compression ratio won't be significantly affected
895 if threading will be enabled by default.
896 .
897 .SS "Custom compressor filter chains"
898 A custom filter chain allows specifying
899 the compression settings in detail instead of relying on
900 the settings associated to the preset levels.
901 When a custom filter chain is specified,
902 the compression preset level options
903 (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR) are
904 silently ignored.
905 .PP
906 A filter chain is comparable to piping on the command line.
907 When compressing, the uncompressed input goes to the first filter,
908 whose output goes to the next filter (if any).
909 The output of the last filter gets written to the compressed file.
910 The maximum number of filters in the chain is four,
911 but typically a filter chain has only one or two filters.
912 .PP
913 Many filters have limitations on where they can be
914 in the filter chain:
915 some filters can work only as the last filter in the chain,
916 some only as a non-last filter, and some work in any position
917 in the chain.
918 Depending on the filter, this limitation is either inherent to
919 the filter design or exists to prevent security issues.
920 .PP
921 A custom filter chain is specified by using one or more
922 filter options in the order they are wanted in the filter chain.
923 That is, the order of filter options is significant!
924 When decoding raw streams
925 .RB ( \-\-format=raw ),
926 the filter chain is specified in the same order as
927 it was specified when compressing.
928 .PP
929 Filters take filter-specific
930 .I options
931 as a comma-separated list.
932 Extra commas in
933 .I options
934 are ignored.
935 Every option has a default value, so you need to
936 specify only those you want to change.
937 .TP
938 \fB\-\-lzma1\fR[\fB=\fIoptions\fR]
939 .PD 0
940 .TP
941 \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
942 .PD
943 Add LZMA1 or LZMA2 filter to the filter chain.
944 These filters can be used only as the last filter in the chain.
945 .IP ""
946 LZMA1 is a legacy filter,
947 which is supported almost solely due to the legacy
948 .B .lzma
949 file format, which supports only LZMA1.
950 LZMA2 is an updated
951 version of LZMA1 to fix some practical issues of LZMA1.
952 The
953 .B .xz
954 format uses LZMA2 and doesn't support LZMA1 at all.
955 Compression speed and ratios of LZMA1 and LZMA2
956 are practically the same.
957 .IP ""
958 LZMA1 and LZMA2 share the same set of
959 .IR options :
960 .RS
961 .TP
962 .BI preset= preset
963 Reset all LZMA1 or LZMA2
964 .I options
965 to
966 .IR preset .
967 .I Preset
968 consist of an integer, which may be followed by single-letter
969 preset modifiers.
970 The integer can be from
971 .B 0
972 to
973 .BR 9 ,
974 matching the command line options \fB\-0\fR ... \fB\-9\fR.
975 The only supported modifier is currently
976 .BR e ,
977 which matches
978 .BR \-\-extreme .
979 The default
980 .I preset
981 is
982 .BR 6 ,
983 from which the default values for the rest of the LZMA1 or LZMA2
984 .I options
985 are taken.
986 .TP
987 .BI dict= size
988 Dictionary (history buffer)
989 .I size
990 indicates how many bytes of the recently processed
991 uncompressed data is kept in memory.
992 The algorithm tries to find repeating byte sequences (matches) in
993 the uncompressed data, and replace them with references
994 to the data currently in the dictionary.
995 The bigger the dictionary, the higher is the chance
996 to find a match.
997 Thus, increasing dictionary
998 .I size
999 usually improves compression ratio, but
1000 a dictionary bigger than the uncompressed file is waste of memory.
1001 .IP ""
1002 Typical dictionary
1003 .I size
1004 is from 64\ KiB to 64\ MiB.
1005 The minimum is 4\ KiB.
1006 The maximum for compression is currently 1.5\ GiB (1536\ MiB).
1007 The decompressor already supports dictionaries up to
1008 one byte less than 4\ GiB, which is the maximum for
1009 the LZMA1 and LZMA2 stream formats.
1010 .IP ""
1011 Dictionary
1012 .I size
1013 and match finder
1014 .RI ( mf )
1015 together determine the memory usage of the LZMA1 or LZMA2 encoder.
1016 The same (or bigger) dictionary
1017 .I size
1018 is required for decompressing that was used when compressing,
1019 thus the memory usage of the decoder is determined
1020 by the dictionary size used when compressing.
1021 The
1022 .B .xz
1023 headers store the dictionary
1024 .I size
1025 either as
1026 .RI "2^" n
1027 or
1028 .RI "2^" n " + 2^(" n "\-1),"
1029 so these
1030 .I sizes
1031 are somewhat preferred for compression.
1032 Other
1033 .I sizes
1034 will get rounded up when stored in the
1035 .B .xz
1036 headers.
1037 .TP
1038 .BI lc= lc
1039 Specify the number of literal context bits.
1040 The minimum is 0 and the maximum is 4; the default is 3.
1041 In addition, the sum of
1042 .I lc
1043 and
1044 .I lp
1045 must not exceed 4.
1046 .IP ""
1047 All bytes that cannot be encoded as matches
1048 are encoded as literals.
1049 That is, literals are simply 8-bit bytes
1050 that are encoded one at a time.
1051 .IP ""
1052 The literal coding makes an assumption that the highest
1053 .I lc
1054 bits of the previous uncompressed byte correlate
1055 with the next byte.
1056 E.g. in typical English text, an upper-case letter is
1057 often followed by a lower-case letter, and a lower-case
1058 letter is usually followed by another lower-case letter.
1059 In the US-ASCII character set, the highest three bits are 010
1060 for upper-case letters and 011 for lower-case letters.
1061 When
1062 .I lc
1063 is at least 3, the literal coding can take advantage of
1064 this property in the uncompressed data.
1065 .IP ""
1066 The default value (3) is usually good.
1067 If you want maximum compression, test
1068 .BR lc=4 .
1069 Sometimes it helps a little, and
1070 sometimes it makes compression worse.
1071 If it makes it worse, test e.g.\&
1072 .B lc=2
1073 too.
1074 .TP
1075 .BI lp= lp
1076 Specify the number of literal position bits.
1077 The minimum is 0 and the maximum is 4; the default is 0.
1078 .IP ""
1079 .I Lp
1080 affects what kind of alignment in the uncompressed data is
1081 assumed when encoding literals.
1082 See
1083 .I pb
1084 below for more information about alignment.
1085 .TP
1086 .BI pb= pb
1087 Specify the number of position bits.
1088 The minimum is 0 and the maximum is 4; the default is 2.
1089 .IP ""
1090 .I Pb
1091 affects what kind of alignment in the uncompressed data is
1092 assumed in general.
1093 The default means four-byte alignment
1094 .RI (2^ pb =2^2=4),
1095 which is often a good choice when there's no better guess.
1096 .IP ""
1097 When the aligment is known, setting
1098 .I pb
1099 accordingly may reduce the file size a little.
1100 E.g. with text files having one-byte
1101 alignment (US-ASCII, ISO-8859-*, UTF-8), setting
1102 .B pb=0
1103 can improve compression slightly.
1104 For UTF-16 text,
1105 .B pb=1
1106 is a good choice.
1107 If the alignment is an odd number like 3 bytes,
1108 .B pb=0
1109 might be the best choice.
1110 .IP ""
1111 Even though the assumed alignment can be adjusted with
1112 .I pb
1113 and
1114 .IR lp ,
1115 LZMA1 and LZMA2 still slightly favor 16-byte alignment.
1116 It might be worth taking into account when designing file formats
1117 that are likely to be often compressed with LZMA1 or LZMA2.
1118 .TP
1119 .BI mf= mf
1120 Match finder has a major effect on encoder speed,
1121 memory usage, and compression ratio.
1122 Usually Hash Chain match finders are faster than Binary Tree
1123 match finders.
1124 The default depends on the
1125 .IR preset :
1126 0 uses
1127 .BR hc3 ,
1128 1\-3
1129 use
1130 .BR hc4 ,
1131 and the rest use
1132 .BR bt4 .
1133 .IP ""
1134 The following match finders are supported.
1135 The memory usage formulas below are rough approximations,
1136 which are closest to the reality when
1137 .I dict
1138 is a power of two.
1139 .RS
1140 .TP
1141 .B hc3
1142 Hash Chain with 2- and 3-byte hashing
1143 .br
1144 Minimum value for
1145 .IR nice :
1146 3
1147 .br
1148 Memory usage:
1149 .br
1150 .I dict
1151 * 7.5 (if
1152 .I dict
1153 <= 16 MiB);
1154 .br
1155 .I dict
1156 * 5.5 + 64 MiB (if
1157 .I dict
1158 > 16 MiB)
1159 .TP
1160 .B hc4
1161 Hash Chain with 2-, 3-, and 4-byte hashing
1162 .br
1163 Minimum value for
1164 .IR nice :
1165 4
1166 .br
1167 Memory usage:
1168 .br
1169 .I dict
1170 * 7.5 (if
1171 .I dict
1172 <= 32 MiB);
1173 .br
1174 .I dict
1175 * 6.5 (if
1176 .I dict
1177 > 32 MiB)
1178 .TP
1179 .B bt2
1180 Binary Tree with 2-byte hashing
1181 .br
1182 Minimum value for
1183 .IR nice :
1184 2
1185 .br
1186 Memory usage:
1187 .I dict
1188 * 9.5
1189 .TP
1190 .B bt3
1191 Binary Tree with 2- and 3-byte hashing
1192 .br
1193 Minimum value for
1194 .IR nice :
1195 3
1196 .br
1197 Memory usage:
1198 .br
1199 .I dict
1200 * 11.5 (if
1201 .I dict
1202 <= 16 MiB);
1203 .br
1204 .I dict
1205 * 9.5 + 64 MiB (if
1206 .I dict
1207 > 16 MiB)
1208 .TP
1209 .B bt4
1210 Binary Tree with 2-, 3-, and 4-byte hashing
1211 .br
1212 Minimum value for
1213 .IR nice :
1214 4
1215 .br
1216 Memory usage:
1217 .br
1218 .I dict
1219 * 11.5 (if
1220 .I dict
1221 <= 32 MiB);
1222 .br
1223 .I dict
1224 * 10.5 (if
1225 .I dict
1226 > 32 MiB)
1227 .RE
1228 .TP
1229 .BI mode= mode
1230 Compression
1231 .I mode
1232 specifies the method to analyze
1233 the data produced by the match finder.
1234 Supported
1235 .I modes
1236 are
1237 .B fast
1238 and
1239 .BR normal .
1240 The default is
1241 .B fast
1242 for
1243 .I presets
1244 0\-3 and
1245 .B normal
1246 for
1247 .I presets
1248 4\-9.
1249 .IP ""
1250 Usually
1251 .B fast
1252 is used with Hash Chain match finders and
1253 .B normal
1254 with Binary Tree match finders.
1255 This is also what the
1256 .I presets
1257 do.
1258 .TP
1259 .BI nice= nice
1260 Specify what is considered to be a nice length for a match.
1261 Once a match of at least
1262 .I nice
1263 bytes is found, the algorithm stops
1264 looking for possibly better matches.
1265 .IP ""
1266 .I Nice
1267 can be 2\-273 bytes.
1268 Higher values tend to give better compression ratio
1269 at the expense of speed.
1270 The default depends on the
1271 .IR preset .
1272 .TP
1273 .BI depth= depth
1274 Specify the maximum search depth in the match finder.
1275 The default is the special value of 0,
1276 which makes the compressor determine a reasonable
1277 .I depth
1278 from
1279 .I mf
1280 and
1281 .IR nice .
1282 .IP ""
1283 Reasonable
1284 .I depth
1285 for Hash Chains is 4\-100 and 16\-1000 for Binary Trees.
1286 Using very high values for
1287 .I depth
1288 can make the encoder extremely slow with some files.
1289 Avoid setting the
1290 .I depth
1291 over 1000 unless you are prepared to interrupt
1292 the compression in case it is taking far too long.
1293 .RE
1294 .IP ""
1295 When decoding raw streams
1296 .RB ( \-\-format=raw ),
1297 LZMA2 needs only the dictionary
1298 .IR size .
1299 LZMA1 needs also
1300 .IR lc ,
1301 .IR lp ,
1302 and
1303 .IR pb .
1304 .TP
1305 \fB\-\-x86\fR[\fB=\fIoptions\fR]
1306 .PD 0
1307 .TP
1308 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
1309 .TP
1310 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
1311 .TP
1312 \fB\-\-arm\fR[\fB=\fIoptions\fR]
1313 .TP
1314 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
1315 .TP
1316 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
1317 .PD
1318 Add a branch/call/jump (BCJ) filter to the filter chain.
1319 These filters can be used only as a non-last filter
1320 in the filter chain.
1321 .IP ""
1322 A BCJ filter converts relative addresses in
1323 the machine code to their absolute counterparts.
1324 This doesn't change the size of the data,
1325 but it increases redundancy,
1326 which can help LZMA2 to produce 0\-15\ % smaller
1327 .B .xz
1328 file.
1329 The BCJ filters are always reversible,
1330 so using a BCJ filter for wrong type of data
1331 doesn't cause any data loss, although it may make
1332 the compression ratio slightly worse.
1333 .IP ""
1334 It is fine to apply a BCJ filter on a whole executable;
1335 there's no need to apply it only on the executable section.
1336 Applying a BCJ filter on an archive that contains both executable
1337 and non-executable files may or may not give good results,
1338 so it generally isn't good to blindly apply a BCJ filter when
1339 compressing binary packages for distribution.
1340 .IP ""
1341 These BCJ filters are very fast and
1342 use insignificant amount of memory.
1343 If a BCJ filter improves compression ratio of a file,
1344 it can improve decompression speed at the same time.
1345 This is because, on the same hardware,
1346 the decompression speed of LZMA2 is roughly
1347 a fixed number of bytes of compressed data per second.
1348 .IP ""
1349 These BCJ filters have known problems related to
1350 the compression ratio:
1351 .RS
1352 .IP \(bu 3
1353 Some types of files containing executable code
1354 (e.g. object files, static libraries, and Linux kernel modules)
1355 have the addresses in the instructions filled with filler values.
1356 These BCJ filters will still do the address conversion,
1357 which will make the compression worse with these files.
1358 .IP \(bu 3
1359 Applying a BCJ filter on an archive containing multiple similar
1360 executables can make the compression ratio worse than not using
1361 a BCJ filter.
1362 This is because the BCJ filter doesn't detect the boundaries
1363 of the executable files, and doesn't reset
1364 the address conversion counter for each executable.
1365 .RE
1366 .IP ""
1367 Both of the above problems will be fixed
1368 in the future in a new filter.
1369 The old BCJ filters will still be useful in embedded systems,
1370 because the decoder of the new filter will be bigger
1371 and use more memory.
1372 .IP ""
1373 Different instruction sets have have different alignment:
1374 .RS
1375 .RS
1376 .PP
1377 .TS
1378 tab(;);
1379 l n l
1380 l n l.
1381 Filter;Alignment;Notes
1382 x86;1;32-bit or 64-bit x86
1383 PowerPC;4;Big endian only
1384 ARM;4;Little endian only
1385 ARM-Thumb;2;Little endian only
1386 IA-64;16;Big or little endian
1387 SPARC;4;Big or little endian
1388 .TE
1389 .RE
1390 .RE
1391 .IP ""
1392 Since the BCJ-filtered data is usually compressed with LZMA2,
1393 the compression ratio may be improved slightly if
1394 the LZMA2 options are set to match the
1395 alignment of the selected BCJ filter.
1396 For example, with the IA-64 filter, it's good to set
1397 .B pb=4
1398 with LZMA2 (2^4=16).
1399 The x86 filter is an exception;
1400 it's usually good to stick to LZMA2's default
1401 four-byte alignment when compressing x86 executables.
1402 .IP ""
1403 All BCJ filters support the same
1404 .IR options :
1405 .RS
1406 .TP
1407 .BI start= offset
1408 Specify the start
1409 .I offset
1410 that is used when converting between relative
1411 and absolute addresses.
1412 The
1413 .I offset
1414 must be a multiple of the alignment of the filter
1415 (see the table above).
1416 The default is zero.
1417 In practice, the default is good; specifying a custom
1418 .I offset
1419 is almost never useful.
1420 .RE
1421 .TP
1422 \fB\-\-delta\fR[\fB=\fIoptions\fR]
1423 Add the Delta filter to the filter chain.
1424 The Delta filter can be only used as a non-last filter
1425 in the filter chain.
1426 .IP ""
1427 Currently only simple byte-wise delta calculation is supported.
1428 It can be useful when compressing e.g. uncompressed bitmap images
1429 or uncompressed PCM audio.
1430 However, special purpose algorithms may give significantly better
1431 results than Delta + LZMA2.
1432 This is true especially with audio,
1433 which compresses faster and better e.g. with
1434 .BR flac (1).
1435 .IP ""
1436 Supported
1437 .IR options :
1438 .RS
1439 .TP
1440 .BI dist= distance
1441 Specify the
1442 .I distance
1443 of the delta calculation in bytes.
1444 .I distance
1445 must be 1\-256.
1446 The default is 1.
1447 .IP ""
1448 For example, with
1449 .B dist=2
1450 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
1451 A1 B1 01 02 01 02 01 02.
1452 .RE
1453 .
1454 .SS "Other options"
1455 .TP
1456 .BR \-q ", " \-\-quiet
1457 Suppress warnings and notices.
1458 Specify this twice to suppress errors too.
1459 This option has no effect on the exit status.
1460 That is, even if a warning was suppressed,
1461 the exit status to indicate a warning is still used.
1462 .TP
1463 .BR \-v ", " \-\-verbose
1464 Be verbose.
1465 If standard error is connected to a terminal,
1466 .B xz
1467 will display a progress indicator.
1468 Specifying
1469 .B \-\-verbose
1470 twice will give even more verbose output.
1471 .IP ""
1472 The progress indicator shows the following information:
1473 .RS
1474 .IP \(bu 3
1475 Completion percentage is shown
1476 if the size of the input file is known.
1477 That is, the percentage cannot be shown in pipes.
1478 .IP \(bu 3
1479 Amount of compressed data produced (compressing)
1480 or consumed (decompressing).
1481 .IP \(bu 3
1482 Amount of uncompressed data consumed (compressing)
1483 or produced (decompressing).
1484 .IP \(bu 3
1485 Compression ratio, which is calculated by dividing
1486 the amount of compressed data processed so far by
1487 the amount of uncompressed data processed so far.
1488 .IP \(bu 3
1489 Compression or decompression speed.
1490 This is measured as the amount of uncompressed data consumed
1491 (compression) or produced (decompression) per second.
1492 It is shown after a few seconds have passed since
1493 .B xz
1494 started processing the file.
1495 .IP \(bu 3
1496 Elapsed time in the format M:SS or H:MM:SS.
1497 .IP \(bu 3
1498 Estimated remaining time is shown
1499 only when the size of the input file is
1500 known and a couple of seconds have already passed since
1501 .B xz
1502 started processing the file.
1503 The time is shown in a less precise format which
1504 never has any colons, e.g. 2 min 30 s.
1505 .RE
1506 .IP ""
1507 When standard error is not a terminal,
1508 .B \-\-verbose
1509 will make
1510 .B xz
1511 print the filename, compressed size, uncompressed size,
1512 compression ratio, and possibly also the speed and elapsed time
1513 on a single line to standard error after compressing or
1514 decompressing the file.
1515 The speed and elapsed time are included only when
1516 the operation took at least a few seconds.
1517 If the operation didn't finish, e.g. due to user interruption,
1518 also the completion percentage is printed
1519 if the size of the input file is known.
1520 .TP
1521 .BR \-Q ", " \-\-no\-warn
1522 Don't set the exit status to 2
1523 even if a condition worth a warning was detected.
1524 This option doesn't affect the verbosity level, thus both
1525 .B \-\-quiet
1526 and
1527 .B \-\-no\-warn
1528 have to be used to not display warnings and
1529 to not alter the exit status.
1530 .TP
1531 .B \-\-robot
1532 Print messages in a machine-parsable format.
1533 This is intended to ease writing frontends that want to use
1534 .B xz
1535 instead of liblzma, which may be the case with various scripts.
1536 The output with this option enabled is meant to be stable across
1537 .B xz
1538 releases.
1539 See the section
1540 .B "ROBOT MODE"
1541 for details.
1542 .TP
1543 .BR \-\-info\-memory
1544 Display, in human-readable format, how much physical memory (RAM)
1545 .B xz
1546 thinks the system has and the memory usage limits for compression
1547 and decompression, and exit successfully.
1548 .TP
1549 .BR \-h ", " \-\-help
1550 Display a help message describing the most commonly used options,
1551 and exit successfully.
1552 .TP
1553 .BR \-H ", " \-\-long\-help
1554 Display a help message describing all features of
1555 .BR xz ,
1556 and exit successfully
1557 .TP
1558 .BR \-V ", " \-\-version
1559 Display the version number of
1560 .B xz
1561 and liblzma in human readable format.
1562 To get machine-parsable output, specify
1563 .B \-\-robot
1564 before
1565 .BR \-\-version .
1566 .
1567 .SH "ROBOT MODE"
1568 The robot mode is activated with the
1569 .B \-\-robot
1570 option.
1571 It makes the output of
1572 .B xz
1573 easier to parse by other programs.
1574 Currently
1575 .B \-\-robot
1576 is supported only together with
1577 .BR \-\-version ,
1578 .BR \-\-info\-memory ,
1579 and
1580 .BR \-\-list .
1581 It will be supported for normal compression and
1582 decompression in the future.
1583 .
1584 .SS Version
1585 .B "xz \-\-robot \-\-version"
1586 will print the version number of
1587 .B xz
1588 and liblzma in the following format:
1589 .PP
1590 .BI XZ_VERSION= XYYYZZZS
1591 .br
1592 .BI LIBLZMA_VERSION= XYYYZZZS
1593 .TP
1594 .I X
1595 Major version.
1596 .TP
1597 .I YYY
1598 Minor version.
1599 Even numbers are stable.
1600 Odd numbers are alpha or beta versions.
1601 .TP
1602 .I ZZZ
1603 Patch level for stable releases or
1604 just a counter for development releases.
1605 .TP
1606 .I S
1607 Stability.
1608 0 is alpha, 1 is beta, and 2 is stable.
1609 .I S
1610 should be always 2 when
1611 .I YYY
1612 is even.
1613 .PP
1614 .I XYYYZZZS
1615 are the same on both lines if
1616 .B xz
1617 and liblzma are from the same XZ Utils release.
1618 .PP
1619 Examples: 4.999.9beta is
1620 .B 49990091
1621 and
1622 5.0.0 is
1623 .BR 50000002 .
1624 .
1625 .SS "Memory limit information"
1626 .B "xz \-\-robot \-\-info\-memory"
1627 prints a single line with three tab-separated columns:
1628 .IP 1. 4
1629 Total amount of physical memory (RAM) in bytes
1630 .IP 2. 4
1631 Memory usage limit for compression in bytes.
1632 A special value of zero indicates the default setting,
1633 which for single-threaded mode is the same as no limit.
1634 .IP 3. 4
1635 Memory usage limit for decompression in bytes.
1636 A special value of zero indicates the default setting,
1637 which for single-threaded mode is the same as no limit.
1638 .PP
1639 In the future, the output of
1640 .B "xz \-\-robot \-\-info\-memory"
1641 may have more columns, but never more than a single line.
1642 .
1643 .SS "List mode"
1644 .B "xz \-\-robot \-\-list"
1645 uses tab-separated output.
1646 The first column of every line has a string
1647 that indicates the type of the information found on that line:
1648 .TP
1649 .B name
1650 This is always the first line when starting to list a file.
1651 The second column on the line is the filename.
1652 .TP
1653 .B file
1654 This line contains overall information about the
1655 .B .xz
1656 file.
1657 This line is always printed after the
1658 .B name
1659 line.
1660 .TP
1661 .B stream
1662 This line type is used only when
1663 .B \-\-verbose
1664 was specified.
1665 There are as many
1666 .B stream
1667 lines as there are streams in the
1668 .B .xz
1669 file.
1670 .TP
1671 .B block
1672 This line type is used only when
1673 .B \-\-verbose
1674 was specified.
1675 There are as many
1676 .B block
1677 lines as there are blocks in the
1678 .B .xz
1679 file.
1680 The
1681 .B block
1682 lines are shown after all the
1683 .B stream
1684 lines; different line types are not interleaved.
1685 .TP
1686 .B summary
1687 This line type is used only when
1688 .B \-\-verbose
1689 was specified twice.
1690 This line is printed after all
1691 .B block
1692 lines.
1693 Like the
1694 .B file
1695 line, the
1696 .B summary
1697 line contains overall information about the
1698 .B .xz
1699 file.
1700 .TP
1701 .B totals
1702 This line is always the very last line of the list output.
1703 It shows the total counts and sizes.
1704 .PP
1705 The columns of the
1706 .B file
1707 lines:
1708 .PD 0
1709 .RS
1710 .IP 2. 4
1711 Number of streams in the file
1712 .IP 3. 4
1713 Total number of blocks in the stream(s)
1714 .IP 4. 4
1715 Compressed size of the file
1716 .IP 5. 4
1717 Uncompressed size of the file
1718 .IP 6. 4
1719 Compression ratio, for example
1720 .BR 0.123.
1721 If ratio is over 9.999, three dashes
1722 .RB ( \-\-\- )
1723 are displayed instead of the ratio.
1724 .IP 7. 4
1725 Comma-separated list of integrity check names.
1726 The following strings are used for the known check types:
1727 .BR None ,
1728 .BR CRC32 ,
1729 .BR CRC64 ,
1730 and
1731 .BR SHA\-256 .
1732 For unknown check types,
1733 .BI Unknown\- N
1734 is used, where
1735 .I N
1736 is the Check ID as a decimal number (one or two digits).
1737 .IP 8. 4
1738 Total size of stream padding in the file
1739 .RE
1740 .PD
1741 .PP
1742 The columns of the
1743 .B stream
1744 lines:
1745 .PD 0
1746 .RS
1747 .IP 2. 4
1748 Stream number (the first stream is 1)
1749 .IP 3. 4
1750 Number of blocks in the stream
1751 .IP 4. 4
1752 Compressed start offset
1753 .IP 5. 4
1754 Uncompressed start offset
1755 .IP 6. 4
1756 Compressed size (does not include stream padding)
1757 .IP 7. 4
1758 Uncompressed size
1759 .IP 8. 4
1760 Compression ratio
1761 .IP 9. 4
1762 Name of the integrity check
1763 .IP 10. 4
1764 Size of stream padding
1765 .RE
1766 .PD
1767 .PP
1768 The columns of the
1769 .B block
1770 lines:
1771 .PD 0
1772 .RS
1773 .IP 2. 4
1774 Number of the stream containing this block
1775 .IP 3. 4
1776 Block number relative to the beginning of the stream
1777 (the first block is 1)
1778 .IP 4. 4
1779 Block number relative to the beginning of the file
1780 .IP 5. 4
1781 Compressed start offset relative to the beginning of the file
1782 .IP 6. 4
1783 Uncompressed start offset relative to the beginning of the file
1784 .IP 7. 4
1785 Total compressed size of the block (includes headers)
1786 .IP 8. 4
1787 Uncompressed size
1788 .IP 9. 4
1789 Compression ratio
1790 .IP 10. 4
1791 Name of the integrity check
1792 .RE
1793 .PD
1794 .PP
1795 If
1796 .B \-\-verbose
1797 was specified twice, additional columns are included on the
1798 .B block
1799 lines.
1800 These are not displayed with a single
1801 .BR \-\-verbose ,
1802 because getting this information requires many seeks
1803 and can thus be slow:
1804 .PD 0
1805 .RS
1806 .IP 11. 4
1807 Value of the integrity check in hexadecimal
1808 .IP 12. 4
1809 Block header size
1810 .IP 13. 4
1811 Block flags:
1812 .B c
1813 indicates that compressed size is present, and
1814 .B u
1815 indicates that uncompressed size is present.
1816 If the flag is not set, a dash
1817 .RB ( \- )
1818 is shown instead to keep the string length fixed.
1819 New flags may be added to the end of the string in the future.
1820 .IP 14. 4
1821 Size of the actual compressed data in the block (this excludes
1822 the block header, block padding, and check fields)
1823 .IP 15. 4
1824 Amount of memory (in bytes) required to decompress
1825 this block with this
1826 .B xz
1827 version
1828 .IP 16. 4
1829 Filter chain.
1830 Note that most of the options used at compression time
1831 cannot be known, because only the options
1832 that are needed for decompression are stored in the
1833 .B .xz
1834 headers.
1835 .RE
1836 .PD
1837 .PP
1838 The columns of the
1839 .B totals
1840 line:
1841 .PD 0
1842 .RS
1843 .IP 2. 4
1844 Number of streams
1845 .IP 3. 4
1846 Number of blocks
1847 .IP 4. 4
1848 Compressed size
1849 .IP 5. 4
1850 Uncompressed size
1851 .IP 6. 4
1852 Average compression ratio
1853 .IP 7. 4
1854 Comma-separated list of integrity check names
1855 that were present in the files
1856 .IP 8. 4
1857 Stream padding size
1858 .IP 9. 4
1859 Number of files.
1860 This is here to
1861 keep the order of the earlier columns the same as on
1862 .B file
1863 lines.
1864 .PD
1865 .RE
1866 .PP
1867 If
1868 .B \-\-verbose
1869 was specified twice, additional columns are included on the
1870 .B totals
1871 line:
1872 .PD 0
1873 .RS
1874 .IP 10. 4
1875 Maximum amount of memory (in bytes) required to decompress
1876 the files with this
1877 .B xz
1878 version
1879 .IP 11. 4
1880 .B yes
1881 or
1882 .B no
1883 indicating if all block headers have both compressed size and
1884 uncompressed size stored in them
1885 .RE
1886 .PD
1887 .PP
1888 Future versions may add new line types and
1889 new columns can be added to the existing line types,
1890 but the existing columns won't be changed.
1891 .
1892 .SH "EXIT STATUS"
1893 .TP
1894 .B 0
1895 All is good.
1896 .TP
1897 .B 1
1898 An error occurred.
1899 .TP
1900 .B 2
1901 Something worth a warning occurred,
1902 but no actual errors occurred.
1903 .PP
1904 Notices (not warnings or errors) printed on standard error
1905 don't affect the exit status.
1906 .
1907 .SH ENVIRONMENT
1908 .B xz
1909 parses space-separated lists of options
1910 from the environment variables
1911 .B XZ_DEFAULTS
1912 and
1913 .BR XZ_OPT ,
1914 in this order, before parsing the options from the command line.
1915 Note that only options are parsed from the environment variables;
1916 all non-options are silently ignored.
1917 Parsing is done with
1918 .BR getopt_long (3)
1919 which is used also for the command line arguments.
1920 .TP
1921 .B XZ_DEFAULTS
1922 User-specific or system-wide default options.
1923 Typically this is set in a shell initialization script to enable
1924 .BR xz 's
1925 memory usage limiter by default.
1926 Excluding shell initialization scripts
1927 and similar special cases, scripts must never set or unset
1928 .BR XZ_DEFAULTS .
1929 .TP
1930 .B XZ_OPT
1931 This is for passing options to
1932 .B xz
1933 when it is not possible to set the options directly on the
1934 .B xz
1935 command line.
1936 This is the case e.g. when
1937 .B xz
1938 is run by a script or tool, e.g. GNU
1939 .BR tar (1):
1940 .RS
1941 .RS
1942 .PP
1943 .nf
1944 .ft CW
1945 XZ_OPT=\-2v tar caf foo.tar.xz foo
1946 .ft R
1947 .fi
1948 .RE
1949 .RE
1950 .IP ""
1951 Scripts may use
1952 .B XZ_OPT
1953 e.g. to set script-specific default compression options.
1954 It is still recommended to allow users to override
1955 .B XZ_OPT
1956 if that is reasonable, e.g. in
1957 .BR sh (1)
1958 scripts one may use something like this:
1959 .RS
1960 .RS
1961 .PP
1962 .nf
1963 .ft CW
1964 XZ_OPT=${XZ_OPT\-"\-7e"}
1965 export XZ_OPT
1966 .ft R
1967 .fi
1968 .RE
1969 .RE
1970 .
1971 .SH "LZMA UTILS COMPATIBILITY"
1972 The command line syntax of
1973 .B xz
1974 is practically a superset of
1975 .BR lzma ,
1976 .BR unlzma ,
1977 and
1978 .BR lzcat
1979 as found from LZMA Utils 4.32.x.
1980 In most cases, it is possible to replace
1981 LZMA Utils with XZ Utils without breaking existing scripts.
1982 There are some incompatibilities though,
1983 which may sometimes cause problems.
1984 .
1985 .SS "Compression preset levels"
1986 The numbering of the compression level presets is not identical in
1987 .B xz
1988 and LZMA Utils.
1989 The most important difference is how dictionary sizes
1990 are mapped to different presets.
1991 Dictionary size is roughly equal to the decompressor memory usage.
1992 .RS
1993 .PP
1994 .TS
1995 tab(;);
1996 c c c
1997 c n n.
1998 Level;xz;LZMA Utils
1999 \-0;256 KiB;N/A
2000 \-1;1 MiB;64 KiB
2001 \-2;2 MiB;1 MiB
2002 \-3;4 MiB;512 KiB
2003 \-4;4 MiB;1 MiB
2004 \-5;8 MiB;2 MiB
2005 \-6;8 MiB;4 MiB
2006 \-7;16 MiB;8 MiB
2007 \-8;32 MiB;16 MiB
2008 \-9;64 MiB;32 MiB
2009 .TE
2010 .RE
2011 .PP
2012 The dictionary size differences affect
2013 the compressor memory usage too,
2014 but there are some other differences between
2015 LZMA Utils and XZ Utils, which
2016 make the difference even bigger:
2017 .RS
2018 .PP
2019 .TS
2020 tab(;);
2021 c c c
2022 c n n.
2023 Level;xz;LZMA Utils 4.32.x
2024 \-0;3 MiB;N/A
2025 \-1;9 MiB;2 MiB
2026 \-2;17 MiB;12 MiB
2027 \-3;32 MiB;12 MiB
2028 \-4;48 MiB;16 MiB
2029 \-5;94 MiB;26 MiB
2030 \-6;94 MiB;45 MiB
2031 \-7;186 MiB;83 MiB
2032 \-8;370 MiB;159 MiB
2033 \-9;674 MiB;311 MiB
2034 .TE
2035 .RE
2036 .PP
2037 The default preset level in LZMA Utils is
2038 .B \-7
2039 while in XZ Utils it is
2040 .BR \-6 ,
2041 so both use an 8 MiB dictionary by default.
2042 .
2043 .SS "Streamed vs. non-streamed .lzma files"
2044 The uncompressed size of the file can be stored in the
2045 .B .lzma
2046 header.
2047 LZMA Utils does that when compressing regular files.
2048 The alternative is to mark that uncompressed size is unknown
2049 and use end-of-payload marker to indicate
2050 where the decompressor should stop.
2051 LZMA Utils uses this method when uncompressed size isn't known,
2052 which is the case for example in pipes.
2053 .PP
2054 .B xz
2055 supports decompressing
2056 .B .lzma
2057 files with or without end-of-payload marker, but all
2058 .B .lzma
2059 files created by
2060 .B xz
2061 will use end-of-payload marker and have uncompressed size
2062 marked as unknown in the
2063 .B .lzma
2064 header.
2065 This may be a problem in some uncommon situations.
2066 For example, a
2067 .B .lzma
2068 decompressor in an embedded device might work
2069 only with files that have known uncompressed size.
2070 If you hit this problem, you need to use LZMA Utils
2071 or LZMA SDK to create
2072 .B .lzma
2073 files with known uncompressed size.
2074 .
2075 .SS "Unsupported .lzma files"
2076 The
2077 .B .lzma
2078 format allows
2079 .I lc
2080 values up to 8, and
2081 .I lp
2082 values up to 4.
2083 LZMA Utils can decompress files with any
2084 .I lc
2085 and
2086 .IR lp ,
2087 but always creates files with
2088 .B lc=3
2089 and
2090 .BR lp=0 .
2091 Creating files with other
2092 .I lc
2093 and
2094 .I lp
2095 is possible with
2096 .B xz
2097 and with LZMA SDK.
2098 .PP
2099 The implementation of the LZMA1 filter in liblzma
2100 requires that the sum of
2101 .I lc
2102 and
2103 .I lp
2104 must not exceed 4.
2105 Thus,
2106 .B .lzma
2107 files, which exceed this limitation, cannot be decompressed with
2108 .BR xz .
2109 .PP
2110 LZMA Utils creates only
2111 .B .lzma
2112 files which have a dictionary size of
2113 .RI "2^" n
2114 (a power of 2) but accepts files with any dictionary size.
2115 liblzma accepts only
2116 .B .lzma
2117 files which have a dictionary size of
2118 .RI "2^" n
2119 or
2120 .RI "2^" n " + 2^(" n "\-1)."
2121 This is to decrease false positives when detecting
2122 .B .lzma
2123 files.
2124 .PP
2125 These limitations shouldn't be a problem in practice,
2126 since practically all
2127 .B .lzma
2128 files have been compressed with settings that liblzma will accept.
2129 .
2130 .SS "Trailing garbage"
2131 When decompressing,
2132 LZMA Utils silently ignore everything after the first
2133 .B .lzma
2134 stream.
2135 In most situations, this is a bug.
2136 This also means that LZMA Utils
2137 don't support decompressing concatenated
2138 .B .lzma
2139 files.
2140 .PP
2141 If there is data left after the first
2142 .B .lzma
2143 stream,
2144 .B xz
2145 considers the file to be corrupt.
2146 This may break obscure scripts which have
2147 assumed that trailing garbage is ignored.
2148 .
2149 .SH NOTES
2150 .
2151 .SS "Compressed output may vary"
2152 The exact compressed output produced from
2153 the same uncompressed input file
2154 may vary between XZ Utils versions even if
2155 compression options are identical.
2156 This is because the encoder can be improved
2157 (faster or better compression)
2158 without affecting the file format.
2159 The output can vary even between different
2160 builds of the same XZ Utils version,
2161 if different build options are used.
2162 .PP
2163 The above means that implementing
2164 .B \-\-rsyncable
2165 to create rsyncable
2166 .B .xz
2167 files is not going to happen without
2168 freezing a part of the encoder
2169 implementation, which can then be used with
2170 .BR \-\-rsyncable .
2171 .
2172 .SS "Embedded .xz decompressors"
2173 Embedded
2174 .B .xz
2175 decompressor implementations like XZ Embedded don't necessarily
2176 support files created with integrity
2177 .I check
2178 types other than
2179 .B none
2180 and
2181 .BR crc32 .
2182 Since the default is
2183 .BR \-\-check=crc64 ,
2184 you must use
2185 .B \-\-check=none
2186 or
2187 .B \-\-check=crc32
2188 when creating files for embedded systems.
2189 .PP
2190 Outside embedded systems, all
2191 .B .xz
2192 format decompressors support all the
2193 .I check
2194 types, or at least are able to decompress
2195 the file without verifying the
2196 integrity check if the particular
2197 .I check
2198 is not supported.
2199 .PP
2200 XZ Embedded supports BCJ filters,
2201 but only with the default start offset.
2202 .
2203 .SH EXAMPLES
2204 .
2205 .SS Basics
2206 Compress the file
2207 .I foo
2208 into
2209 .I foo.xz
2210 using the default compression level
2211 .RB ( \-6 ),
2212 and remove
2213 .I foo
2214 if compression is successful:
2215 .RS
2216 .PP
2217 .nf
2218 .ft CW
2219 xz foo
2220 .ft R
2221 .fi
2222 .RE
2223 .PP
2224 Decompress
2225 .I bar.xz
2226 into
2227 .I bar
2228 and don't remove
2229 .I bar.xz
2230 even if decompression is successful:
2231 .RS
2232 .PP
2233 .nf
2234 .ft CW
2235 xz \-dk bar.xz
2236 .ft R
2237 .fi
2238 .RE
2239 .PP
2240 Create
2241 .I baz.tar.xz
2242 with the preset
2243 .B \-4e
2244 .RB ( "\-4 \-\-extreme" ),
2245 which is slower than e.g. the default
2246 .BR \-6 ,
2247 but needs less memory for compression and decompression (48\ MiB
2248 and 5\ MiB, respectively):
2249 .RS
2250 .PP
2251 .nf
2252 .ft CW
2253 tar cf \- baz | xz \-4e > baz.tar.xz
2254 .ft R
2255 .fi
2256 .RE
2257 .PP
2258 A mix of compressed and uncompressed files can be decompressed
2259 to standard output with a single command:
2260 .RS
2261 .PP
2262 .nf
2263 .ft CW
2264 xz \-dcf a.txt b.txt.xz c.txt d.txt.lzma > abcd.txt
2265 .ft R
2266 .fi
2267 .RE
2268 .
2269 .SS "Parallel compression of many files"
2270 On GNU and *BSD,
2271 .BR find (1)
2272 and
2273 .BR xargs (1)
2274 can be used to parallelize compression of many files:
2275 .RS
2276 .PP
2277 .nf
2278 .ft CW
2279 find . \-type f \e! \-name '*.xz' \-print0 \e
2280     | xargs \-0r \-P4 \-n16 xz \-T1
2281 .ft R
2282 .fi
2283 .RE
2284 .PP
2285 The
2286 .B \-P
2287 option to
2288 .BR xargs (1)
2289 sets the number of parallel
2290 .B xz
2291 processes.
2292 The best value for the
2293 .B \-n
2294 option depends on how many files there are to be compressed.
2295 If there are only a couple of files,
2296 the value should probably be 1;
2297 with tens of thousands of files,
2298 100 or even more may be appropriate to reduce the number of
2299 .B xz
2300 processes that
2301 .BR xargs (1)
2302 will eventually create.
2303 .PP
2304 The option
2305 .B \-T1
2306 for
2307 .B xz
2308 is there to force it to single-threaded mode, because
2309 .BR xargs (1)
2310 is used to control the amount of parallelization.
2311 .
2312 .SS "Robot mode"
2313 Calculate how many bytes have been saved in total
2314 after compressing multiple files:
2315 .RS
2316 .PP
2317 .nf
2318 .ft CW
2319 xz \-\-robot \-\-list *.xz | awk '/^totals/{print $5\-$4}'
2320 .ft R
2321 .fi
2322 .RE
2323 .PP
2324 A script may want to know that it is using new enough
2325 .BR xz .
2326 The following
2327 .BR sh (1)
2328 script checks that the version number of the
2329 .B xz
2330 tool is at least 5.0.0.
2331 This method is compatible with old beta versions,
2332 which didn't support the
2333 .B \-\-robot
2334 option:
2335 .RS
2336 .PP
2337 .nf
2338 .ft CW
2339 if ! eval "$(xz \-\-robot \-\-version 2> /dev/null)" ||
2340         [ "$XZ_VERSION" \-lt 50000002 ]; then
2341     echo "Your xz is too old."
2342 fi
2343 unset XZ_VERSION LIBLZMA_VERSION
2344 .ft R
2345 .fi
2346 .RE
2347 .PP
2348 Set a memory usage limit for decompression using
2349 .BR XZ_OPT ,
2350 but if a limit has already been set, don't increase it:
2351 .RS
2352 .PP
2353 .nf
2354 .ft CW
2355 NEWLIM=$((123 << 20))  # 123 MiB
2356 OLDLIM=$(xz \-\-robot \-\-info\-memory | cut \-f3)
2357 if [ $OLDLIM \-eq 0 \-o $OLDLIM \-gt $NEWLIM ]; then
2358     XZ_OPT="$XZ_OPT \-\-memlimit\-decompress=$NEWLIM"
2359     export XZ_OPT
2360 fi
2361 .ft R
2362 .fi
2363 .RE
2364 .
2365 .SS "Custom compressor filter chains"
2366 The simplest use for custom filter chains is
2367 customizing a LZMA2 preset.
2368 This can be useful,
2369 because the presets cover only a subset of the
2370 potentially useful combinations of compression settings.
2371 .PP
2372 The CompCPU columns of the tables
2373 from the descriptions of the options
2374 .BR "\-0" " ... " "\-9"
2375 and
2376 .B \-\-extreme
2377 are useful when customizing LZMA2 presets.
2378 Here are the relevant parts collected from those two tables:
2379 .RS
2380 .PP
2381 .TS
2382 tab(;);
2383 c c
2384 n n.
2385 Preset;CompCPU
2386 \-0;0
2387 \-1;1
2388 \-2;2
2389 \-3;3
2390 \-4;4
2391 \-5;5
2392 \-6;6
2393 \-5e;7
2394 \-6e;8
2395 .TE
2396 .RE
2397 .PP
2398 If you know that a file requires
2399 somewhat big dictionary (e.g. 32 MiB) to compress well,
2400 but you want to compress it quicker than
2401 .B "xz \-8"
2402 would do, a preset with a low CompCPU value (e.g. 1)
2403 can be modified to use a bigger dictionary:
2404 .RS
2405 .PP
2406 .nf
2407 .ft CW
2408 xz \-\-lzma2=preset=1,dict=32MiB foo.tar
2409 .ft R
2410 .fi
2411 .RE
2412 .PP
2413 With certain files, the above command may be faster than
2414 .B "xz \-6"
2415 while compressing significantly better.
2416 However, it must be emphasized that only some files benefit from
2417 a big dictionary while keeping the CompCPU value low.
2418 The most obvious situation,
2419 where a big dictionary can help a lot,
2420 is an archive containing very similar files
2421 of at least a few megabytes each.
2422 The dictionary size has to be significantly bigger
2423 than any individual file to allow LZMA2 to take
2424 full advantage of the similarities between consecutive files.
2425 .PP
2426 If very high compressor and decompressor memory usage is fine,
2427 and the file being compressed is
2428 at least several hundred megabytes, it may be useful
2429 to use an even bigger dictionary than the 64 MiB that
2430 .B "xz \-9"
2431 would use:
2432 .RS
2433 .PP
2434 .nf
2435 .ft CW
2436 xz \-vv \-\-lzma2=dict=192MiB big_foo.tar
2437 .ft R
2438 .fi
2439 .RE
2440 .PP
2441 Using
2442 .B \-vv
2443 .RB ( "\-\-verbose \-\-verbose" )
2444 like in the above example can be useful
2445 to see the memory requirements
2446 of the compressor and decompressor.
2447 Remember that using a dictionary bigger than
2448 the size of the uncompressed file is waste of memory,
2449 so the above command isn't useful for small files.
2450 .PP
2451 Sometimes the compression time doesn't matter,
2452 but the decompressor memory usage has to be kept low
2453 e.g. to make it possible to decompress the file on
2454 an embedded system.
2455 The following command uses
2456 .B \-6e
2457 .RB ( "\-6 \-\-extreme" )
2458 as a base and sets the dictionary to only 64\ KiB.
2459 The resulting file can be decompressed with XZ Embedded
2460 (that's why there is
2461 .BR \-\-check=crc32 )
2462 using about 100\ KiB of memory.
2463 .RS
2464 .PP
2465 .nf
2466 .ft CW
2467 xz \-\-check=crc32 \-\-lzma2=preset=6e,dict=64KiB foo
2468 .ft R
2469 .fi
2470 .RE
2471 .PP
2472 If you want to squeeze out as many bytes as possible,
2473 adjusting the number of literal context bits
2474 .RI ( lc )
2475 and number of position bits
2476 .RI ( pb )
2477 can sometimes help.
2478 Adjusting the number of literal position bits
2479 .RI ( lp )
2480 might help too, but usually
2481 .I lc
2482 and
2483 .I pb
2484 are more important.
2485 E.g. a source code archive contains mostly US-ASCII text,
2486 so something like the following might give
2487 slightly (like 0.1\ %) smaller file than
2488 .B "xz \-6e"
2489 (try also without
2490 .BR lc=4 ):
2491 .RS
2492 .PP
2493 .nf
2494 .ft CW
2495 xz \-\-lzma2=preset=6e,pb=0,lc=4 source_code.tar
2496 .ft R
2497 .fi
2498 .RE
2499 .PP
2500 Using another filter together with LZMA2 can improve
2501 compression with certain file types.
2502 E.g. to compress a x86-32 or x86-64 shared library
2503 using the x86 BCJ filter:
2504 .RS
2505 .PP
2506 .nf
2507 .ft CW
2508 xz \-\-x86 \-\-lzma2 libfoo.so
2509 .ft R
2510 .fi
2511 .RE
2512 .PP
2513 Note that the order of the filter options is significant.
2514 If
2515 .B \-\-x86
2516 is specified after
2517 .BR \-\-lzma2 ,
2518 .B xz
2519 will give an error,
2520 because there cannot be any filter after LZMA2,
2521 and also because the x86 BCJ filter cannot be used
2522 as the last filter in the chain.
2523 .PP
2524 The Delta filter together with LZMA2
2525 can give good results with bitmap images.
2526 It should usually beat PNG,
2527 which has a few more advanced filters than simple
2528 delta but uses Deflate for the actual compression.
2529 .PP
2530 The image has to be saved in uncompressed format,
2531 e.g. as uncompressed TIFF.
2532 The distance parameter of the Delta filter is set
2533 to match the number of bytes per pixel in the image.
2534 E.g. 24-bit RGB bitmap needs
2535 .BR dist=3 ,
2536 and it is also good to pass
2537 .B pb=0
2538 to LZMA2 to accommodate the three-byte alignment:
2539 .RS
2540 .PP
2541 .nf
2542 .ft CW
2543 xz \-\-delta=dist=3 \-\-lzma2=pb=0 foo.tiff
2544 .ft R
2545 .fi
2546 .RE
2547 .PP
2548 If multiple images have been put into a single archive (e.g.\&
2549 .BR .tar ),
2550 the Delta filter will work on that too as long as all images
2551 have the same number of bytes per pixel.
2552 .
2553 .SH "SEE ALSO"
2554 .BR xzdec (1),
2555 .BR xzdiff (1),
2556 .BR xzgrep (1),
2557 .BR xzless (1),
2558 .BR xzmore (1),
2559 .BR gzip (1),
2560 .BR bzip2 (1),
2561 .BR 7z (1)
2562 .PP
2563 XZ Utils: <http://tukaani.org/xz/>
2564 .br
2565 XZ Embedded: <http://tukaani.org/xz/embedded.html>
2566 .br
2567 LZMA SDK: <http://7-zip.org/sdk.html>