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