]> icculus.org git repositories - icculus/xz.git/blob - src/xz/xz.1
xz: Make --help two lines shorter.
[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-08-07" "Tukaani" "XZ Utils"
9 .SH NAME
10 xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
11 .SH SYNOPSIS
12 .B xz
13 .RI [ option ]...
14 .RI [ file ]...
15 .PP
16 .B unxz
17 is equivalent to
18 .BR "xz \-\-decompress" .
19 .br
20 .B xzcat
21 is equivalent to
22 .BR "xz \-\-decompress \-\-stdout" .
23 .br
24 .B lzma
25 is equivalent to
26 .BR "xz \-\-format=lzma" .
27 .br
28 .B unlzma
29 is equivalent to
30 .BR "xz \-\-format=lzma \-\-decompress" .
31 .br
32 .B lzcat
33 is equivalent to
34 .BR "xz \-\-format=lzma \-\-decompress \-\-stdout" .
35 .PP
36 When writing scripts that need to decompress files, it is recommended to
37 always use the name
38 .B xz
39 with appropriate arguments
40 .RB ( "xz \-d"
41 or
42 .BR "xz \-dc" )
43 instead of the names
44 .B unxz
45 and
46 .BR xzcat.
47 .SH DESCRIPTION
48 .B xz
49 is a general-purpose data compression tool with command line syntax similar to
50 .BR gzip (1)
51 and
52 .BR bzip2 (1).
53 The native file format is the
54 .B .xz
55 format, but also the legacy
56 .B .lzma
57 format and raw compressed streams with no container format headers
58 are supported.
59 .PP
60 .B xz
61 compresses or decompresses each
62 .I file
63 according to the selected operation mode.
64 If no
65 .I files
66 are given or
67 .I file
68 is
69 .BR \- ,
70 .B xz
71 reads from standard input and writes the processed data to standard output.
72 .B xz
73 will refuse (display an error and skip the
74 .IR file )
75 to write compressed data to standard output if it is a terminal. Similarly,
76 .B xz
77 will refuse to read compressed data from standard input if it is a terminal.
78 .PP
79 Unless
80 .B \-\-stdout
81 is specified,
82 .I files
83 other than
84 .B \-
85 are written to a new file whose name is derived from the source
86 .I file
87 name:
88 .IP \(bu 3
89 When compressing, the suffix of the target file format
90 .RB ( .xz
91 or
92 .BR .lzma )
93 is appended to the source filename to get the target filename.
94 .IP \(bu 3
95 When decompressing, the
96 .B .xz
97 or
98 .B .lzma
99 suffix is removed from the filename to get the target filename.
100 .B xz
101 also recognizes the suffixes
102 .B .txz
103 and
104 .BR .tlz ,
105 and replaces them with the
106 .B .tar
107 suffix.
108 .PP
109 If the target file already exists, an error is displayed and the
110 .I file
111 is skipped.
112 .PP
113 Unless writing to standard output,
114 .B xz
115 will display a warning and skip the
116 .I file
117 if any of the following applies:
118 .IP \(bu 3
119 .I File
120 is not a regular file. Symbolic links are not followed, thus they
121 are not considered to be regular files.
122 .IP \(bu 3
123 .I File
124 has more than one hard link.
125 .IP \(bu 3
126 .I File
127 has setuid, setgid, or sticky bit set.
128 .IP \(bu 3
129 The operation mode is set to compress, and the
130 .I file
131 already has a suffix of the target file format
132 .RB ( .xz
133 or
134 .B .txz
135 when compressing to the
136 .B .xz
137 format, and
138 .B .lzma
139 or
140 .B .tlz
141 when compressing to the
142 .B .lzma
143 format).
144 .IP \(bu 3
145 The operation mode is set to decompress, and the
146 .I file
147 doesn't have a suffix of any of the supported file formats
148 .RB ( .xz ,
149 .BR .txz ,
150 .BR .lzma ,
151 or
152 .BR .tlz ).
153 .PP
154 After successfully compressing or decompressing the
155 .IR file ,
156 .B xz
157 copies the owner, group, permissions, access time, and modification time
158 from the source
159 .I file
160 to the target file. If copying the group fails, the permissions are modified
161 so that the target file doesn't become accessible to users who didn't have
162 permission to access the source
163 .IR file .
164 .B xz
165 doesn't support copying other metadata like access control lists
166 or extended attributes yet.
167 .PP
168 Once the target file has been successfully closed, the source
169 .I file
170 is removed unless
171 .B \-\-keep
172 was specified. The source
173 .I file
174 is never removed if the output is written to standard output.
175 .PP
176 Sending
177 .B SIGINFO
178 or
179 .B SIGUSR1
180 to the
181 .B xz
182 process makes it print progress information to standard error.
183 This has only limited use since when standard error is a terminal, using
184 .B \-\-verbose
185 will display an automatically updating progress indicator.
186 .SS "Memory usage"
187 The memory usage of
188 .B xz
189 varies from a few hundred kilobytes to several gigabytes depending on
190 the compression settings. The settings used when compressing a file
191 determine the memory requirements of the decompressor. Typically the
192 decompressor needs only 5\ % to 20\ % of the amount of memory that the
193 compressor needed when creating the file. For example, decompressing a
194 file created with
195 .B xz \-9
196 currently requires 65 MiB of memory. Still, it is possible to have
197 .B .xz
198 files that need several gigabytes of memory to decompress.
199 .PP
200 Especially users of older systems may find the possibility of very large
201 memory usage annoying. To prevent uncomfortable surprises,
202 .B xz
203 has a built-in memory usage limiter, which is disabled by default.
204 While some operating systems provide ways to limit the memory usage of
205 processes, relying on it wasn't deemed to be flexible enough (e.g. using
206 .BR ulimit (1)
207 to limit virtual memory tends to cripple
208 .BR mmap (2)).
209 .PP
210 The memory usage limiter can be enabled with the command line option
211 \fB\-\-memlimit=\fIlimit\fR, but often it is more convenient to enable
212 the limiter by default by setting the environment variable
213 .BR XZ_DEFAULTS ,
214 e.g.
215 .BR XZ_DEFAULTS=\-\-memlimit=150MiB .
216 It is possible to set the limits separately for compression and decompression
217 by using \fB\-\-memlimit\-compress=\fIlimit\fR and
218 \fB\-\-memlimit\-decompress=\fIlimit\fR, respectively.
219 Using these two options outside
220 .B XZ_DEFAULTS
221 is rarely useful, because a single run of
222 .B xz
223 cannot do both compression and decompression and
224 .BI \-\-memlimit= limit
225 (or \fB\-M\fR \fIlimit\fR)
226 is shorter to type on the command line.
227 .PP
228 If the specified memory usage limit is exceeded when decompressing,
229 .B xz
230 will display an error and decompressing the file will fail.
231 If the limit is exceeded when compressing,
232 .B xz
233 will try to scale the settings down so that the limit is no longer exceeded
234 (except when using \fB\-\-format=raw\fR or \fB\-\-no\-adjust\fR).
235 This way the operation won't fail unless the limit is very small. The scaling
236 of the settings is done in steps that don't match the compression level
237 presets, e.g. if the limit is only slightly less than the amount required for
238 .BR "xz \-9" ,
239 the settings will be scaled down only a little, not all the way down to
240 .BR "xz \-8" .
241 .SS Concatenation and padding with .xz files
242 It is possible to concatenate
243 .B .xz
244 files as is.
245 .B xz
246 will decompress such files as if they were a single
247 .B .xz
248 file.
249 .PP
250 It is possible to insert padding between the concatenated parts
251 or after the last part. The padding must be null bytes and the size
252 of the padding must be a multiple of four bytes. This can be useful
253 if the .xz file is stored on a medium that stores file sizes
254 e.g. as 512-byte blocks.
255 .PP
256 Concatenation and padding are not allowed with
257 .B .lzma
258 files or raw streams.
259 .SH OPTIONS
260 .SS "Integer suffixes and special values"
261 In most places where an integer argument is expected, an optional suffix
262 is supported to easily indicate large integers. There must be no space
263 between the integer and the suffix.
264 .TP
265 .B KiB
266 The integer is multiplied by 1,024 (2^10). Also
267 .BR Ki ,
268 .BR k ,
269 .BR kB ,
270 .BR K ,
271 and
272 .B KB
273 are accepted as synonyms for
274 .BR KiB .
275 .TP
276 .B MiB
277 The integer is multiplied by 1,048,576 (2^20). Also
278 .BR Mi ,
279 .BR m ,
280 .BR M ,
281 and
282 .B MB
283 are accepted as synonyms for
284 .BR MiB .
285 .TP
286 .B GiB
287 The integer is multiplied by 1,073,741,824 (2^30). Also
288 .BR Gi ,
289 .BR g ,
290 .BR G ,
291 and
292 .B GB
293 are accepted as synonyms for
294 .BR GiB .
295 .PP
296 A special value
297 .B max
298 can be used to indicate the maximum integer value supported by the option.
299 .SS "Operation mode"
300 If multiple operation mode options are given, the last one takes effect.
301 .TP
302 .BR \-z ", " \-\-compress
303 Compress. This is the default operation mode when no operation mode option
304 is specified, and no other operation mode is implied from the command name
305 (for example,
306 .B unxz
307 implies
308 .BR \-\-decompress ).
309 .TP
310 .BR \-d ", " \-\-decompress ", " \-\-uncompress
311 Decompress.
312 .TP
313 .BR \-t ", " \-\-test
314 Test the integrity of compressed
315 .IR files .
316 No files are created or removed. This option is equivalent to
317 .B "\-\-decompress \-\-stdout"
318 except that the decompressed data is discarded instead of being
319 written to standard output.
320 .TP
321 .BR \-l ", " \-\-list
322 List information about compressed
323 .IR files .
324 No uncompressed output is produced, and no files are created or removed.
325 In list mode, the program cannot read the compressed data from standard
326 input or from other unseekable sources.
327 .IP
328 The default listing shows basic information about
329 .IR files ,
330 one file per line. To get more detailed information, use also the
331 .B \-\-verbose
332 option. For even more information, use
333 .B \-\-verbose
334 twice, but note that it may be slow, because getting all the extra
335 information requires many seeks. The width of verbose output exceeds
336 80 characters, so piping the output to e.g.
337 .B "less\ \-S"
338 may be convenient if the terminal isn't wide enough.
339 .IP
340 The exact output may vary between
341 .B xz
342 versions and different locales. To get machine-readable output,
343 .B \-\-robot \-\-list
344 should be used.
345 .SS "Operation modifiers"
346 .TP
347 .BR \-k ", " \-\-keep
348 Keep (don't delete) the input files.
349 .TP
350 .BR \-f ", " \-\-force
351 This option has several effects:
352 .RS
353 .IP \(bu 3
354 If the target file already exists, delete it before compressing or
355 decompressing.
356 .IP \(bu 3
357 Compress or decompress even if the input is a symbolic link to a regular file,
358 has more than one hard link, or has setuid, setgid, or sticky bit set.
359 The setuid, setgid, and sticky bits are not copied to the target file.
360 .IP \(bu 3
361 If combined with
362 .B \-\-decompress
363 .BR \-\-stdout
364 and
365 .B xz
366 doesn't recognize the type of the source file,
367 .B xz
368 will copy the source file as is to standard output. This allows using
369 .B xzcat
370 .B \-\-force
371 like
372 .BR cat (1)
373 for files that have not been compressed with
374 .BR xz .
375 Note that in future,
376 .B xz
377 might support new compressed file formats, which may make
378 .B xz
379 decompress more types of files instead of copying them as is to
380 standard output.
381 .BI \-\-format= format
382 can be used to restrict
383 .B xz
384 to decompress only a single file format.
385 .RE
386 .TP
387 .BR \-c ", " \-\-stdout ", " \-\-to\-stdout
388 Write the compressed or decompressed data to standard output instead of
389 a file. This implies
390 .BR \-\-keep .
391 .TP
392 .B \-\-no\-sparse
393 Disable creation of sparse files. By default, if decompressing into
394 a regular file,
395 .B xz
396 tries to make the file sparse if the decompressed data contains long
397 sequences of binary zeros. It works also when writing to standard output
398 as long as standard output is connected to a regular file, and certain
399 additional conditions are met to make it safe. Creating sparse files may
400 save disk space and speed up the decompression by reducing the amount of
401 disk I/O.
402 .TP
403 \fB\-S\fR \fI.suf\fR, \fB\-\-suffix=\fI.suf
404 When compressing, use
405 .I .suf
406 as the suffix for the target file instead of
407 .B .xz
408 or
409 .BR .lzma .
410 If not writing to standard output and the source file already has the suffix
411 .IR .suf ,
412 a warning is displayed and the file is skipped.
413 .IP
414 When decompressing, recognize also files with the suffix
415 .I .suf
416 in addition to files with the
417 .BR .xz ,
418 .BR .txz ,
419 .BR .lzma ,
420 or
421 .B .tlz
422 suffix. If the source file has the suffix
423 .IR .suf ,
424 the suffix is removed to get the target filename.
425 .IP
426 When compressing or decompressing raw streams
427 .RB ( \-\-format=raw ),
428 the suffix must always be specified unless writing to standard output,
429 because there is no default suffix for raw streams.
430 .TP
431 \fB\-\-files\fR[\fB=\fIfile\fR]
432 Read the filenames to process from
433 .IR file ;
434 if
435 .I file
436 is omitted, filenames are read from standard input. Filenames must be
437 terminated with the newline character. A dash
438 .RB ( \- )
439 is taken as a regular filename; it doesn't mean standard input.
440 If filenames are given also as command line arguments, they are
441 processed before the filenames read from
442 .IR file .
443 .TP
444 \fB\-\-files0\fR[\fB=\fIfile\fR]
445 This is identical to \fB\-\-files\fR[\fB=\fIfile\fR] except that the
446 filenames must be terminated with the null character.
447 .SS "Basic file format and compression options"
448 .TP
449 \fB\-F\fR \fIformat\fR, \fB\-\-format=\fIformat
450 Specify the file format to compress or decompress:
451 .RS
452 .IP \(bu 3
453 .BR auto :
454 This is the default. When compressing,
455 .B auto
456 is equivalent to
457 .BR xz .
458 When decompressing, the format of the input file is automatically detected.
459 Note that raw streams (created with
460 .BR \-\-format=raw )
461 cannot be auto-detected.
462 .IP \(bu 3
463 .BR xz :
464 Compress to the
465 .B .xz
466 file format, or accept only
467 .B .xz
468 files when decompressing.
469 .IP \(bu 3
470 .B lzma
471 or
472 .BR alone :
473 Compress to the legacy
474 .B .lzma
475 file format, or accept only
476 .B .lzma
477 files when decompressing. The alternative name
478 .B alone
479 is provided for backwards compatibility with LZMA Utils.
480 .IP \(bu 3
481 .BR raw :
482 Compress or uncompress a raw stream (no headers). This is meant for advanced
483 users only. To decode raw streams, you need to set not only
484 .B \-\-format=raw
485 but also specify the filter chain, which would normally be stored in the
486 container format headers.
487 .RE
488 .TP
489 \fB\-C\fR \fIcheck\fR, \fB\-\-check=\fIcheck
490 Specify the type of the integrity check, which is calculated from the
491 uncompressed data. This option has an effect only when compressing into the
492 .B .xz
493 format; the
494 .B .lzma
495 format doesn't support integrity checks.
496 The integrity check (if any) is verified when the
497 .B .xz
498 file is decompressed.
499 .IP
500 Supported
501 .I check
502 types:
503 .RS
504 .IP \(bu 3
505 .BR none :
506 Don't calculate an integrity check at all. This is usually a bad idea. This
507 can be useful when integrity of the data is verified by other means anyway.
508 .IP \(bu 3
509 .BR crc32 :
510 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
511 .IP \(bu 3
512 .BR crc64 :
513 Calculate CRC64 using the polynomial from ECMA-182. This is the default, since
514 it is slightly better than CRC32 at detecting damaged files and the speed
515 difference is negligible.
516 .IP \(bu 3
517 .BR sha256 :
518 Calculate SHA-256. This is somewhat slower than CRC32 and CRC64.
519 .RE
520 .IP
521 Integrity of the
522 .B .xz
523 headers is always verified with CRC32. It is not possible to change or
524 disable it.
525 .TP
526 .BR \-0 " ... " \-9
527 Select compression preset. If a preset level is specified multiple times,
528 the last one takes effect.
529 .IP
530 The compression preset levels can be categorised roughly into three
531 categories:
532 .RS
533 .IP "\fB\-0\fR ... \fB\-2"
534 Fast presets with relatively low memory usage.
535 .B \-1
536 and
537 .B \-2
538 should give compression speed and ratios comparable to
539 .B "bzip2 \-1"
540 and
541 .BR "bzip2 \-9" ,
542 respectively.
543 Currently
544 .B \-0
545 is not very good (not much faster than
546 .B \-1
547 but much worse compression). In future,
548 .B \-0
549 may be indicate some fast algorithm instead of LZMA2.
550 .IP "\fB\-3\fR ... \fB\-5"
551 Good compression ratio with low to medium memory usage.
552 These are significantly slower than levels 0\-2.
553 .IP "\fB\-6\fR ... \fB\-9"
554 Excellent compression with medium to high memory usage. These are also
555 slower than the lower preset levels. The default is
556 .BR \-6 .
557 Unless you want to maximize the compression ratio, you probably don't want
558 a higher preset level than
559 .B \-7
560 due to speed and memory usage.
561 .RE
562 .IP
563 The exact compression settings (filter chain) used by each preset may
564 vary between
565 .B xz
566 versions. Because the settings may vary, the memory usage may vary
567 slightly too. FIXME The following
568 table lists the maximum memory usage of each preset level, which won't be
569 exceeded even in future versions of
570 .BR xz .
571 .IP
572 .B "FIXME: The table below is just a rough idea."
573 .RS
574 .RS
575 .TS
576 tab(;);
577 c c c
578 n n n.
579 Preset;Compression;Decompression
580 \-0;6 MiB;1 MiB
581 \-1;6 MiB;1 MiB
582 \-2;10 MiB;1 MiB
583 \-3;20 MiB;2 MiB
584 \-4;30 MiB;3 MiB
585 \-5;60 MiB;6 MiB
586 \-6;100 MiB;10 MiB
587 \-7;200 MiB;20 MiB
588 \-8;400 MiB;40 MiB
589 \-9;800 MiB;80 MiB
590 .TE
591 .RE
592 .RE
593 .TP
594 .BR \-\-fast " and " \-\-best
595 These are somewhat misleading aliases for
596 .B \-0
597 and
598 .BR \-9 ,
599 respectively.
600 These are provided only for backwards compatibility with LZMA Utils.
601 Avoid using these options.
602 .IP
603 Especially the name of
604 .B \-\-best
605 is misleading, because the definition of best depends on the input data,
606 and that usually people don't want the very best compression ratio anyway,
607 because it would be very slow.
608 .TP
609 .BR \-e ", " \-\-extreme
610 Modify the compression preset (\fB\-0\fR ... \fB\-9\fR) so that a little bit
611 better compression ratio can be achieved without increasing memory usage
612 of the compressor or decompressor (exception: compressor memory usage may
613 increase a little with presets \fB\-0\fR ... \fB\-2\fR). The downside is that
614 the compression time will increase dramatically (it can easily double).
615 .TP
616 .BI \-\-memlimit\-compress= limit
617 Set a memory usage limit for compression. If this option is specified
618 multiple times, the last one takes effect.
619 .IP
620 If the compression settings exceed the
621 .IR limit ,
622 .B xz
623 will adjust the settings downwards so that the limit is no longer exceeded
624 and display a notice that automatic adjustment was done. Adjustment is never
625 done when compressing with
626 .B \-\-format=raw
627 or if
628 .B \-\-no\-adjust
629 has been specified. In those cases, an error is displayed and
630 .B xz
631 will exit with exit status
632 .BR 1 .
633 .IP
634 The
635 .I limit
636 can be specified in multiple ways:
637 .RS
638 .IP \(bu 3
639 The
640 .I limit
641 can be an absolute value in bytes. Using an integer suffix like
642 .B MiB
643 can be useful. Example:
644 .B "\-\-memlimit\-compress=80MiB"
645 .IP \(bu 3
646 The
647 .I limit
648 can be specified as a percentage of total physical memory (RAM).
649 This can be useful especially when setting the
650 .B XZ_DEFAULTS
651 environment variable in a shell initialization script that is shared
652 between different computers. That way the limit is automatically bigger
653 on systems with more memory. Example:
654 .B "\-\-memlimit\-compress=70%"
655 .IP \(bu 3
656 The
657 .I limit
658 can be reset back to its default value by setting it to
659 .BR 0 .
660 This is currently equivalent to setting the
661 .I limit
662 to
663 .B max
664 i.e. no memory usage limit. Once multithreading support has been implemented,
665 there may be a difference between
666 .B 0
667 and
668 .B max
669 for the multithreaded case, so it is recommended to use
670 .B 0
671 instead of
672 .B max
673 at least until the details have been decided.
674 .RE
675 .IP
676 See also the section
677 .BR "Memory usage" .
678 .TP
679 .BI \-\-memlimit\-decompress= limit
680 Set a memory usage limit for decompression. This affects also the
681 .B \-\-list
682 mode. If the operation is not possible without exceeding the
683 .IR limit ,
684 .B xz
685 will display an error and decompressing the file will fail. See
686 .BI \-\-memlimit\-compress= limit
687 for possible ways to specify the
688 .IR limit .
689 .TP
690 \fB\-M\fR \fIlimit\fR, \fB\-\-memlimit=\fIlimit\fR, \fB\-\-memory=\fIlimit
691 This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
692 \fB\-\-memlimit\-decompress=\fIlimit\fR.
693 .TP
694 .B \-\-no\-adjust
695 Display an error and exit if the compression settings exceed the
696 the memory usage limit. The default is to adjust the settings downwards so
697 that the memory usage limit is not exceeded. Automatic adjusting is
698 always disabled when creating raw streams
699 .RB ( \-\-format=raw ).
700 .TP
701 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
702 Specify the number of worker threads to use. The actual number of threads
703 can be less than
704 .I threads
705 if using more threads would exceed the memory usage limit.
706 .IP
707 .B "Multithreaded compression and decompression are not implemented yet,"
708 .B "so this option has no effect for now."
709 .IP
710 .B "As of writing (2010-08-07), it hasn't been decided if threads will be"
711 .B "used by default on multicore systems once support for threading has"
712 .B "been implemented. Comments are welcome."
713 The complicating factor is that using many threads will increase the memory
714 usage dramatically. Note that if multithreading will be the default,
715 it will be done so that single-threaded and multithreaded modes produce
716 the same output, so compression ratio won't be significantly affected if
717 threading will be enabled by default.
718 .SS Custom compressor filter chains
719 A custom filter chain allows specifying the compression settings in detail
720 instead of relying on the settings associated to the preset levels.
721 When a custom filter chain is specified, the compression preset level options
722 (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR) are silently ignored.
723 .PP
724 A filter chain is comparable to piping on the UN*X command line.
725 When compressing, the uncompressed input goes to the first filter, whose
726 output goes to the next filter (if any). The output of the last filter
727 gets written to the compressed file. The maximum number of filters in
728 the chain is four, but typically a filter chain has only one or two filters.
729 .PP
730 Many filters have limitations where they can be in the filter chain:
731 some filters can work only as the last filter in the chain, some only
732 as a non-last filter, and some work in any position in the chain. Depending
733 on the filter, this limitation is either inherent to the filter design or
734 exists to prevent security issues.
735 .PP
736 A custom filter chain is specified by using one or more filter options in
737 the order they are wanted in the filter chain. That is, the order of filter
738 options is significant! When decoding raw streams
739 .RB ( \-\-format=raw ),
740 the filter chain is specified in the same order as it was specified when
741 compressing.
742 .PP
743 Filters take filter-specific
744 .I options
745 as a comma-separated list. Extra commas in
746 .I options
747 are ignored. Every option has a default value, so you need to
748 specify only those you want to change.
749 .TP
750 \fB\-\-lzma1\fR[\fB=\fIoptions\fR], \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
751 Add LZMA1 or LZMA2 filter to the filter chain. These filter can be used
752 only as the last filter in the chain.
753 .IP
754 LZMA1 is a legacy filter, which is supported almost solely due to the legacy
755 .B .lzma
756 file format, which supports only LZMA1. LZMA2 is an updated
757 version of LZMA1 to fix some practical issues of LZMA1. The
758 .B .xz
759 format uses LZMA2, and doesn't support LZMA1 at all. Compression speed and
760 ratios of LZMA1 and LZMA2 are practically the same.
761 .IP
762 LZMA1 and LZMA2 share the same set of
763 .IR options :
764 .RS
765 .TP
766 .BI preset= preset
767 Reset all LZMA1 or LZMA2
768 .I options
769 to
770 .IR preset .
771 .I Preset
772 consist of an integer, which may be followed by single-letter preset
773 modifiers. The integer can be from
774 .B 0
775 to
776 .BR 9 ,
777 matching the command line options \fB\-0\fR ... \fB\-9\fR.
778 The only supported modifier is currently
779 .BR e ,
780 which matches
781 .BR \-\-extreme .
782 .IP
783 The default
784 .I preset
785 is
786 .BR 6 ,
787 from which the default values for the rest of the LZMA1 or LZMA2
788 .I options
789 are taken.
790 .TP
791 .BI dict= size
792 Dictionary (history buffer) size indicates how many bytes of the recently
793 processed uncompressed data is kept in memory. One method to reduce size of
794 the uncompressed data is to store distance-length pairs, which
795 indicate what data to repeat from the dictionary buffer. The bigger
796 the dictionary, the better the compression ratio usually is,
797 but dictionaries bigger than the uncompressed data are waste of RAM.
798 .IP
799 Typical dictionary size is from 64 KiB to 64 MiB. The minimum is 4 KiB.
800 The maximum for compression is currently 1.5 GiB. The decompressor already
801 supports dictionaries up to one byte less than 4 GiB, which is the
802 maximum for LZMA1 and LZMA2 stream formats.
803 .IP
804 Dictionary size has the biggest effect on compression ratio.
805 Dictionary size and match finder together determine the memory usage of
806 the LZMA1 or LZMA2 encoder. The same dictionary size is required
807 for decompressing that was used when compressing, thus the memory usage of
808 the decoder is determined by the dictionary size used when compressing.
809 .TP
810 .BI lc= lc
811 Specify the number of literal context bits. The minimum is
812 .B 0
813 and the maximum is
814 .BR 4 ;
815 the default is
816 .BR 3 .
817 In addition, the sum of
818 .I lc
819 and
820 .I lp
821 must not exceed
822 .BR 4 .
823 .TP
824 .BI lp= lp
825 Specify the number of literal position bits. The minimum is
826 .B 0
827 and the maximum is
828 .BR 4 ;
829 the default is
830 .BR 0 .
831 .TP
832 .BI pb= pb
833 Specify the number of position bits. The minimum is
834 .B 0
835 and the maximum is
836 .BR 4 ;
837 the default is
838 .BR 2 .
839 .TP
840 .BI mode= mode
841 Compression
842 .I mode
843 specifies the function used to analyze the data produced by the match finder.
844 Supported
845 .I modes
846 are
847 .B fast
848 and
849 .BR normal .
850 The default is
851 .B fast
852 for
853 .I presets
854 .BR 0 \- 2
855 and
856 .B normal
857 for
858 .I presets
859 .BR 3 \- 9 .
860 .TP
861 .BI mf= mf
862 Match finder has a major effect on encoder speed, memory usage, and
863 compression ratio. Usually Hash Chain match finders are faster than
864 Binary Tree match finders. Hash Chains are usually used together with
865 .B mode=fast
866 and Binary Trees with
867 .BR mode=normal .
868 The memory usage formulas are only rough estimates,
869 which are closest to reality when
870 .I dict
871 is a power of two.
872 .RS
873 .TP
874 .B hc3
875 Hash Chain with 2- and 3-byte hashing
876 .br
877 Minimum value for
878 .IR nice :
879 3
880 .br
881 Memory usage:
882 .I dict
883 * 7.5 (if
884 .I dict
885 <= 16 MiB);
886 .br
887 .I dict
888 * 5.5 + 64 MiB (if
889 .I dict
890 > 16 MiB)
891 .TP
892 .B hc4
893 Hash Chain with 2-, 3-, and 4-byte hashing
894 .br
895 Minimum value for
896 .IR nice :
897 4
898 .br
899 Memory usage:
900 .I dict
901 * 7.5
902 .TP
903 .B bt2
904 Binary Tree with 2-byte hashing
905 .br
906 Minimum value for
907 .IR nice :
908 2
909 .br
910 Memory usage:
911 .I dict
912 * 9.5
913 .TP
914 .B bt3
915 Binary Tree with 2- and 3-byte hashing
916 .br
917 Minimum value for
918 .IR nice :
919 3
920 .br
921 Memory usage:
922 .I dict
923 * 11.5 (if
924 .I dict
925 <= 16 MiB);
926 .br
927 .I dict
928 * 9.5 + 64 MiB (if
929 .I dict
930 > 16 MiB)
931 .TP
932 .B bt4
933 Binary Tree with 2-, 3-, and 4-byte hashing
934 .br
935 Minimum value for
936 .IR nice :
937 4
938 .br
939 Memory usage:
940 .I dict
941 * 11.5
942 .RE
943 .TP
944 .BI nice= nice
945 Specify what is considered to be a nice length for a match. Once a match
946 of at least
947 .I nice
948 bytes is found, the algorithm stops looking for possibly better matches.
949 .IP
950 .I nice
951 can be 2\-273 bytes. Higher values tend to give better compression ratio
952 at expense of speed. The default depends on the
953 .I preset
954 level.
955 .TP
956 .BI depth= depth
957 Specify the maximum search depth in the match finder. The default is the
958 special value
959 .BR 0 ,
960 which makes the compressor determine a reasonable
961 .I depth
962 from
963 .I mf
964 and
965 .IR nice .
966 .IP
967 Using very high values for
968 .I depth
969 can make the encoder extremely slow with carefully crafted files.
970 Avoid setting the
971 .I depth
972 over 1000 unless you are prepared to interrupt the compression in case it
973 is taking too long.
974 .RE
975 .IP
976 When decoding raw streams
977 .RB ( \-\-format=raw ),
978 LZMA2 needs only the value of
979 .BR dict .
980 LZMA1 needs also
981 .BR lc ,
982 .BR lp ,
983 and
984 .BR pb.
985 .TP
986 \fB\-\-x86\fR[\fB=\fIoptions\fR]
987 .TP
988 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
989 .TP
990 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
991 .TP
992 \fB\-\-arm\fR[\fB=\fIoptions\fR]
993 .TP
994 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
995 .TP
996 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
997 Add a branch/call/jump (BCJ) filter to the filter chain. These filters
998 can be used only as non-last filter in the filter chain.
999 .IP
1000 A BCJ filter converts relative addresses in the machine code to their
1001 absolute counterparts. This doesn't change the size of the data, but
1002 it increases redundancy, which allows e.g. LZMA2 to get better
1003 compression ratio.
1004 .IP
1005 The BCJ filters are always reversible, so using a BCJ filter for wrong
1006 type of data doesn't cause any data loss. However, applying a BCJ filter
1007 for wrong type of data is a bad idea, because it tends to make the
1008 compression ratio worse.
1009 .IP
1010 Different instruction sets have have different alignment:
1011 .RS
1012 .RS
1013 .TS
1014 tab(;);
1015 l n l
1016 l n l.
1017 Filter;Alignment;Notes
1018 x86;1;32-bit and 64-bit x86
1019 PowerPC;4;Big endian only
1020 ARM;4;Little endian only
1021 ARM-Thumb;2;Little endian only
1022 IA-64;16;Big or little endian
1023 SPARC;4;Big or little endian
1024 .TE
1025 .RE
1026 .RE
1027 .IP
1028 Since the BCJ-filtered data is usually compressed with LZMA2, the compression
1029 ratio may be improved slightly if the LZMA2 options are set to match the
1030 alignment of the selected BCJ filter. For example, with the IA-64 filter,
1031 it's good to set
1032 .B pb=4
1033 with LZMA2 (2^4=16). The x86 filter is an exception; it's usually good to
1034 stick to LZMA2's default four-byte alignment when compressing x86 executables.
1035 .IP
1036 All BCJ filters support the same
1037 .IR options :
1038 .RS
1039 .TP
1040 .BI start= offset
1041 Specify the start
1042 .I offset
1043 that is used when converting between relative and absolute addresses.
1044 The
1045 .I offset
1046 must be a multiple of the alignment of the filter (see the table above).
1047 The default is zero. In practice, the default is good; specifying
1048 a custom
1049 .I offset
1050 is almost never useful.
1051 .IP
1052 Specifying a non-zero start
1053 .I offset
1054 is probably useful only if the executable has multiple sections, and there
1055 are many cross-section jumps or calls. Applying a BCJ filter separately for
1056 each section with proper start offset and then compressing the result as
1057 a single chunk may give some improvement in compression ratio compared
1058 to applying the BCJ filter with the default
1059 .I offset
1060 for the whole executable.
1061 .RE
1062 .TP
1063 \fB\-\-delta\fR[\fB=\fIoptions\fR]
1064 Add Delta filter to the filter chain. The Delta filter
1065 can be used only as non-last filter in the filter chain.
1066 .IP
1067 Currently only simple byte-wise delta calculation is supported. It can
1068 be useful when compressing e.g. uncompressed bitmap images or uncompressed
1069 PCM audio. However, special purpose algorithms may give significantly better
1070 results than Delta + LZMA2. This is true especially with audio, which
1071 compresses faster and better e.g. with
1072 .BR flac (1).
1073 .IP
1074 Supported
1075 .IR options :
1076 .RS
1077 .TP
1078 .BI dist= distance
1079 Specify the
1080 .I distance
1081 of the delta calculation as bytes.
1082 .I distance
1083 must be 1\-256. The default is 1.
1084 .IP
1085 For example, with
1086 .B dist=2
1087 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
1088 A1 B1 01 02 01 02 01 02.
1089 .RE
1090 .SS "Other options"
1091 .TP
1092 .BR \-q ", " \-\-quiet
1093 Suppress warnings and notices. Specify this twice to suppress errors too.
1094 This option has no effect on the exit status. That is, even if a warning
1095 was suppressed, the exit status to indicate a warning is still used.
1096 .TP
1097 .BR \-v ", " \-\-verbose
1098 Be verbose. If standard error is connected to a terminal,
1099 .B xz
1100 will display a progress indicator.
1101 Specifying
1102 .B \-\-verbose
1103 twice will give even more verbose output (useful mostly for debugging).
1104 .IP
1105 The progress indicator shows the following information:
1106 .RS
1107 .IP \(bu 3
1108 Completion percentage is shown if the size of the input file is known.
1109 That is, percentage cannot be shown in pipes.
1110 .IP \(bu 3
1111 Amount of compressed data produced (compressing) or consumed (decompressing).
1112 .IP \(bu 3
1113 Amount of uncompressed data consumed (compressing) or produced
1114 (decompressing).
1115 .IP \(bu 3
1116 Compression ratio, which is calculated by dividing the amount of
1117 compressed data processed so far by the amount of uncompressed data
1118 processed so far.
1119 .IP \(bu 3
1120 Compression or decompression speed. This is measured as the amount of
1121 uncompressed data consumed (compression) or produced (decompression)
1122 per second. It is shown after a few seconds have passed since
1123 .B xz
1124 started processing the file.
1125 .IP \(bu 3
1126 Elapsed time in the format M:SS or H:MM:SS.
1127 .IP \(bu 3
1128 Estimated remaining time is shown only when the size of the input file is
1129 known and a couple of seconds have already passed since
1130 .B xz
1131 started processing the file. The time is shown in a less precise format which
1132 never has any colons, e.g. 2 min 30 s.
1133 .RE
1134 .IP
1135 When standard error is not a terminal,
1136 .B \-\-verbose
1137 will make
1138 .B xz
1139 print the filename, compressed size, uncompressed size, compression ratio,
1140 and possibly also the speed and elapsed time on a single line to standard
1141 error after compressing or decompressing the file. The speed and elapsed
1142 time are included only when the operation took at least a few seconds.
1143 If the operation didn't finish, for example due to user interruption, also
1144 the completion percentage is printed if the size of the input file is known.
1145 .TP
1146 .BR \-Q ", " \-\-no\-warn
1147 Don't set the exit status to
1148 .B 2
1149 even if a condition worth a warning was detected. This option doesn't affect
1150 the verbosity level, thus both
1151 .B \-\-quiet
1152 and
1153 .B \-\-no\-warn
1154 have to be used to not display warnings and to not alter the exit status.
1155 .TP
1156 .B \-\-robot
1157 Print messages in a machine-parsable format. This is intended to ease
1158 writing frontends that want to use
1159 .B xz
1160 instead of liblzma, which may be the case with various scripts. The output
1161 with this option enabled is meant to be stable across
1162 .B xz
1163 releases. See the section
1164 .B "ROBOT MODE"
1165 for details.
1166 .TP
1167 .BR \-\-info\-memory
1168 Display, in human-readable format, how much physical memory (RAM)
1169 .B xz
1170 thinks the system has and the memory usage limits for compression
1171 and decompression, and exit successfully.
1172 .TP
1173 .BR \-h ", " \-\-help
1174 Display a help message describing the most commonly used options,
1175 and exit successfully.
1176 .TP
1177 .BR \-H ", " \-\-long\-help
1178 Display a help message describing all features of
1179 .BR xz ,
1180 and exit successfully
1181 .TP
1182 .BR \-V ", " \-\-version
1183 Display the version number of
1184 .B xz
1185 and liblzma in human readable format. To get machine-parsable output, specify
1186 .B \-\-robot
1187 before
1188 .BR \-\-version .
1189 .SH ROBOT MODE
1190 The robot mode is activated with the
1191 .B \-\-robot
1192 option. It makes the output of
1193 .B xz
1194 easier to parse by other programs. Currently
1195 .B \-\-robot
1196 is supported only together with
1197 .BR \-\-version ,
1198 .BR \-\-info\-memory ,
1199 and
1200 .BR \-\-list .
1201 It will be supported for normal compression and decompression in the future.
1202 .PP
1203 .SS Version
1204 .B "xz \-\-robot \-\-version"
1205 will print the version number of
1206 .B xz
1207 and liblzma in the following format:
1208 .PP
1209 .BI XZ_VERSION= XYYYZZZS
1210 .br
1211 .BI LIBLZMA_VERSION= XYYYZZZS
1212 .TP
1213 .I X
1214 Major version.
1215 .TP
1216 .I YYY
1217 Minor version. Even numbers are stable.
1218 Odd numbers are alpha or beta versions.
1219 .TP
1220 .I ZZZ
1221 Patch level for stable releases or just a counter for development releases.
1222 .TP
1223 .I S
1224 Stability.
1225 .B 0
1226 is alpha,
1227 .B 1
1228 is beta, and
1229 .B 2
1230 is stable.
1231 .I S
1232 should be always
1233 .B 2
1234 when
1235 .I YYY
1236 is even.
1237 .PP
1238 .I XYYYZZZS
1239 are the same on both lines if
1240 .B xz
1241 and liblzma are from the same XZ Utils release.
1242 .PP
1243 Examples: 4.999.9beta is
1244 .B 49990091
1245 and
1246 5.0.0 is
1247 .BR 50000002 .
1248 .SS Memory limit information
1249 .B "xz \-\-robot \-\-info\-memory"
1250 prints a single line with three tab-separated columns:
1251 .RS
1252 .IP 1. 4
1253 Total amount of physical memory (RAM) as bytes
1254 .IP 2. 4
1255 Memory usage limit for compression as bytes.
1256 A special value of zero indicates the default setting,
1257 which for single-threaded mode is the same as no limit.
1258 .IP 3. 4
1259 Memory usage limit for decompression as bytes.
1260 A special value of zero indicates the default setting,
1261 which for single-threaded mode is the same as no limit.
1262 .RE
1263 .PP
1264 In the future, the output of
1265 .B "xz \-\-robot \-\-info\-memory"
1266 may have more columns, but never more than a single line.
1267 .SS List mode
1268 .B "xz \-\-robot \-\-list"
1269 uses tab-separated output. The first column of every line has a string
1270 that indicates the type of the information found on that line:
1271 .TP
1272 .B name
1273 This is always the first line when starting to list a file. The second
1274 column on the line is the filename.
1275 .TP
1276 .B file
1277 This line contains overall information about the
1278 .B .xz
1279 file. This line is always printed after the
1280 .B name
1281 line.
1282 .TP
1283 .B stream
1284 This line type is used only when
1285 .B \-\-verbose
1286 was specified. There are as many
1287 .B stream
1288 lines as there are streams in the
1289 .B .xz
1290 file.
1291 .TP
1292 .B block
1293 This line type is used only when
1294 .B \-\-verbose
1295 was specified. There are as many
1296 .B block
1297 lines as there are blocks in the
1298 .B .xz
1299 file. The
1300 .B block
1301 lines are shown after all the
1302 .B stream
1303 lines; different line types are not interleaved.
1304 .TP
1305 .B summary
1306 This line type is used only when
1307 .B \-\-verbose
1308 was specified twice. This line is printed after all
1309 .B block
1310 lines. Like the
1311 .B file
1312 line, the
1313 .B summary
1314 line contains overall information about the
1315 .B .xz
1316 file.
1317 .TP
1318 .B totals
1319 This line is always the very last line of the list output. It shows
1320 the total counts and sizes.
1321 .PP
1322 The columns of the
1323 .B file
1324 lines:
1325 .RS
1326 .IP 2. 4
1327 Number of streams in the file
1328 .IP 3. 4
1329 Total number of blocks in the stream(s)
1330 .IP 4. 4
1331 Compressed size of the file
1332 .IP 5. 4
1333 Uncompressed size of the file
1334 .IP 6. 4
1335 Compression ratio, for example
1336 .BR 0.123.
1337 If ratio is over 9.999, three dashes
1338 .RB ( \-\-\- )
1339 are displayed instead of the ratio.
1340 .IP 7. 4
1341 Comma-separated list of integrity check names. The following strings are
1342 used for the known check types:
1343 .BR None ,
1344 .BR CRC32 ,
1345 .BR CRC64 ,
1346 and
1347 .BR SHA\-256 .
1348 For unknown check types,
1349 .BI Unknown\- N
1350 is used, where
1351 .I N
1352 is the Check ID as a decimal number (one or two digits).
1353 .IP 8. 4
1354 Total size of stream padding in the file
1355 .RE
1356 .PP
1357 The columns of the
1358 .B stream
1359 lines:
1360 .RS
1361 .IP 2. 4
1362 Stream number (the first stream is 1)
1363 .IP 3. 4
1364 Number of blocks in the stream
1365 .IP 4. 4
1366 Compressed start offset
1367 .IP 5. 4
1368 Uncompressed start offset
1369 .IP 6. 4
1370 Compressed size (does not include stream padding)
1371 .IP 7. 4
1372 Uncompressed size
1373 .IP 8. 4
1374 Compression ratio
1375 .IP 9. 4
1376 Name of the integrity check
1377 .IP 10. 4
1378 Size of stream padding
1379 .RE
1380 .PP
1381 The columns of the
1382 .B block
1383 lines:
1384 .RS
1385 .IP 2. 4
1386 Number of the stream containing this block
1387 .IP 3. 4
1388 Block number relative to the beginning of the stream (the first block is 1)
1389 .IP 4. 4
1390 Block number relative to the beginning of the file
1391 .IP 5. 4
1392 Compressed start offset relative to the beginning of the file
1393 .IP 6. 4
1394 Uncompressed start offset relative to the beginning of the file
1395 .IP 7. 4
1396 Total compressed size of the block (includes headers)
1397 .IP 8. 4
1398 Uncompressed size
1399 .IP 9. 4
1400 Compression ratio
1401 .IP 10. 4
1402 Name of the integrity check
1403 .RE
1404 .PP
1405 If
1406 .B \-\-verbose
1407 was specified twice, additional columns are included on the
1408 .B block
1409 lines. These are not displayed with a single
1410 .BR \-\-verbose ,
1411 because getting this information requires many seeks and can thus be slow:
1412 .RS
1413 .IP 11. 4
1414 Value of the integrity check in hexadecimal
1415 .IP 12. 4
1416 Block header size
1417 .IP 13. 4
1418 Block flags:
1419 .B c
1420 indicates that compressed size is present, and
1421 .B u
1422 indicates that uncompressed size is present.
1423 If the flag is not set, a dash
1424 .RB ( \- )
1425 is shown instead to keep the string length fixed. New flags may be added
1426 to the end of the string in the future.
1427 .IP 14. 4
1428 Size of the actual compressed data in the block (this excludes
1429 the block header, block padding, and check fields)
1430 .IP 15. 4
1431 Amount of memory (as bytes) required to decompress this block with this
1432 .B xz
1433 version
1434 .IP 16. 4
1435 Filter chain. Note that most of the options used at compression time cannot
1436 be known, because only the options that are needed for decompression are
1437 stored in the
1438 .B .xz
1439 headers.
1440 .RE
1441 .PP
1442 The columns of the
1443 .B totals
1444 line:
1445 .RS
1446 .IP 2. 4
1447 Number of streams
1448 .IP 3. 4
1449 Number of blocks
1450 .IP 4. 4
1451 Compressed size
1452 .IP 5. 4
1453 Uncompressed size
1454 .IP 6. 4
1455 Average compression ratio
1456 .IP 7. 4
1457 Comma-separated list of integrity check names that were present in the files
1458 .IP 8. 4
1459 Stream padding size
1460 .IP 9. 4
1461 Number of files. This is here to keep the order of the earlier columns
1462 the same as on
1463 .B file
1464 lines.
1465 .RE
1466 .PP
1467 If
1468 .B \-\-verbose
1469 was specified twice, additional columns are included on the
1470 .B totals
1471 line:
1472 .RS
1473 .IP 10. 4
1474 Maximum amount of memory (as bytes) required to decompress the files
1475 with this
1476 .B xz
1477 version
1478 .IP 11. 4
1479 .B yes
1480 or
1481 .B no
1482 indicating if all block headers have both compressed size and
1483 uncompressed size stored in them
1484 .RE
1485 .PP
1486 Future versions may add new line types and new columns can be added to
1487 the existing line types, but the existing columns won't be changed.
1488 .SH "EXIT STATUS"
1489 .TP
1490 .B 0
1491 All is good.
1492 .TP
1493 .B 1
1494 An error occurred.
1495 .TP
1496 .B 2
1497 Something worth a warning occurred, but no actual errors occurred.
1498 .PP
1499 Notices (not warnings or errors) printed on standard error don't affect
1500 the exit status.
1501 .SH ENVIRONMENT
1502 .B xz
1503 parses space-separated lists of options from the environment variables
1504 .B XZ_DEFAULTS
1505 and
1506 .BR XZ_OPT ,
1507 in this order, before parsing the options from the command line. Note that
1508 only options are parsed from the environment variables; all non-options
1509 are silently ignored. Parsing is done with
1510 .BR getopt_long (3)
1511 which is used also for the command line arguments.
1512 .TP
1513 .B XZ_DEFAULTS
1514 User-specific or system-wide default options.
1515 Typically this is set in a shell initialization script to enable
1516 .BR xz 's
1517 memory usage limiter by default. Excluding shell initialization scripts
1518 and similar special cases, scripts must never set or unset
1519 .BR XZ_DEFAULTS .
1520 .TP
1521 .B XZ_OPT
1522 This is for passing options to
1523 .B xz
1524 when it is not possible to set the options directly on the
1525 .B xz
1526 command line. This is the case e.g. when
1527 .B xz
1528 is run by a script or tool, e.g. GNU
1529 .BR tar (1):
1530 .RS
1531 .IP
1532 \fBXZ_OPT=\-2v tar caf foo.tar.xz foo
1533 .RE
1534 .IP
1535 Scripts may use
1536 .B XZ_OPT
1537 e.g. to set script-specific default compression options.
1538 It is still recommended to allow users to override
1539 .B XZ_OPT
1540 if that is reasonable, e.g. in
1541 .BR sh (1)
1542 scripts one may use something like this:
1543 .RS
1544 .IP
1545 \fBXZ_OPT=${XZ_OPT\-"\-7e"}; export XZ_OPT
1546 .RE
1547 .IP
1548 .SH "LZMA UTILS COMPATIBILITY"
1549 The command line syntax of
1550 .B xz
1551 is practically a superset of
1552 .BR lzma ,
1553 .BR unlzma ,
1554 and
1555 .BR lzcat
1556 as found from LZMA Utils 4.32.x. In most cases, it is possible to replace
1557 LZMA Utils with XZ Utils without breaking existing scripts. There are some
1558 incompatibilities though, which may sometimes cause problems.
1559 .SS "Compression preset levels"
1560 The numbering of the compression level presets is not identical in
1561 .B xz
1562 and LZMA Utils.
1563 The most important difference is how dictionary sizes are mapped to different
1564 presets. Dictionary size is roughly equal to the decompressor memory usage.
1565 .RS
1566 .TS
1567 tab(;);
1568 c c c
1569 c n n.
1570 Level;xz;LZMA Utils
1571 \-1;64 KiB;64 KiB
1572 \-2;512 KiB;1 MiB
1573 \-3;1 MiB;512 KiB
1574 \-4;2 MiB;1 MiB
1575 \-5;4 MiB;2 MiB
1576 \-6;8 MiB;4 MiB
1577 \-7;16 MiB;8 MiB
1578 \-8;32 MiB;16 MiB
1579 \-9;64 MiB;32 MiB
1580 .TE
1581 .RE
1582 .PP
1583 The dictionary size differences affect the compressor memory usage too,
1584 but there are some other differences between LZMA Utils and XZ Utils, which
1585 make the difference even bigger:
1586 .RS
1587 .TS
1588 tab(;);
1589 c c c
1590 c n n.
1591 Level;xz;LZMA Utils 4.32.x
1592 \-1;2 MiB;2 MiB
1593 \-2;5 MiB;12 MiB
1594 \-3;13 MiB;12 MiB
1595 \-4;25 MiB;16 MiB
1596 \-5;48 MiB;26 MiB
1597 \-6;94 MiB;45 MiB
1598 \-7;186 MiB;83 MiB
1599 \-8;370 MiB;159 MiB
1600 \-9;674 MiB;311 MiB
1601 .TE
1602 .RE
1603 .PP
1604 The default preset level in LZMA Utils is
1605 .B \-7
1606 while in XZ Utils it is
1607 .BR \-6 ,
1608 so both use 8 MiB dictionary by default.
1609 .SS "Streamed vs. non-streamed .lzma files"
1610 Uncompressed size of the file can be stored in the
1611 .B .lzma
1612 header. LZMA Utils does that when compressing regular files.
1613 The alternative is to mark that uncompressed size is unknown and
1614 use end of payload marker to indicate where the decompressor should stop.
1615 LZMA Utils uses this method when uncompressed size isn't known, which is
1616 the case for example in pipes.
1617 .PP
1618 .B xz
1619 supports decompressing
1620 .B .lzma
1621 files with or without end of payload marker, but all
1622 .B .lzma
1623 files created by
1624 .B xz
1625 will use end of payload marker and have uncompressed size marked as unknown
1626 in the
1627 .B .lzma
1628 header. This may be a problem in some (uncommon) situations. For example, a
1629 .B .lzma
1630 decompressor in an embedded device might work only with files that have known
1631 uncompressed size. If you hit this problem, you need to use LZMA Utils or
1632 LZMA SDK to create
1633 .B .lzma
1634 files with known uncompressed size.
1635 .SS "Unsupported .lzma files"
1636 The
1637 .B .lzma
1638 format allows
1639 .I lc
1640 values up to 8, and
1641 .I lp
1642 values up to 4. LZMA Utils can decompress files with any
1643 .I lc
1644 and
1645 .IR lp ,
1646 but always creates files with
1647 .B lc=3
1648 and
1649 .BR lp=0 .
1650 Creating files with other
1651 .I lc
1652 and
1653 .I lp
1654 is possible with
1655 .B xz
1656 and with LZMA SDK.
1657 .PP
1658 The implementation of the LZMA1 filter in liblzma requires
1659 that the sum of
1660 .I lc
1661 and
1662 .I lp
1663 must not exceed 4. Thus,
1664 .B .lzma
1665 files which exceed this limitation, cannot be decompressed with
1666 .BR xz .
1667 .PP
1668 LZMA Utils creates only
1669 .B .lzma
1670 files which have dictionary size of
1671 .RI "2^" n
1672 (a power of 2), but accepts files with any dictionary size.
1673 liblzma accepts only
1674 .B .lzma
1675 files which have dictionary size of
1676 .RI "2^" n
1677 or
1678 .RI "2^" n " + 2^(" n "\-1)."
1679 This is to decrease false positives when detecting
1680 .B .lzma
1681 files.
1682 .PP
1683 These limitations shouldn't be a problem in practice, since practically all
1684 .B .lzma
1685 files have been compressed with settings that liblzma will accept.
1686 .SS "Trailing garbage"
1687 When decompressing, LZMA Utils silently ignore everything after the first
1688 .B .lzma
1689 stream. In most situations, this is a bug. This also means that LZMA Utils
1690 don't support decompressing concatenated
1691 .B .lzma
1692 files.
1693 .PP
1694 If there is data left after the first
1695 .B .lzma
1696 stream,
1697 .B xz
1698 considers the file to be corrupt. This may break obscure scripts which have
1699 assumed that trailing garbage is ignored.
1700 .SH NOTES
1701 .SS Compressed output may vary
1702 The exact compressed output produced from the same uncompressed input file
1703 may vary between XZ Utils versions even if compression options are identical.
1704 This is because the encoder can be improved (faster or better compression)
1705 without affecting the file format. The output can vary even between different
1706 builds of the same XZ Utils version, if different build options are used.
1707 .PP
1708 The above means that implementing
1709 .B \-\-rsyncable
1710 to create rsyncable
1711 .B .xz
1712 files is not going to happen without freezing a part of the encoder
1713 implementation, which can then be used with
1714 .BR \-\-rsyncable .
1715 .SS Embedded .xz decompressors
1716 Embedded
1717 .B .xz
1718 decompressor implementations like XZ Embedded don't necessarily support files
1719 created with
1720 .I check
1721 types other than
1722 .B none
1723 and
1724 .BR crc32 .
1725 Since the default is \fB\-\-check=\fIcrc64\fR, you must use
1726 .B \-\-check=none
1727 or
1728 .B \-\-check=crc32
1729 when creating files for embedded systems.
1730 .PP
1731 Outside embedded systems, all
1732 .B .xz
1733 format decompressors support all the
1734 .I check
1735 types, or at least are able to decompress the file without verifying the
1736 integrity check if the particular
1737 .I check
1738 is not supported.
1739 .PP
1740 XZ Embedded supports BCJ filters, but only with the default start offset.
1741 .SH EXAMPLES
1742 .SS Basics
1743 A mix of compressed and uncompressed files can be decompressed
1744 to standard output with a single command:
1745 .IP
1746 .B "xz \-dcf a.txt b.txt.xz c.txt d.txt.xz > abcd.txt"
1747 .SS Parallel compression of many files
1748 On GNU and *BSD,
1749 .BR find (1)
1750 and
1751 .BR xargs (1)
1752 can be used to parallelize compression of many files:
1753 .PP
1754 .IP
1755 .B "find . \-type f \e! \-name '*.xz' \-print0 |"
1756 .B "xargs \-0r \-P4 \-n16 xz \-T1"
1757 .PP
1758 The
1759 .B \-P
1760 option sets the number of parallel
1761 .B xz
1762 processes. The best value for the
1763 .B \-n
1764 option depends on how many files there are to be compressed.
1765 If there are only a couple of files, the value should probably be
1766 .BR 1 ;
1767 with tens of thousands of files,
1768 .B 100
1769 or even more may be appropriate to reduce the number of
1770 .B xz
1771 processes that
1772 .BR xargs (1)
1773 will eventually create.
1774 .PP
1775 The option
1776 .B \-T1
1777 for
1778 .B xz
1779 is there to force it to single-threaded mode, because
1780 .BR xargs (1)
1781 is used to control the amount of parallelization.
1782 .SS Robot mode examples
1783 Calculating how many bytes have been saved in total after compressing
1784 multiple files:
1785 .IP
1786 .B "xz \-\-robot \-\-list *.xz | awk '/^totals/{print $5\-$4}'"
1787 .SH "SEE ALSO"
1788 .BR xzdec (1),
1789 .BR gzip (1),
1790 .BR bzip2 (1)
1791 .PP
1792 XZ Utils: <http://tukaani.org/xz/>
1793 .br
1794 XZ Embedded: <http://tukaani.org/xz/embedded.html>
1795 .br
1796 LZMA SDK: <http://7-zip.org/sdk.html>