3 .\" Author: Lasse Collin
5 .\" This file has been put into the public domain.
6 .\" You can do whatever you want with this file.
8 .TH XZ 1 "2010-09-27" "Tukaani" "XZ Utils"
11 xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
20 .BR "xz \-\-decompress" .
24 .BR "xz \-\-decompress \-\-stdout" .
28 .BR "xz \-\-format=lzma" .
32 .BR "xz \-\-format=lzma \-\-decompress" .
36 .BR "xz \-\-format=lzma \-\-decompress \-\-stdout" .
38 When writing scripts that need to decompress files,
39 it is recommended to always use the name
41 with appropriate arguments
52 is a general-purpose data compression tool with
53 command line syntax similar to
57 The native file format is the
59 format, but the legacy
61 format used by LZMA Utils and
62 raw compressed streams with no container format headers
66 compresses or decompresses each
68 according to the selected operation mode.
76 reads from standard input and writes the processed data
79 will refuse (display an error and skip the
81 to write compressed data to standard output if it is a terminal.
84 will refuse to read compressed data
85 from standard input if it is a terminal.
93 are written to a new file whose name is derived from the source
97 When compressing, the suffix of the target file format
101 is appended to the source filename to get the target filename.
103 When decompressing, the
107 suffix is removed from the filename to get the target filename.
109 also recognizes the suffixes
113 and replaces them with the
117 If the target file already exists, an error is displayed and the
121 Unless writing to standard output,
123 will display a warning and skip the
125 if any of the following applies:
128 is not a regular file.
129 Symbolic links are not followed,
130 thus they are not considered to be regular files.
133 has more than one hard link.
136 has setuid, setgid, or sticky bit set.
138 The operation mode is set to compress, and the
140 already has a suffix of the target file format
144 when compressing to the
150 when compressing to the
154 The operation mode is set to decompress, and the
156 doesn't have a suffix of any of the supported file formats
163 After successfully compressing or decompressing the
166 copies the owner, group, permissions, access time,
167 and modification time from the source
170 If copying the group fails, the permissions are modified
171 so that the target file doesn't become accessible to users
172 who didn't have permission to access the source
175 doesn't support copying other metadata like access control lists
176 or extended attributes yet.
178 Once the target file has been successfully closed, the source
185 is never removed if the output is written to standard output.
193 process makes it print progress information to standard error.
194 This has only limited use since when standard error
197 will display an automatically updating progress indicator.
202 varies from a few hundred kilobytes to several gigabytes
203 depending on the compression settings.
204 The settings used when compressing a file determine
205 the memory requirements of the decompressor.
206 Typically the decompressor needs 5\ % to 20\ % of
207 the amount of memory that the compressor needed when
209 For example, decompressing a file created with
211 currently requires 65\ MiB of memory.
212 Still, it is possible to have
214 files that require several gigabytes of memory to decompress.
216 Especially users of older systems may find
217 the possibility of very large memory usage annoying.
218 To prevent uncomfortable surprises,
220 has a built-in memory usage limiter, which is disabled by default.
221 While some operating systems provide ways to limit
222 the memory usage of processes, relying on it
223 wasn't deemed to be flexible enough (e.g. using
225 to limit virtual memory tends to cripple
228 The memory usage limiter can be enabled with
229 the command line option \fB\-\-memlimit=\fIlimit\fR.
230 Often it is more convenient to enable the limiter
231 by default by setting the environment variable
234 .BR XZ_DEFAULTS=\-\-memlimit=150MiB .
235 It is possible to set the limits separately
236 for compression and decompression
237 by using \fB\-\-memlimit\-compress=\fIlimit\fR and
238 \fB\-\-memlimit\-decompress=\fIlimit\fR.
239 Using these two options outside
241 is rarely useful, because a single run of
243 cannot do both compression and decompression and
244 .BI \-\-memlimit= limit
245 (or \fB\-M\fR \fIlimit\fR)
246 is shorter to type on the command line.
248 If the specified memory usage limit is exceeded when decompressing,
250 will display an error and decompressing the file will fail.
251 If the limit is exceeded when compressing,
253 will try to scale the settings down so that the limit
254 is no longer exceeded (except when using \fB\-\-format=raw\fR
255 or \fB\-\-no\-adjust\fR).
256 This way the operation won't fail unless the limit is very small.
257 The scaling of the settings is done in steps that don't
258 match the compression level presets, e.g. if the limit is
259 only slightly less than the amount required for
261 the settings will be scaled down only a little,
262 not all the way down to
265 .SS "Concatenation and padding with .xz files"
266 It is possible to concatenate
270 will decompress such files as if they were a single
274 It is possible to insert padding between the concatenated parts
275 or after the last part.
276 The padding must consist of null bytes and the size
277 of the padding must be a multiple of four bytes.
278 This can be useful e.g. if the
280 file is stored on a medium that measures file sizes
283 Concatenation and padding are not allowed with
285 files or raw streams.
289 .SS "Integer suffixes and special values"
290 In most places where an integer argument is expected,
291 an optional suffix is supported to easily indicate large integers.
292 There must be no space between the integer and the suffix.
295 Multiply the integer by 1,024 (2^10).
302 are accepted as synonyms for
306 Multiply the integer by 1,048,576 (2^20).
312 are accepted as synonyms for
316 Multiply the integer by 1,073,741,824 (2^30).
322 are accepted as synonyms for
327 can be used to indicate the maximum integer value
328 supported by the option.
331 If multiple operation mode options are given,
332 the last one takes effect.
334 .BR \-z ", " \-\-compress
336 This is the default operation mode when no operation mode option
337 is specified, and no other operation mode is implied from
338 the command name (for example,
341 .BR \-\-decompress ).
343 .BR \-d ", " \-\-decompress ", " \-\-uncompress
346 .BR \-t ", " \-\-test
347 Test the integrity of compressed
349 This option is equivalent to
350 .B "\-\-decompress \-\-stdout"
351 except that the decompressed data is discarded instead of being
352 written to standard output.
353 No files are created or removed.
355 .BR \-l ", " \-\-list
356 Print information about compressed
358 No uncompressed output is produced,
359 and no files are created or removed.
360 In list mode, the program cannot read
361 the compressed data from standard
362 input or from other unseekable sources.
364 The default listing shows basic information about
367 To get more detailed information, use also the
370 For even more information, use
372 twice, but note that it may be slow, because getting all the extra
373 information requires many seeks.
374 The width of verbose output exceeds
375 80 characters, so piping the output to e.g.\&
377 may be convenient if the terminal isn't wide enough.
379 The exact output may vary between
381 versions and different locales.
382 For machine-readable output,
383 .B \-\-robot \-\-list
386 .SS "Operation modifiers"
388 .BR \-k ", " \-\-keep
389 Don't delete the input files.
391 .BR \-f ", " \-\-force
392 This option has several effects:
395 If the target file already exists,
396 delete it before compressing or decompressing.
398 Compress or decompress even if the input is
399 a symbolic link to a regular file,
400 has more than one hard link,
401 or has the setuid, setgid, or sticky bit set.
402 The setuid, setgid, and sticky bits are not copied
410 cannot recognize the type of the source file,
411 copy the source file as is to standard output.
417 for files that have not been compressed with
421 might support new compressed file formats, which may make
423 decompress more types of files instead of copying them as is to
425 .BI \-\-format= format
426 can be used to restrict
428 to decompress only a single file format.
431 .BR \-c ", " \-\-stdout ", " \-\-to\-stdout
432 Write the compressed or decompressed data to
433 standard output instead of a file.
438 Disable creation of sparse files.
439 By default, if decompressing into a regular file,
441 tries to make the file sparse if the decompressed data contains
442 long sequences of binary zeros.
443 It works also when writing to standard output
444 as long as standard output is connected to a regular file,
445 and certain additional conditions are met to make it safe.
446 Creating sparse files may save disk space and speed up
447 the decompression by reducing the amount of disk I/O.
449 \fB\-S\fR \fI.suf\fR, \fB\-\-suffix=\fI.suf
450 When compressing, use
452 as the suffix for the target file instead of
456 If not writing to standard output and
457 the source file already has the suffix
459 a warning is displayed and the file is skipped.
461 When decompressing, recognize files with the suffix
463 in addition to files with the
470 If the source file has the suffix
472 the suffix is removed to get the target filename.
474 When compressing or decompressing raw streams
475 .RB ( \-\-format=raw ),
476 the suffix must always be specified unless
477 writing to standard output,
478 because there is no default suffix for raw streams.
480 \fB\-\-files\fR[\fB=\fIfile\fR]
481 Read the filenames to process from
485 is omitted, filenames are read from standard input.
486 Filenames must be terminated with the newline character.
489 is taken as a regular filename; it doesn't mean standard input.
490 If filenames are given also as command line arguments, they are
491 processed before the filenames read from
494 \fB\-\-files0\fR[\fB=\fIfile\fR]
495 This is identical to \fB\-\-files\fR[\fB=\fIfile\fR] except
496 that each filename must be terminated with the null character.
498 .SS "Basic file format and compression options"
500 \fB\-F\fR \fIformat\fR, \fB\-\-format=\fIformat
503 to compress or decompress:
513 the format of the input file is automatically detected.
514 Note that raw streams (created with
516 cannot be auto-detected.
521 file format, or accept only
523 files when decompressing.
526 Compress to the legacy
528 file format, or accept only
530 files when decompressing.
533 is provided for backwards compatibility with LZMA Utils.
536 Compress or uncompress a raw stream (no headers).
537 This is meant for advanced users only.
538 To decode raw streams, you need use
540 and explicitly specify the filter chain,
541 which normally would have been stored in the container headers.
544 \fB\-C\fR \fIcheck\fR, \fB\-\-check=\fIcheck
545 Specify the type of the integrity check, which is calculated
546 from the uncompressed data.
547 This option has an effect only when compressing into the
551 format doesn't support integrity checks.
552 The integrity check (if any) is verified when the
554 file is decompressed.
562 Don't calculate an integrity check at all.
563 This is usually a bad idea.
564 This can be useful when integrity of the data is verified
565 by other means anyway.
568 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
571 Calculate CRC64 using the polynomial from ECMA-182.
572 This is the default, since it is slightly better than CRC32
573 at detecting damaged files and the speed difference is negligible.
577 This is somewhat slower than CRC32 and CRC64.
582 headers is always verified with CRC32.
583 It is not possible to change or disable it.
586 Select a compression preset level.
589 If multiple preset levels are specified,
590 the last one takes effect.
591 If a custom filter chain was already specified, setting
592 a compression preset level clears the custom filter chain.
594 The differences between the presets are more significant than with
598 The selected compression settings determine
599 the memory requirements of the decompressor,
600 thus using a too high preset level might make it painful
601 to decompress the file on an old system with little RAM.
603 .B "it's not a good idea to blindly use \-9 for everything"
604 like it often is with
610 .BR "\-0" " ... " "\-3"
611 These are somewhat fast presets.
613 is sometimes faster than
615 while compressing much better.
616 The higher ones often have speed comparable to
618 with comparable or better compression ratio,
620 depend a lot on the type of data being compressed.
622 .BR "\-4" " ... " "\-6"
623 Good to very good compression while keeping
624 decompressor memory usage reasonable even for old systems.
626 is the default, which is usually a good choice
627 e.g. for distributing files that need to be decompressible
628 even on systems with only 16\ MiB RAM.
632 may be worth considering too.
639 but with higher compressor and decompressor memory requirements.
640 These are useful only when compressing files bigger than
641 8\ MiB, 16\ MiB, and 32\ MiB, respectively.
644 On the same hardware, the decompression speed is approximately
645 a constant number of bytes of compressed data per second.
646 In other words, the better the compression,
647 the faster the decompression will usually be.
648 This also means that the amount of uncompressed output
649 produced per second can vary a lot.
651 The following table summarises the features of the presets:
659 Preset;DictSize;CompCPU;CompMem;DecMem
660 \-0;256 KiB;0;3 MiB;1 MiB
661 \-1;1 MiB;1;9 MiB;2 MiB
662 \-2;2 MiB;2;17 MiB;3 MiB
663 \-3;4 MiB;3;32 MiB;5 MiB
664 \-4;4 MiB;4;48 MiB;5 MiB
665 \-5;8 MiB;5;94 MiB;9 MiB
666 \-6;8 MiB;6;94 MiB;9 MiB
667 \-7;16 MiB;6;186 MiB;17 MiB
668 \-8;32 MiB;6;370 MiB;33 MiB
669 \-9;64 MiB;6;674 MiB;65 MiB
677 DictSize is the LZMA2 dictionary size.
678 It is waste of memory to use a dictionary bigger than
679 the size of the uncompressed file.
680 This is why it is good to avoid using the presets
682 when there's no real need for them.
685 and lower, the amount of memory wasted is
686 usually low enough to not matter.
688 CompCPU is a simplified representation of the LZMA2 settings
689 that affect compression speed.
690 The dictionary size affects speed too,
691 so while CompCPU is the same for levels
692 .BR \-6 " ... " \-9 ,
693 higher levels still tend to be a little slower.
694 To get even slower and thus possibly better compression, see
697 CompMem contains the compressor memory requirements
698 in the single-threaded mode.
699 It may vary slightly between
702 Memory requirements of some of the future multithreaded modes may
703 be dramatically higher than that of the single-threaded mode.
705 DecMem contains the decompressor memory requirements.
706 That is, the compression settings determine
707 the memory requirements of the decompressor.
708 The exact decompressor memory usage is slighly more than
709 the LZMA2 dictionary size, but the values in the table
710 have been rounded up to the next full MiB.
713 .BR \-e ", " \-\-extreme
714 Use a slower variant of the selected compression preset level
715 .RB ( \-0 " ... " \-9 )
716 to hopefully get a little bit better compression ratio,
717 but with bad luck this can also make it worse.
718 Decompressor memory usage is not affected,
719 but compressor memory usage increases a little at preset levels
720 .BR \-0 " ... " \-3 .
722 Since there are two presets with dictionary sizes
723 4\ MiB and 8\ MiB, the presets
727 use slightly faster settings (lower CompCPU) than
732 That way no two presets are identical.
740 Preset;DictSize;CompCPU;CompMem;DecMem
741 \-0e;256 KiB;8;4 MiB;1 MiB
742 \-1e;1 MiB;8;13 MiB;2 MiB
743 \-2e;2 MiB;8;25 MiB;3 MiB
744 \-3e;4 MiB;7;48 MiB;5 MiB
745 \-4e;4 MiB;8;48 MiB;5 MiB
746 \-5e;8 MiB;7;94 MiB;9 MiB
747 \-6e;8 MiB;8;94 MiB;9 MiB
748 \-7e;16 MiB;8;186 MiB;17 MiB
749 \-8e;32 MiB;8;370 MiB;33 MiB
750 \-9e;64 MiB;8;674 MiB;65 MiB
755 For example, there are a total of four presets that use
756 8\ MiB dictionary, whose order from the fastest to the slowest is
768 These are somewhat misleading aliases for
773 These are provided only for backwards compatibility
775 Avoid using these options.
777 .BI \-\-memlimit\-compress= limit
778 Set a memory usage limit for compression.
779 If this option is specified multiple times,
780 the last one takes effect.
782 If the compression settings exceed the
785 will adjust the settings downwards so that
786 the limit is no longer exceeded and display a notice that
787 automatic adjustment was done.
788 Adjustment is never done when compressing with
793 In those cases, an error is displayed and
795 will exit with exit status 1.
799 can be specified in multiple ways:
804 can be an absolute value in bytes.
805 Using an integer suffix like
809 .B "\-\-memlimit\-compress=80MiB"
813 can be specified as a percentage of total physical memory (RAM).
814 This can be useful especially when setting the
816 environment variable in a shell initialization script
817 that is shared between different computers.
818 That way the limit is automatically bigger
819 on systems with more memory.
821 .B "\-\-memlimit\-compress=70%"
825 can be reset back to its default value by setting it to
827 This is currently equivalent to setting the
831 i.e. no memory usage limit.
832 Once multithreading support has been implemented,
833 there may be a difference between
837 for the multithreaded case, so it is recommended to use
841 until the details have been decided.
847 .BI \-\-memlimit\-decompress= limit
848 Set a memory usage limit for decompression.
849 This affects also the
852 If the operation is not possible without exceeding the
855 will display an error and decompressing the file will fail.
857 .BI \-\-memlimit\-compress= limit
858 for possible ways to specify the
861 \fB\-M\fR \fIlimit\fR, \fB\-\-memlimit=\fIlimit\fR, \fB\-\-memory=\fIlimit
862 This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
863 \fB\-\-memlimit\-decompress=\fIlimit\fR.
866 Display an error and exit if the compression settings exceed the
867 the memory usage limit.
868 The default is to adjust the settings downwards so
869 that the memory usage limit is not exceeded.
870 Automatic adjusting is always disabled when creating raw streams
871 .RB ( \-\-format=raw ).
873 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
874 Specify the number of worker threads to use.
875 The actual number of threads can be less than
877 if using more threads would exceed the memory usage limit.
879 .B "Multithreaded compression and decompression are not"
880 .B "implemented yet, so this option has no effect for now."
882 .B "As of writing (2010-09-27), it hasn't been decided"
883 .B "if threads will be used by default on multicore systems"
884 .B "once support for threading has been implemented."
885 .B "Comments are welcome."
886 The complicating factor is that using many threads
887 will increase the memory usage dramatically.
888 Note that if multithreading will be the default,
889 it will probably be done so that single-threaded and
890 multithreaded modes produce the same output,
891 so compression ratio won't be significantly affected
892 if threading will be enabled by default.
894 .SS "Custom compressor filter chains"
895 A custom filter chain allows specifying
896 the compression settings in detail instead of relying on
897 the settings associated to the preset levels.
898 When a custom filter chain is specified,
899 the compression preset level options
900 (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR) are
903 A filter chain is comparable to piping on the command line.
904 When compressing, the uncompressed input goes to the first filter,
905 whose output goes to the next filter (if any).
906 The output of the last filter gets written to the compressed file.
907 The maximum number of filters in the chain is four,
908 but typically a filter chain has only one or two filters.
910 Many filters have limitations where they can be
912 some filters can work only as the last filter in the chain,
913 some only as a non-last filter, and some work in any position
915 Depending on the filter, this limitation is either inherent to
916 the filter design or exists to prevent security issues.
918 A custom filter chain is specified by using one or more
919 filter options in the order they are wanted in the filter chain.
920 That is, the order of filter options is significant!
921 When decoding raw streams
922 .RB ( \-\-format=raw ),
923 the filter chain is specified in the same order as
924 it was specified when compressing.
926 Filters take filter-specific
928 as a comma-separated list.
932 Every option has a default value, so you need to
933 specify only those you want to change.
935 \fB\-\-lzma1\fR[\fB=\fIoptions\fR]
938 \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
940 Add LZMA1 or LZMA2 filter to the filter chain.
941 These filters can be used only as the last filter in the chain.
943 LZMA1 is a legacy filter,
944 which is supported almost solely due to the legacy
946 file format, which supports only LZMA1.
948 version of LZMA1 to fix some practical issues of LZMA1.
951 format uses LZMA2 and doesn't support LZMA1 at all.
952 Compression speed and ratios of LZMA1 and LZMA2
953 are practically the same.
955 LZMA1 and LZMA2 share the same set of
960 Reset all LZMA1 or LZMA2
965 consist of an integer, which may be followed by single-letter
967 The integer can be from
971 matching the command line options \fB\-0\fR ... \fB\-9\fR.
972 The only supported modifier is currently
980 from which the default values for the rest of the LZMA1 or LZMA2
985 Dictionary (history buffer)
987 indicates how many bytes of the recently processed
988 uncompressed data is kept in memory.
989 The algorithm tries to find repeating byte sequences (matches) in
990 the uncompressed data, and replace them with references
991 to the data currently in the dictionary.
992 The bigger the dictionary, the higher is the chance
994 Thus, increasing dictionary
996 usually improves compression ratio, but
997 a dictionary bigger than the uncompressed file is waste of memory.
1001 is from 64\ KiB to 64\ MiB.
1002 The minimum is 4\ KiB.
1003 The maximum for compression is currently 1.5\ GiB (1536\ MiB).
1004 The decompressor already supports dictionaries up to
1005 one byte less than 4\ GiB, which is the maximum for
1006 the LZMA1 and LZMA2 stream formats.
1012 together determine the memory usage of the LZMA1 or LZMA2 encoder.
1013 The same (or bigger) dictionary
1015 is required for decompressing that was used when compressing,
1016 thus the memory usage of the decoder is determined
1017 by the dictionary size used when compressing.
1020 headers store the dictionary
1025 .RI "2^" n " + 2^(" n "\-1),"
1028 are somewhat preferred for compression.
1031 will get rounded up when stored in the
1036 Specify the number of literal context bits.
1037 The minimum is 0 and the maximum is 4; the default is 3.
1038 In addition, the sum of
1044 All bytes that cannot be encoded as matches
1045 are encoded as literals.
1046 That is, literals are simply 8-bit bytes
1047 that are encoded one at a time.
1049 The literal coding makes an assumption that the highest
1051 bits of the previous uncompressed byte correlate
1053 E.g. in typical English text, an upper-case letter is
1054 often followed by a lower-case letter, and a lower-case
1055 letter is usually followed by another lower-case letter.
1056 In the US-ASCII character set, the highest three bits are 010
1057 for upper-case letters and 011 for lower-case letters.
1060 is at least 3, the literal coding can take advantage of
1061 this property in the uncompressed data.
1063 The default value (3) is usually good.
1064 If you want maximum compression, test
1066 Sometimes it helps a little, and
1067 sometimes it makes compression worse.
1068 If it makes it worse, test e.g.\&
1073 Specify the number of literal position bits.
1074 The minimum is 0 and the maximum is 4; the default is 0.
1077 affects what kind of alignment in the uncompressed data is
1078 assumed when encoding literals.
1081 below for more information about alignment.
1084 Specify the number of position bits.
1085 The minimum is 0 and the maximum is 4; the default is 2.
1088 affects what kind of alignment in the uncompressed data is
1090 The default means four-byte alignment
1092 which is often a good choice when there's no better guess.
1094 When the aligment is known, setting
1096 accordingly may reduce the file size a little.
1097 E.g. with text files having one-byte
1098 alignment (US-ASCII, ISO-8859-*, UTF-8), setting
1100 can improve compression slightly.
1104 If the alignment is an odd number like 3 bytes,
1106 might be the best choice.
1108 Even though the assumed alignment can be adjusted with
1112 LZMA1 and LZMA2 still slightly favor 16-byte alignment.
1113 It might be worth taking into account when designing file formats
1114 that are likely to be often compressed with LZMA1 or LZMA2.
1117 Match finder has a major effect on encoder speed,
1118 memory usage, and compression ratio.
1119 Usually Hash Chain match finders are faster than Binary Tree
1121 The default depends on the
1131 The following match finders are supported.
1132 The memory usage formulas below are rough approximations,
1133 which are closest to the reality when
1139 Hash Chain with 2- and 3-byte hashing
1158 Hash Chain with 2-, 3-, and 4-byte hashing
1177 Binary Tree with 2-byte hashing
1188 Binary Tree with 2- and 3-byte hashing
1207 Binary Tree with 2-, 3-, and 4-byte hashing
1229 specifies the method to analyze
1230 the data produced by the match finder.
1249 is used with Hash Chain match finders and
1251 with Binary Tree match finders.
1252 This is also what the
1257 Specify what is considered to be a nice length for a match.
1258 Once a match of at least
1260 bytes is found, the algorithm stops
1261 looking for possibly better matches.
1264 can be 2\-273 bytes.
1265 Higher values tend to give better compression ratio
1266 at the expense of speed.
1267 The default depends on the
1271 Specify the maximum search depth in the match finder.
1272 The default is the special value of 0,
1273 which makes the compressor determine a reasonable
1282 for Hash Chains is 4\-100 and 16\-1000 for Binary Trees.
1283 Using very high values for
1285 can make the encoder extremely slow with some files.
1288 over 1000 unless you are prepared to interrupt
1289 the compression in case it is taking far too long.
1292 When decoding raw streams
1293 .RB ( \-\-format=raw ),
1294 LZMA2 needs only the dictionary
1302 \fB\-\-x86\fR[\fB=\fIoptions\fR]
1305 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
1307 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
1309 \fB\-\-arm\fR[\fB=\fIoptions\fR]
1311 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
1313 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
1315 Add a branch/call/jump (BCJ) filter to the filter chain.
1316 These filters can be used only as a non-last filter
1317 in the filter chain.
1319 A BCJ filter converts relative addresses in
1320 the machine code to their absolute counterparts.
1321 This doesn't change the size of the data,
1322 but it increases redundancy,
1323 which can help LZMA2 to produce 0\-15\ % smaller
1326 The BCJ filters are always reversible,
1327 so using a BCJ filter for wrong type of data
1328 doesn't cause any data loss, although it may make
1329 the compression ratio slightly worse.
1331 It is fine to apply a BCJ filter on a whole executable;
1332 there's no need to apply it only on the executable section.
1333 Applying a BCJ filter on an archive that contains both executable
1334 and non-executable files may or may not give good results,
1335 so it generally isn't good to blindly apply a BCJ filter when
1336 compressing binary packages for distribution.
1338 These BCJ filters are very fast and
1339 use insignificant amount of memory.
1340 If a BCJ filter improves compression ratio of a file,
1341 it can improve decompression speed at the same time.
1342 This is because, on the same hardware,
1343 the decompression speed of LZMA2 is roughly
1344 a fixed number of bytes of compressed data per second.
1346 These BCJ filters have known problems related to
1347 the compression ratio:
1350 Some types of files containing executable code
1351 (e.g. object files, static libraries, and Linux kernel modules)
1352 have the addresses in the instructions filled with filler values.
1353 These BCJ filters will still do the address conversion,
1354 which will make the compression worse with these files.
1356 Applying a BCJ filter on an archive containing multiple similar
1357 executables can make the compression ratio worse than not using
1359 This is because the BCJ filter doesn't detect the boundaries
1360 of the executable files, and doesn't reset
1361 the address conversion counter for each executable.
1364 Both of the above problems will be fixed
1365 in the future in a new filter.
1366 The old BCJ filters will still be useful in embedded systems,
1367 because the decoder of the new filter will be bigger
1368 and use more memory.
1370 Different instruction sets have have different alignment:
1378 Filter;Alignment;Notes
1379 x86;1;32-bit or 64-bit x86
1380 PowerPC;4;Big endian only
1381 ARM;4;Little endian only
1382 ARM-Thumb;2;Little endian only
1383 IA-64;16;Big or little endian
1384 SPARC;4;Big or little endian
1389 Since the BCJ-filtered data is usually compressed with LZMA2,
1390 the compression ratio may be improved slightly if
1391 the LZMA2 options are set to match the
1392 alignment of the selected BCJ filter.
1393 For example, with the IA-64 filter, it's good to set
1395 with LZMA2 (2^4=16).
1396 The x86 filter is an exception;
1397 it's usually good to stick to LZMA2's default
1398 four-byte alignment when compressing x86 executables.
1400 All BCJ filters support the same
1407 that is used when converting between relative
1408 and absolute addresses.
1411 must be a multiple of the alignment of the filter
1412 (see the table above).
1413 The default is zero.
1414 In practice, the default is good; specifying a custom
1416 is almost never useful.
1419 \fB\-\-delta\fR[\fB=\fIoptions\fR]
1420 Add Delta filter to the filter chain.
1421 The Delta filter can be used only as non-last filter
1422 in the filter chain.
1424 Currently only simple byte-wise delta calculation is supported.
1425 It can be useful when compressing e.g. uncompressed bitmap images
1426 or uncompressed PCM audio.
1427 However, special purpose algorithms may give significantly better
1428 results than Delta + LZMA2.
1429 This is true especially with audio,
1430 which compresses faster and better e.g. with
1440 of the delta calculation in bytes.
1447 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
1448 A1 B1 01 02 01 02 01 02.
1453 .BR \-q ", " \-\-quiet
1454 Suppress warnings and notices.
1455 Specify this twice to suppress errors too.
1456 This option has no effect on the exit status.
1457 That is, even if a warning was suppressed,
1458 the exit status to indicate a warning is still used.
1460 .BR \-v ", " \-\-verbose
1462 If standard error is connected to a terminal,
1464 will display a progress indicator.
1467 twice will give even more verbose output.
1469 The progress indicator shows the following information:
1472 Completion percentage is shown
1473 if the size of the input file is known.
1474 That is, percentage cannot be shown in pipes.
1476 Amount of compressed data produced (compressing)
1477 or consumed (decompressing).
1479 Amount of uncompressed data consumed (compressing)
1480 or produced (decompressing).
1482 Compression ratio, which is calculated by dividing
1483 the amount of compressed data processed so far by
1484 the amount of uncompressed data processed so far.
1486 Compression or decompression speed.
1487 This is measured as the amount of uncompressed data consumed
1488 (compression) or produced (decompression) per second.
1489 It is shown after a few seconds have passed since
1491 started processing the file.
1493 Elapsed time in the format M:SS or H:MM:SS.
1495 Estimated remaining time is shown
1496 only when the size of the input file is
1497 known and a couple of seconds have already passed since
1499 started processing the file.
1500 The time is shown in a less precise format which
1501 never has any colons, e.g. 2 min 30 s.
1504 When standard error is not a terminal,
1508 print the filename, compressed size, uncompressed size,
1509 compression ratio, and possibly also the speed and elapsed time
1510 on a single line to standard error after compressing or
1511 decompressing the file.
1512 The speed and elapsed time are included only when
1513 the operation took at least a few seconds.
1514 If the operation didn't finish, e.g. due to user interruption,
1515 also the completion percentage is printed
1516 if the size of the input file is known.
1518 .BR \-Q ", " \-\-no\-warn
1519 Don't set the exit status to 2
1520 even if a condition worth a warning was detected.
1521 This option doesn't affect the verbosity level, thus both
1525 have to be used to not display warnings and
1526 to not alter the exit status.
1529 Print messages in a machine-parsable format.
1530 This is intended to ease writing frontends that want to use
1532 instead of liblzma, which may be the case with various scripts.
1533 The output with this option enabled is meant to be stable across
1540 .BR \-\-info\-memory
1541 Display, in human-readable format, how much physical memory (RAM)
1543 thinks the system has and the memory usage limits for compression
1544 and decompression, and exit successfully.
1546 .BR \-h ", " \-\-help
1547 Display a help message describing the most commonly used options,
1548 and exit successfully.
1550 .BR \-H ", " \-\-long\-help
1551 Display a help message describing all features of
1553 and exit successfully
1555 .BR \-V ", " \-\-version
1556 Display the version number of
1558 and liblzma in human readable format.
1559 To get machine-parsable output, specify
1565 The robot mode is activated with the
1568 It makes the output of
1570 easier to parse by other programs.
1573 is supported only together with
1575 .BR \-\-info\-memory ,
1578 It will be supported for normal compression and
1579 decompression in the future.
1582 .B "xz \-\-robot \-\-version"
1583 will print the version number of
1585 and liblzma in the following format:
1587 .BI XZ_VERSION= XYYYZZZS
1589 .BI LIBLZMA_VERSION= XYYYZZZS
1596 Even numbers are stable.
1597 Odd numbers are alpha or beta versions.
1600 Patch level for stable releases or
1601 just a counter for development releases.
1605 0 is alpha, 1 is beta, and 2 is stable.
1607 should be always 2 when
1612 are the same on both lines if
1614 and liblzma are from the same XZ Utils release.
1616 Examples: 4.999.9beta is
1622 .SS "Memory limit information"
1623 .B "xz \-\-robot \-\-info\-memory"
1624 prints a single line with three tab-separated columns:
1626 Total amount of physical memory (RAM) in bytes
1628 Memory usage limit for compression in bytes.
1629 A special value of zero indicates the default setting,
1630 which for single-threaded mode is the same as no limit.
1632 Memory usage limit for decompression in bytes.
1633 A special value of zero indicates the default setting,
1634 which for single-threaded mode is the same as no limit.
1636 In the future, the output of
1637 .B "xz \-\-robot \-\-info\-memory"
1638 may have more columns, but never more than a single line.
1641 .B "xz \-\-robot \-\-list"
1642 uses tab-separated output.
1643 The first column of every line has a string
1644 that indicates the type of the information found on that line:
1647 This is always the first line when starting to list a file.
1648 The second column on the line is the filename.
1651 This line contains overall information about the
1654 This line is always printed after the
1659 This line type is used only when
1664 lines as there are streams in the
1669 This line type is used only when
1674 lines as there are blocks in the
1679 lines are shown after all the
1681 lines; different line types are not interleaved.
1684 This line type is used only when
1686 was specified twice.
1687 This line is printed after all
1694 line contains overall information about the
1699 This line is always the very last line of the list output.
1700 It shows the total counts and sizes.
1708 Number of streams in the file
1710 Total number of blocks in the stream(s)
1712 Compressed size of the file
1714 Uncompressed size of the file
1716 Compression ratio, for example
1718 If ratio is over 9.999, three dashes
1720 are displayed instead of the ratio.
1722 Comma-separated list of integrity check names.
1723 The following strings are used for the known check types:
1729 For unknown check types,
1733 is the Check ID as a decimal number (one or two digits).
1735 Total size of stream padding in the file
1745 Stream number (the first stream is 1)
1747 Number of blocks in the stream
1749 Compressed start offset
1751 Uncompressed start offset
1753 Compressed size (does not include stream padding)
1759 Name of the integrity check
1761 Size of stream padding
1771 Number of the stream containing this block
1773 Block number relative to the beginning of the stream
1774 (the first block is 1)
1776 Block number relative to the beginning of the file
1778 Compressed start offset relative to the beginning of the file
1780 Uncompressed start offset relative to the beginning of the file
1782 Total compressed size of the block (includes headers)
1788 Name of the integrity check
1794 was specified twice, additional columns are included on the
1797 These are not displayed with a single
1799 because getting this information requires many seeks
1800 and can thus be slow:
1804 Value of the integrity check in hexadecimal
1810 indicates that compressed size is present, and
1812 indicates that uncompressed size is present.
1813 If the flag is not set, a dash
1815 is shown instead to keep the string length fixed.
1816 New flags may be added to the end of the string in the future.
1818 Size of the actual compressed data in the block (this excludes
1819 the block header, block padding, and check fields)
1821 Amount of memory (in bytes) required to decompress
1822 this block with this
1827 Note that most of the options used at compression time
1828 cannot be known, because only the options
1829 that are needed for decompression are stored in the
1849 Average compression ratio
1851 Comma-separated list of integrity check names
1852 that were present in the files
1858 keep the order of the earlier columns the same as on
1866 was specified twice, additional columns are included on the
1872 Maximum amount of memory (in bytes) required to decompress
1880 indicating if all block headers have both compressed size and
1881 uncompressed size stored in them
1885 Future versions may add new line types and
1886 new columns can be added to the existing line types,
1887 but the existing columns won't be changed.
1898 Something worth a warning occurred,
1899 but no actual errors occurred.
1901 Notices (not warnings or errors) printed on standard error
1902 don't affect the exit status.
1906 parses space-separated lists of options
1907 from the environment variables
1911 in this order, before parsing the options from the command line.
1912 Note that only options are parsed from the environment variables;
1913 all non-options are silently ignored.
1914 Parsing is done with
1916 which is used also for the command line arguments.
1919 User-specific or system-wide default options.
1920 Typically this is set in a shell initialization script to enable
1922 memory usage limiter by default.
1923 Excluding shell initialization scripts
1924 and similar special cases, scripts must never set or unset
1928 This is for passing options to
1930 when it is not possible to set the options directly on the
1933 This is the case e.g. when
1935 is run by a script or tool, e.g. GNU
1942 XZ_OPT=\-2v tar caf foo.tar.xz foo
1950 e.g. to set script-specific default compression options.
1951 It is still recommended to allow users to override
1953 if that is reasonable, e.g. in
1955 scripts one may use something like this:
1961 XZ_OPT=${XZ_OPT\-"\-7e"}
1968 .SH "LZMA UTILS COMPATIBILITY"
1969 The command line syntax of
1971 is practically a superset of
1976 as found from LZMA Utils 4.32.x.
1977 In most cases, it is possible to replace
1978 LZMA Utils with XZ Utils without breaking existing scripts.
1979 There are some incompatibilities though,
1980 which may sometimes cause problems.
1982 .SS "Compression preset levels"
1983 The numbering of the compression level presets is not identical in
1986 The most important difference is how dictionary sizes
1987 are mapped to different presets.
1988 Dictionary size is roughly equal to the decompressor memory usage.
2009 The dictionary size differences affect
2010 the compressor memory usage too,
2011 but there are some other differences between
2012 LZMA Utils and XZ Utils, which
2013 make the difference even bigger:
2020 Level;xz;LZMA Utils 4.32.x
2034 The default preset level in LZMA Utils is
2036 while in XZ Utils it is
2038 so both use an 8 MiB dictionary by default.
2040 .SS "Streamed vs. non-streamed .lzma files"
2041 The uncompressed size of the file can be stored in the
2044 LZMA Utils does that when compressing regular files.
2045 The alternative is to mark that uncompressed size is unknown
2046 and use end of payload marker to indicate
2047 where the decompressor should stop.
2048 LZMA Utils uses this method when uncompressed size isn't known,
2049 which is the case for example in pipes.
2052 supports decompressing
2054 files with or without end of payload marker, but all
2058 will use end of payload marker and have uncompressed size
2059 marked as unknown in the
2062 This may be a problem in some uncommon situations.
2065 decompressor in an embedded device might work
2066 only with files that have known uncompressed size.
2067 If you hit this problem, you need to use LZMA Utils
2068 or LZMA SDK to create
2070 files with known uncompressed size.
2072 .SS "Unsupported .lzma files"
2080 LZMA Utils can decompress files with any
2084 but always creates files with
2088 Creating files with other
2096 The implementation of the LZMA1 filter in liblzma
2097 requires that the sum of
2104 files, which exceed this limitation, cannot be decompressed with
2107 LZMA Utils creates only
2109 files which have a dictionary size of
2111 (a power of 2) but accepts files with any dictionary size.
2112 liblzma accepts only
2114 files which have a dictionary size of
2117 .RI "2^" n " + 2^(" n "\-1)."
2118 This is to decrease false positives when detecting
2122 These limitations shouldn't be a problem in practice,
2123 since practically all
2125 files have been compressed with settings that liblzma will accept.
2127 .SS "Trailing garbage"
2129 LZMA Utils silently ignore everything after the first
2132 In most situations, this is a bug.
2133 This also means that LZMA Utils
2134 don't support decompressing concatenated
2138 If there is data left after the first
2142 considers the file to be corrupt.
2143 This may break obscure scripts which have
2144 assumed that trailing garbage is ignored.
2148 .SS "Compressed output may vary"
2149 The exact compressed output produced from
2150 the same uncompressed input file
2151 may vary between XZ Utils versions even if
2152 compression options are identical.
2153 This is because the encoder can be improved
2154 (faster or better compression)
2155 without affecting the file format.
2156 The output can vary even between different
2157 builds of the same XZ Utils version,
2158 if different build options are used.
2160 The above means that implementing
2164 files is not going to happen without
2165 freezing a part of the encoder
2166 implementation, which can then be used with
2169 .SS "Embedded .xz decompressors"
2172 decompressor implementations like XZ Embedded don't necessarily
2173 support files created with integrity
2179 Since the default is
2180 .BR \-\-check=crc64 ,
2185 when creating files for embedded systems.
2187 Outside embedded systems, all
2189 format decompressors support all the
2191 types, or at least are able to decompress
2192 the file without verifying the
2193 integrity check if the particular
2197 XZ Embedded supports BCJ filters,
2198 but only with the default start offset.
2207 using the default compression level
2211 if compression is successful:
2227 even if decompression is successful:
2241 .RB ( "\-4 \-\-extreme" ),
2242 which is slower than e.g. the default
2244 but needs less memory for compression and decompression (48\ MiB
2245 and 5\ MiB, respectively):
2250 tar cf \- baz | xz \-4e > baz.tar.xz
2255 A mix of compressed and uncompressed files can be decompressed
2256 to standard output with a single command:
2261 xz \-dcf a.txt b.txt.xz c.txt d.txt.lzma > abcd.txt
2266 .SS "Parallel compression of many files"
2271 can be used to parallelize compression of many files:
2276 find . \-type f \e! \-name '*.xz' \-print0 \e
2277 | xargs \-0r \-P4 \-n16 xz \-T1
2286 sets the number of parallel
2289 The best value for the
2291 option depends on how many files there are to be compressed.
2292 If there are only a couple of files,
2293 the value should probably be 1;
2294 with tens of thousands of files,
2295 100 or even more may be appropriate to reduce the number of
2299 will eventually create.
2305 is there to force it to single-threaded mode, because
2307 is used to control the amount of parallelization.
2310 Calculate how many bytes have been saved in total
2311 after compressing multiple files:
2316 xz \-\-robot \-\-list *.xz | awk '/^totals/{print $5\-$4}'
2321 A script may want to know that it is using new enough
2325 script checks that the version number of the
2327 tool is at least 5.0.0.
2328 This method is compatible with old beta versions,
2329 which didn't support the
2336 if ! eval "$(xz \-\-robot \-\-version 2> /dev/null)" ||
2337 [ "$XZ_VERSION" \-lt 50000002 ]; then
2338 echo "Your xz is too old."
2340 unset XZ_VERSION LIBLZMA_VERSION
2345 Set a memory usage limit for decompression using
2347 but if a limit has already been set, don't increase it:
2352 NEWLIM=$((123 << 20)) # 123 MiB
2353 OLDLIM=$(xz \-\-robot \-\-info\-memory | cut \-f3)
2354 if [ $OLDLIM \-eq 0 \-o $OLDLIM \-gt $NEWLIM ]; then
2355 XZ_OPT="$XZ_OPT \-\-memlimit\-decompress=$NEWLIM"
2362 .SS "Custom compressor filter chains"
2363 The simplest use for custom filter chains is
2364 customizing a LZMA2 preset.
2366 because the presets cover only a subset of the
2367 potentially useful combinations of compression settings.
2369 The CompCPU columns of the tables
2370 from the descriptions of the options
2371 .BR "\-0" " ... " "\-9"
2374 are useful when customizing LZMA2 presets.
2375 Here are the relevant parts collected from those two tables:
2395 If you know that a file requires
2396 somewhat big dictionary (e.g. 32 MiB) to compress well,
2397 but you want to compress it quicker than
2399 would do, a preset with a low CompCPU value (e.g. 1)
2400 can be modified to use a bigger dictionary:
2405 xz \-\-lzma2=preset=1,dict=32MiB foo.tar
2410 With certain files, the above command may be faster than
2412 while compressing significantly better.
2413 However, it must be emphasized that only some files benefit from
2414 a big dictionary while keeping the CompCPU value low.
2415 The most obvious situation,
2416 where a big dictionary can help a lot,
2417 is an archive containing very similar files
2418 of at least a few megabytes each.
2419 The dictionary size has to be significantly bigger
2420 than any individual file to allow LZMA2 to take
2421 full advantage of the similarities between consecutive files.
2423 If very high compressor and decompressor memory usage is fine,
2424 and the file being compressed is
2425 at least several hundred megabytes, it may be useful
2426 to use an even bigger dictionary than the 64 MiB that
2433 xz \-vv \-\-lzma2=dict=192MiB big_foo.tar
2440 .RB ( "\-\-verbose \-\-verbose" )
2441 like in the above example can be useful
2442 to see the memory requirements
2443 of the compressor and decompressor.
2444 Remember that using a dictionary bigger than
2445 the size of the uncompressed file is waste of memory,
2446 so the above command isn't useful for small files.
2448 Sometimes the compression time doesn't matter,
2449 but the decompressor memory usage has to be kept low
2450 e.g. to make it possible to decompress the file on
2452 The following command uses
2454 .RB ( "\-6 \-\-extreme" )
2455 as a base and sets the dictionary to only 64\ KiB.
2456 The resulting file can be decompressed with XZ Embedded
2457 (that's why there is
2458 .BR \-\-check=crc32 )
2459 using about 100\ KiB of memory.
2464 xz \-\-check=crc32 \-\-lzma2=preset=6e,dict=64KiB foo
2469 If you want to squeeze out as many bytes as possible,
2470 adjusting the number of literal context bits
2472 and number of position bits
2475 Adjusting the number of literal position bits
2477 might help too, but usually
2482 E.g. a source code archive contains mostly US-ASCII text,
2483 so something like the following might give
2484 slightly (like 0.1\ %) smaller file than
2492 xz \-\-lzma2=preset=6e,pb=0,lc=4 source_code.tar
2497 Using another filter together with LZMA2 can improve
2498 compression with certain file types.
2499 E.g. to compress a x86-32 or x86-64 shared library
2500 using the x86 BCJ filter:
2505 xz \-\-x86 \-\-lzma2 libfoo.so
2510 Note that the order of the filter options is significant.
2517 because there cannot be any filter after LZMA2,
2518 and also because the x86 BCJ filter cannot be used
2519 as the last filter in the chain.
2521 The Delta filter together with LZMA2
2522 can give good results with bitmap images.
2523 It should usually beat PNG,
2524 which has a few more advanced filters than simple
2525 delta but uses Deflate for the actual compression.
2527 The image has to be saved in uncompressed format,
2528 e.g. as uncompressed TIFF.
2529 The distance parameter of the Delta filter is set
2530 to match the number of bytes per pixel in the image.
2531 E.g. 24-bit RGB bitmap needs
2533 and it is also good to pass
2535 to LZMA2 to accomodate the three-byte alignment:
2540 xz \-\-delta=dist=3 \-\-lzma2=pb=0 foo.tiff
2545 If multiple images have been put into a single archive (e.g.\&
2547 the Delta filter will work on that too as long as all images
2548 have the same number of bytes per pixel.
2560 XZ Utils: <http://tukaani.org/xz/>
2562 XZ Embedded: <http://tukaani.org/xz/embedded.html>
2564 LZMA SDK: <http://7-zip.org/sdk.html>