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