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-10-04" "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 and 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 this may be slow, because getting all the extra
373 information requires many seeks.
374 The width of verbose output exceeds
375 80 characters, so piping the output to e.g.\&
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 also works when writing to standard output
444 as long as standard output is connected to a regular file
445 and certain additional conditions are met to make it safe.
446 Creating sparse files may save disk space and speed up
447 the decompression by reducing the amount of disk I/O.
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.
546 The check is calculated from the uncompressed data and
550 This option has an effect only when compressing into the
554 format doesn't support integrity checks.
555 The integrity check (if any) is verified when the
557 file is decompressed.
565 Don't calculate an integrity check at all.
566 This is usually a bad idea.
567 This can be useful when integrity of the data is verified
568 by other means anyway.
571 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
574 Calculate CRC64 using the polynomial from ECMA-182.
575 This is the default, since it is slightly better than CRC32
576 at detecting damaged files and the speed difference is negligible.
580 This is somewhat slower than CRC32 and CRC64.
585 headers is always verified with CRC32.
586 It is not possible to change or disable it.
589 Select a compression preset level.
592 If multiple preset levels are specified,
593 the last one takes effect.
594 If a custom filter chain was already specified, setting
595 a compression preset level clears the custom filter chain.
597 The differences between the presets are more significant than with
601 The selected compression settings determine
602 the memory requirements of the decompressor,
603 thus using a too high preset level might make it painful
604 to decompress the file on an old system with little RAM.
606 .B "it's not a good idea to blindly use \-9 for everything"
607 like it often is with
613 .BR "\-0" " ... " "\-3"
614 These are somewhat fast presets.
616 is sometimes faster than
618 while compressing much better.
619 The higher ones often have speed comparable to
621 with comparable or better compression ratio,
623 depend a lot on the type of data being compressed.
625 .BR "\-4" " ... " "\-6"
626 Good to very good compression while keeping
627 decompressor memory usage reasonable even for old systems.
629 is the default, which is usually a good choice
630 e.g. for distributing files that need to be decompressible
631 even on systems with only 16\ MiB RAM.
635 may be worth considering too.
642 but with higher compressor and decompressor memory requirements.
643 These are useful only when compressing files bigger than
644 8\ MiB, 16\ MiB, and 32\ MiB, respectively.
647 On the same hardware, the decompression speed is approximately
648 a constant number of bytes of compressed data per second.
649 In other words, the better the compression,
650 the faster the decompression will usually be.
651 This also means that the amount of uncompressed output
652 produced per second can vary a lot.
654 The following table summarises the features of the presets:
662 Preset;DictSize;CompCPU;CompMem;DecMem
663 \-0;256 KiB;0;3 MiB;1 MiB
664 \-1;1 MiB;1;9 MiB;2 MiB
665 \-2;2 MiB;2;17 MiB;3 MiB
666 \-3;4 MiB;3;32 MiB;5 MiB
667 \-4;4 MiB;4;48 MiB;5 MiB
668 \-5;8 MiB;5;94 MiB;9 MiB
669 \-6;8 MiB;6;94 MiB;9 MiB
670 \-7;16 MiB;6;186 MiB;17 MiB
671 \-8;32 MiB;6;370 MiB;33 MiB
672 \-9;64 MiB;6;674 MiB;65 MiB
680 DictSize is the LZMA2 dictionary size.
681 It is waste of memory to use a dictionary bigger than
682 the size of the uncompressed file.
683 This is why it is good to avoid using the presets
685 when there's no real need for them.
688 and lower, the amount of memory wasted is
689 usually low enough to not matter.
691 CompCPU is a simplified representation of the LZMA2 settings
692 that affect compression speed.
693 The dictionary size affects speed too,
694 so while CompCPU is the same for levels
695 .BR \-6 " ... " \-9 ,
696 higher levels still tend to be a little slower.
697 To get even slower and thus possibly better compression, see
700 CompMem contains the compressor memory requirements
701 in the single-threaded mode.
702 It may vary slightly between
705 Memory requirements of some of the future multithreaded modes may
706 be dramatically higher than that of the single-threaded mode.
708 DecMem contains the decompressor memory requirements.
709 That is, the compression settings determine
710 the memory requirements of the decompressor.
711 The exact decompressor memory usage is slighly more than
712 the LZMA2 dictionary size, but the values in the table
713 have been rounded up to the next full MiB.
716 .BR \-e ", " \-\-extreme
717 Use a slower variant of the selected compression preset level
718 .RB ( \-0 " ... " \-9 )
719 to hopefully get a little bit better compression ratio,
720 but with bad luck this can also make it worse.
721 Decompressor memory usage is not affected,
722 but compressor memory usage increases a little at preset levels
723 .BR \-0 " ... " \-3 .
725 Since there are two presets with dictionary sizes
726 4\ MiB and 8\ MiB, the presets
730 use slightly faster settings (lower CompCPU) than
735 That way no two presets are identical.
743 Preset;DictSize;CompCPU;CompMem;DecMem
744 \-0e;256 KiB;8;4 MiB;1 MiB
745 \-1e;1 MiB;8;13 MiB;2 MiB
746 \-2e;2 MiB;8;25 MiB;3 MiB
747 \-3e;4 MiB;7;48 MiB;5 MiB
748 \-4e;4 MiB;8;48 MiB;5 MiB
749 \-5e;8 MiB;7;94 MiB;9 MiB
750 \-6e;8 MiB;8;94 MiB;9 MiB
751 \-7e;16 MiB;8;186 MiB;17 MiB
752 \-8e;32 MiB;8;370 MiB;33 MiB
753 \-9e;64 MiB;8;674 MiB;65 MiB
758 For example, there are a total of four presets that use
759 8\ MiB dictionary, whose order from the fastest to the slowest is
771 These are somewhat misleading aliases for
776 These are provided only for backwards compatibility
778 Avoid using these options.
780 .BI \-\-memlimit\-compress= limit
781 Set a memory usage limit for compression.
782 If this option is specified multiple times,
783 the last one takes effect.
785 If the compression settings exceed the
788 will adjust the settings downwards so that
789 the limit is no longer exceeded and display a notice that
790 automatic adjustment was done.
791 Such adjustments are not made when compressing with
796 In those cases, an error is displayed and
798 will exit with exit status 1.
802 can be specified in multiple ways:
807 can be an absolute value in bytes.
808 Using an integer suffix like
812 .B "\-\-memlimit\-compress=80MiB"
816 can be specified as a percentage of total physical memory (RAM).
817 This can be useful especially when setting the
819 environment variable in a shell initialization script
820 that is shared between different computers.
821 That way the limit is automatically bigger
822 on systems with more memory.
824 .B "\-\-memlimit\-compress=70%"
828 can be reset back to its default value by setting it to
830 This is currently equivalent to setting the
834 (no memory usage limit).
835 Once multithreading support has been implemented,
836 there may be a difference between
840 for the multithreaded case, so it is recommended to use
844 until the details have been decided.
850 .BI \-\-memlimit\-decompress= limit
851 Set a memory usage limit for decompression.
852 This also affects the
855 If the operation is not possible without exceeding the
858 will display an error and decompressing the file will fail.
860 .BI \-\-memlimit\-compress= limit
861 for possible ways to specify the
864 \fB\-M\fR \fIlimit\fR, \fB\-\-memlimit=\fIlimit\fR, \fB\-\-memory=\fIlimit
865 This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
866 \fB\-\-memlimit\-decompress=\fIlimit\fR.
869 Display an error and exit if the compression settings exceed the
870 the memory usage limit.
871 The default is to adjust the settings downwards so
872 that the memory usage limit is not exceeded.
873 Automatic adjusting is always disabled when creating raw streams
874 .RB ( \-\-format=raw ).
876 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
877 Specify the number of worker threads to use.
878 The actual number of threads can be less than
880 if using more threads would exceed the memory usage limit.
882 .B "Multithreaded compression and decompression are not"
883 .B "implemented yet, so this option has no effect for now."
885 .B "As of writing (2010-09-27), it hasn't been decided"
886 .B "if threads will be used by default on multicore systems"
887 .B "once support for threading has been implemented."
888 .B "Comments are welcome."
889 The complicating factor is that using many threads
890 will increase the memory usage dramatically.
891 Note that if multithreading will be the default,
892 it will probably be done so that single-threaded and
893 multithreaded modes produce the same output,
894 so compression ratio won't be significantly affected
895 if threading will be enabled by default.
897 .SS "Custom compressor filter chains"
898 A custom filter chain allows specifying
899 the compression settings in detail instead of relying on
900 the settings associated to the preset levels.
901 When a custom filter chain is specified,
902 the compression preset level options
903 (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR) are
906 A filter chain is comparable to piping on the command line.
907 When compressing, the uncompressed input goes to the first filter,
908 whose output goes to the next filter (if any).
909 The output of the last filter gets written to the compressed file.
910 The maximum number of filters in the chain is four,
911 but typically a filter chain has only one or two filters.
913 Many filters have limitations on where they can be
915 some filters can work only as the last filter in the chain,
916 some only as a non-last filter, and some work in any position
918 Depending on the filter, this limitation is either inherent to
919 the filter design or exists to prevent security issues.
921 A custom filter chain is specified by using one or more
922 filter options in the order they are wanted in the filter chain.
923 That is, the order of filter options is significant!
924 When decoding raw streams
925 .RB ( \-\-format=raw ),
926 the filter chain is specified in the same order as
927 it was specified when compressing.
929 Filters take filter-specific
931 as a comma-separated list.
935 Every option has a default value, so you need to
936 specify only those you want to change.
938 \fB\-\-lzma1\fR[\fB=\fIoptions\fR]
941 \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
943 Add LZMA1 or LZMA2 filter to the filter chain.
944 These filters can be used only as the last filter in the chain.
946 LZMA1 is a legacy filter,
947 which is supported almost solely due to the legacy
949 file format, which supports only LZMA1.
951 version of LZMA1 to fix some practical issues of LZMA1.
954 format uses LZMA2 and doesn't support LZMA1 at all.
955 Compression speed and ratios of LZMA1 and LZMA2
956 are practically the same.
958 LZMA1 and LZMA2 share the same set of
963 Reset all LZMA1 or LZMA2
968 consist of an integer, which may be followed by single-letter
970 The integer can be from
974 matching the command line options \fB\-0\fR ... \fB\-9\fR.
975 The only supported modifier is currently
983 from which the default values for the rest of the LZMA1 or LZMA2
988 Dictionary (history buffer)
990 indicates how many bytes of the recently processed
991 uncompressed data is kept in memory.
992 The algorithm tries to find repeating byte sequences (matches) in
993 the uncompressed data, and replace them with references
994 to the data currently in the dictionary.
995 The bigger the dictionary, the higher is the chance
997 Thus, increasing dictionary
999 usually improves compression ratio, but
1000 a dictionary bigger than the uncompressed file is waste of memory.
1004 is from 64\ KiB to 64\ MiB.
1005 The minimum is 4\ KiB.
1006 The maximum for compression is currently 1.5\ GiB (1536\ MiB).
1007 The decompressor already supports dictionaries up to
1008 one byte less than 4\ GiB, which is the maximum for
1009 the LZMA1 and LZMA2 stream formats.
1015 together determine the memory usage of the LZMA1 or LZMA2 encoder.
1016 The same (or bigger) dictionary
1018 is required for decompressing that was used when compressing,
1019 thus the memory usage of the decoder is determined
1020 by the dictionary size used when compressing.
1023 headers store the dictionary
1028 .RI "2^" n " + 2^(" n "\-1),"
1031 are somewhat preferred for compression.
1034 will get rounded up when stored in the
1039 Specify the number of literal context bits.
1040 The minimum is 0 and the maximum is 4; the default is 3.
1041 In addition, the sum of
1047 All bytes that cannot be encoded as matches
1048 are encoded as literals.
1049 That is, literals are simply 8-bit bytes
1050 that are encoded one at a time.
1052 The literal coding makes an assumption that the highest
1054 bits of the previous uncompressed byte correlate
1056 E.g. in typical English text, an upper-case letter is
1057 often followed by a lower-case letter, and a lower-case
1058 letter is usually followed by another lower-case letter.
1059 In the US-ASCII character set, the highest three bits are 010
1060 for upper-case letters and 011 for lower-case letters.
1063 is at least 3, the literal coding can take advantage of
1064 this property in the uncompressed data.
1066 The default value (3) is usually good.
1067 If you want maximum compression, test
1069 Sometimes it helps a little, and
1070 sometimes it makes compression worse.
1071 If it makes it worse, test e.g.\&
1076 Specify the number of literal position bits.
1077 The minimum is 0 and the maximum is 4; the default is 0.
1080 affects what kind of alignment in the uncompressed data is
1081 assumed when encoding literals.
1084 below for more information about alignment.
1087 Specify the number of position bits.
1088 The minimum is 0 and the maximum is 4; the default is 2.
1091 affects what kind of alignment in the uncompressed data is
1093 The default means four-byte alignment
1095 which is often a good choice when there's no better guess.
1097 When the aligment is known, setting
1099 accordingly may reduce the file size a little.
1100 E.g. with text files having one-byte
1101 alignment (US-ASCII, ISO-8859-*, UTF-8), setting
1103 can improve compression slightly.
1107 If the alignment is an odd number like 3 bytes,
1109 might be the best choice.
1111 Even though the assumed alignment can be adjusted with
1115 LZMA1 and LZMA2 still slightly favor 16-byte alignment.
1116 It might be worth taking into account when designing file formats
1117 that are likely to be often compressed with LZMA1 or LZMA2.
1120 Match finder has a major effect on encoder speed,
1121 memory usage, and compression ratio.
1122 Usually Hash Chain match finders are faster than Binary Tree
1124 The default depends on the
1134 The following match finders are supported.
1135 The memory usage formulas below are rough approximations,
1136 which are closest to the reality when
1142 Hash Chain with 2- and 3-byte hashing
1161 Hash Chain with 2-, 3-, and 4-byte hashing
1180 Binary Tree with 2-byte hashing
1191 Binary Tree with 2- and 3-byte hashing
1210 Binary Tree with 2-, 3-, and 4-byte hashing
1232 specifies the method to analyze
1233 the data produced by the match finder.
1252 is used with Hash Chain match finders and
1254 with Binary Tree match finders.
1255 This is also what the
1260 Specify what is considered to be a nice length for a match.
1261 Once a match of at least
1263 bytes is found, the algorithm stops
1264 looking for possibly better matches.
1267 can be 2\-273 bytes.
1268 Higher values tend to give better compression ratio
1269 at the expense of speed.
1270 The default depends on the
1274 Specify the maximum search depth in the match finder.
1275 The default is the special value of 0,
1276 which makes the compressor determine a reasonable
1285 for Hash Chains is 4\-100 and 16\-1000 for Binary Trees.
1286 Using very high values for
1288 can make the encoder extremely slow with some files.
1291 over 1000 unless you are prepared to interrupt
1292 the compression in case it is taking far too long.
1295 When decoding raw streams
1296 .RB ( \-\-format=raw ),
1297 LZMA2 needs only the dictionary
1305 \fB\-\-x86\fR[\fB=\fIoptions\fR]
1308 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
1310 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
1312 \fB\-\-arm\fR[\fB=\fIoptions\fR]
1314 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
1316 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
1318 Add a branch/call/jump (BCJ) filter to the filter chain.
1319 These filters can be used only as a non-last filter
1320 in the filter chain.
1322 A BCJ filter converts relative addresses in
1323 the machine code to their absolute counterparts.
1324 This doesn't change the size of the data,
1325 but it increases redundancy,
1326 which can help LZMA2 to produce 0\-15\ % smaller
1329 The BCJ filters are always reversible,
1330 so using a BCJ filter for wrong type of data
1331 doesn't cause any data loss, although it may make
1332 the compression ratio slightly worse.
1334 It is fine to apply a BCJ filter on a whole executable;
1335 there's no need to apply it only on the executable section.
1336 Applying a BCJ filter on an archive that contains both executable
1337 and non-executable files may or may not give good results,
1338 so it generally isn't good to blindly apply a BCJ filter when
1339 compressing binary packages for distribution.
1341 These BCJ filters are very fast and
1342 use insignificant amount of memory.
1343 If a BCJ filter improves compression ratio of a file,
1344 it can improve decompression speed at the same time.
1345 This is because, on the same hardware,
1346 the decompression speed of LZMA2 is roughly
1347 a fixed number of bytes of compressed data per second.
1349 These BCJ filters have known problems related to
1350 the compression ratio:
1353 Some types of files containing executable code
1354 (e.g. object files, static libraries, and Linux kernel modules)
1355 have the addresses in the instructions filled with filler values.
1356 These BCJ filters will still do the address conversion,
1357 which will make the compression worse with these files.
1359 Applying a BCJ filter on an archive containing multiple similar
1360 executables can make the compression ratio worse than not using
1362 This is because the BCJ filter doesn't detect the boundaries
1363 of the executable files, and doesn't reset
1364 the address conversion counter for each executable.
1367 Both of the above problems will be fixed
1368 in the future in a new filter.
1369 The old BCJ filters will still be useful in embedded systems,
1370 because the decoder of the new filter will be bigger
1371 and use more memory.
1373 Different instruction sets have have different alignment:
1381 Filter;Alignment;Notes
1382 x86;1;32-bit or 64-bit x86
1383 PowerPC;4;Big endian only
1384 ARM;4;Little endian only
1385 ARM-Thumb;2;Little endian only
1386 IA-64;16;Big or little endian
1387 SPARC;4;Big or little endian
1392 Since the BCJ-filtered data is usually compressed with LZMA2,
1393 the compression ratio may be improved slightly if
1394 the LZMA2 options are set to match the
1395 alignment of the selected BCJ filter.
1396 For example, with the IA-64 filter, it's good to set
1398 with LZMA2 (2^4=16).
1399 The x86 filter is an exception;
1400 it's usually good to stick to LZMA2's default
1401 four-byte alignment when compressing x86 executables.
1403 All BCJ filters support the same
1410 that is used when converting between relative
1411 and absolute addresses.
1414 must be a multiple of the alignment of the filter
1415 (see the table above).
1416 The default is zero.
1417 In practice, the default is good; specifying a custom
1419 is almost never useful.
1422 \fB\-\-delta\fR[\fB=\fIoptions\fR]
1423 Add the Delta filter to the filter chain.
1424 The Delta filter can be only used as a non-last filter
1425 in the filter chain.
1427 Currently only simple byte-wise delta calculation is supported.
1428 It can be useful when compressing e.g. uncompressed bitmap images
1429 or uncompressed PCM audio.
1430 However, special purpose algorithms may give significantly better
1431 results than Delta + LZMA2.
1432 This is true especially with audio,
1433 which compresses faster and better e.g. with
1443 of the delta calculation in bytes.
1450 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
1451 A1 B1 01 02 01 02 01 02.
1456 .BR \-q ", " \-\-quiet
1457 Suppress warnings and notices.
1458 Specify this twice to suppress errors too.
1459 This option has no effect on the exit status.
1460 That is, even if a warning was suppressed,
1461 the exit status to indicate a warning is still used.
1463 .BR \-v ", " \-\-verbose
1465 If standard error is connected to a terminal,
1467 will display a progress indicator.
1470 twice will give even more verbose output.
1472 The progress indicator shows the following information:
1475 Completion percentage is shown
1476 if the size of the input file is known.
1477 That is, the percentage cannot be shown in pipes.
1479 Amount of compressed data produced (compressing)
1480 or consumed (decompressing).
1482 Amount of uncompressed data consumed (compressing)
1483 or produced (decompressing).
1485 Compression ratio, which is calculated by dividing
1486 the amount of compressed data processed so far by
1487 the amount of uncompressed data processed so far.
1489 Compression or decompression speed.
1490 This is measured as the amount of uncompressed data consumed
1491 (compression) or produced (decompression) per second.
1492 It is shown after a few seconds have passed since
1494 started processing the file.
1496 Elapsed time in the format M:SS or H:MM:SS.
1498 Estimated remaining time is shown
1499 only when the size of the input file is
1500 known and a couple of seconds have already passed since
1502 started processing the file.
1503 The time is shown in a less precise format which
1504 never has any colons, e.g. 2 min 30 s.
1507 When standard error is not a terminal,
1511 print the filename, compressed size, uncompressed size,
1512 compression ratio, and possibly also the speed and elapsed time
1513 on a single line to standard error after compressing or
1514 decompressing the file.
1515 The speed and elapsed time are included only when
1516 the operation took at least a few seconds.
1517 If the operation didn't finish, e.g. due to user interruption,
1518 also the completion percentage is printed
1519 if the size of the input file is known.
1521 .BR \-Q ", " \-\-no\-warn
1522 Don't set the exit status to 2
1523 even if a condition worth a warning was detected.
1524 This option doesn't affect the verbosity level, thus both
1528 have to be used to not display warnings and
1529 to not alter the exit status.
1532 Print messages in a machine-parsable format.
1533 This is intended to ease writing frontends that want to use
1535 instead of liblzma, which may be the case with various scripts.
1536 The output with this option enabled is meant to be stable across
1543 .BR \-\-info\-memory
1544 Display, in human-readable format, how much physical memory (RAM)
1546 thinks the system has and the memory usage limits for compression
1547 and decompression, and exit successfully.
1549 .BR \-h ", " \-\-help
1550 Display a help message describing the most commonly used options,
1551 and exit successfully.
1553 .BR \-H ", " \-\-long\-help
1554 Display a help message describing all features of
1556 and exit successfully
1558 .BR \-V ", " \-\-version
1559 Display the version number of
1561 and liblzma in human readable format.
1562 To get machine-parsable output, specify
1568 The robot mode is activated with the
1571 It makes the output of
1573 easier to parse by other programs.
1576 is supported only together with
1578 .BR \-\-info\-memory ,
1581 It will be supported for normal compression and
1582 decompression in the future.
1585 .B "xz \-\-robot \-\-version"
1586 will print the version number of
1588 and liblzma in the following format:
1590 .BI XZ_VERSION= XYYYZZZS
1592 .BI LIBLZMA_VERSION= XYYYZZZS
1599 Even numbers are stable.
1600 Odd numbers are alpha or beta versions.
1603 Patch level for stable releases or
1604 just a counter for development releases.
1608 0 is alpha, 1 is beta, and 2 is stable.
1610 should be always 2 when
1615 are the same on both lines if
1617 and liblzma are from the same XZ Utils release.
1619 Examples: 4.999.9beta is
1625 .SS "Memory limit information"
1626 .B "xz \-\-robot \-\-info\-memory"
1627 prints a single line with three tab-separated columns:
1629 Total amount of physical memory (RAM) in bytes
1631 Memory usage limit for compression in bytes.
1632 A special value of zero indicates the default setting,
1633 which for single-threaded mode is the same as no limit.
1635 Memory usage limit for decompression in bytes.
1636 A special value of zero indicates the default setting,
1637 which for single-threaded mode is the same as no limit.
1639 In the future, the output of
1640 .B "xz \-\-robot \-\-info\-memory"
1641 may have more columns, but never more than a single line.
1644 .B "xz \-\-robot \-\-list"
1645 uses tab-separated output.
1646 The first column of every line has a string
1647 that indicates the type of the information found on that line:
1650 This is always the first line when starting to list a file.
1651 The second column on the line is the filename.
1654 This line contains overall information about the
1657 This line is always printed after the
1662 This line type is used only when
1667 lines as there are streams in the
1672 This line type is used only when
1677 lines as there are blocks in the
1682 lines are shown after all the
1684 lines; different line types are not interleaved.
1687 This line type is used only when
1689 was specified twice.
1690 This line is printed after all
1697 line contains overall information about the
1702 This line is always the very last line of the list output.
1703 It shows the total counts and sizes.
1711 Number of streams in the file
1713 Total number of blocks in the stream(s)
1715 Compressed size of the file
1717 Uncompressed size of the file
1719 Compression ratio, for example
1721 If ratio is over 9.999, three dashes
1723 are displayed instead of the ratio.
1725 Comma-separated list of integrity check names.
1726 The following strings are used for the known check types:
1732 For unknown check types,
1736 is the Check ID as a decimal number (one or two digits).
1738 Total size of stream padding in the file
1748 Stream number (the first stream is 1)
1750 Number of blocks in the stream
1752 Compressed start offset
1754 Uncompressed start offset
1756 Compressed size (does not include stream padding)
1762 Name of the integrity check
1764 Size of stream padding
1774 Number of the stream containing this block
1776 Block number relative to the beginning of the stream
1777 (the first block is 1)
1779 Block number relative to the beginning of the file
1781 Compressed start offset relative to the beginning of the file
1783 Uncompressed start offset relative to the beginning of the file
1785 Total compressed size of the block (includes headers)
1791 Name of the integrity check
1797 was specified twice, additional columns are included on the
1800 These are not displayed with a single
1802 because getting this information requires many seeks
1803 and can thus be slow:
1807 Value of the integrity check in hexadecimal
1813 indicates that compressed size is present, and
1815 indicates that uncompressed size is present.
1816 If the flag is not set, a dash
1818 is shown instead to keep the string length fixed.
1819 New flags may be added to the end of the string in the future.
1821 Size of the actual compressed data in the block (this excludes
1822 the block header, block padding, and check fields)
1824 Amount of memory (in bytes) required to decompress
1825 this block with this
1830 Note that most of the options used at compression time
1831 cannot be known, because only the options
1832 that are needed for decompression are stored in the
1852 Average compression ratio
1854 Comma-separated list of integrity check names
1855 that were present in the files
1861 keep the order of the earlier columns the same as on
1869 was specified twice, additional columns are included on the
1875 Maximum amount of memory (in bytes) required to decompress
1883 indicating if all block headers have both compressed size and
1884 uncompressed size stored in them
1888 Future versions may add new line types and
1889 new columns can be added to the existing line types,
1890 but the existing columns won't be changed.
1901 Something worth a warning occurred,
1902 but no actual errors occurred.
1904 Notices (not warnings or errors) printed on standard error
1905 don't affect the exit status.
1909 parses space-separated lists of options
1910 from the environment variables
1914 in this order, before parsing the options from the command line.
1915 Note that only options are parsed from the environment variables;
1916 all non-options are silently ignored.
1917 Parsing is done with
1919 which is used also for the command line arguments.
1922 User-specific or system-wide default options.
1923 Typically this is set in a shell initialization script to enable
1925 memory usage limiter by default.
1926 Excluding shell initialization scripts
1927 and similar special cases, scripts must never set or unset
1931 This is for passing options to
1933 when it is not possible to set the options directly on the
1936 This is the case e.g. when
1938 is run by a script or tool, e.g. GNU
1945 XZ_OPT=\-2v tar caf foo.tar.xz foo
1953 e.g. to set script-specific default compression options.
1954 It is still recommended to allow users to override
1956 if that is reasonable, e.g. in
1958 scripts one may use something like this:
1964 XZ_OPT=${XZ_OPT\-"\-7e"}
1971 .SH "LZMA UTILS COMPATIBILITY"
1972 The command line syntax of
1974 is practically a superset of
1979 as found from LZMA Utils 4.32.x.
1980 In most cases, it is possible to replace
1981 LZMA Utils with XZ Utils without breaking existing scripts.
1982 There are some incompatibilities though,
1983 which may sometimes cause problems.
1985 .SS "Compression preset levels"
1986 The numbering of the compression level presets is not identical in
1989 The most important difference is how dictionary sizes
1990 are mapped to different presets.
1991 Dictionary size is roughly equal to the decompressor memory usage.
2012 The dictionary size differences affect
2013 the compressor memory usage too,
2014 but there are some other differences between
2015 LZMA Utils and XZ Utils, which
2016 make the difference even bigger:
2023 Level;xz;LZMA Utils 4.32.x
2037 The default preset level in LZMA Utils is
2039 while in XZ Utils it is
2041 so both use an 8 MiB dictionary by default.
2043 .SS "Streamed vs. non-streamed .lzma files"
2044 The uncompressed size of the file can be stored in the
2047 LZMA Utils does that when compressing regular files.
2048 The alternative is to mark that uncompressed size is unknown
2049 and use end-of-payload marker to indicate
2050 where the decompressor should stop.
2051 LZMA Utils uses this method when uncompressed size isn't known,
2052 which is the case for example in pipes.
2055 supports decompressing
2057 files with or without end-of-payload marker, but all
2061 will use end-of-payload marker and have uncompressed size
2062 marked as unknown in the
2065 This may be a problem in some uncommon situations.
2068 decompressor in an embedded device might work
2069 only with files that have known uncompressed size.
2070 If you hit this problem, you need to use LZMA Utils
2071 or LZMA SDK to create
2073 files with known uncompressed size.
2075 .SS "Unsupported .lzma files"
2083 LZMA Utils can decompress files with any
2087 but always creates files with
2091 Creating files with other
2099 The implementation of the LZMA1 filter in liblzma
2100 requires that the sum of
2107 files, which exceed this limitation, cannot be decompressed with
2110 LZMA Utils creates only
2112 files which have a dictionary size of
2114 (a power of 2) but accepts files with any dictionary size.
2115 liblzma accepts only
2117 files which have a dictionary size of
2120 .RI "2^" n " + 2^(" n "\-1)."
2121 This is to decrease false positives when detecting
2125 These limitations shouldn't be a problem in practice,
2126 since practically all
2128 files have been compressed with settings that liblzma will accept.
2130 .SS "Trailing garbage"
2132 LZMA Utils silently ignore everything after the first
2135 In most situations, this is a bug.
2136 This also means that LZMA Utils
2137 don't support decompressing concatenated
2141 If there is data left after the first
2145 considers the file to be corrupt.
2146 This may break obscure scripts which have
2147 assumed that trailing garbage is ignored.
2151 .SS "Compressed output may vary"
2152 The exact compressed output produced from
2153 the same uncompressed input file
2154 may vary between XZ Utils versions even if
2155 compression options are identical.
2156 This is because the encoder can be improved
2157 (faster or better compression)
2158 without affecting the file format.
2159 The output can vary even between different
2160 builds of the same XZ Utils version,
2161 if different build options are used.
2163 The above means that implementing
2167 files is not going to happen without
2168 freezing a part of the encoder
2169 implementation, which can then be used with
2172 .SS "Embedded .xz decompressors"
2175 decompressor implementations like XZ Embedded don't necessarily
2176 support files created with integrity
2182 Since the default is
2183 .BR \-\-check=crc64 ,
2188 when creating files for embedded systems.
2190 Outside embedded systems, all
2192 format decompressors support all the
2194 types, or at least are able to decompress
2195 the file without verifying the
2196 integrity check if the particular
2200 XZ Embedded supports BCJ filters,
2201 but only with the default start offset.
2210 using the default compression level
2214 if compression is successful:
2230 even if decompression is successful:
2244 .RB ( "\-4 \-\-extreme" ),
2245 which is slower than e.g. the default
2247 but needs less memory for compression and decompression (48\ MiB
2248 and 5\ MiB, respectively):
2253 tar cf \- baz | xz \-4e > baz.tar.xz
2258 A mix of compressed and uncompressed files can be decompressed
2259 to standard output with a single command:
2264 xz \-dcf a.txt b.txt.xz c.txt d.txt.lzma > abcd.txt
2269 .SS "Parallel compression of many files"
2274 can be used to parallelize compression of many files:
2279 find . \-type f \e! \-name '*.xz' \-print0 \e
2280 | xargs \-0r \-P4 \-n16 xz \-T1
2289 sets the number of parallel
2292 The best value for the
2294 option depends on how many files there are to be compressed.
2295 If there are only a couple of files,
2296 the value should probably be 1;
2297 with tens of thousands of files,
2298 100 or even more may be appropriate to reduce the number of
2302 will eventually create.
2308 is there to force it to single-threaded mode, because
2310 is used to control the amount of parallelization.
2313 Calculate how many bytes have been saved in total
2314 after compressing multiple files:
2319 xz \-\-robot \-\-list *.xz | awk '/^totals/{print $5\-$4}'
2324 A script may want to know that it is using new enough
2328 script checks that the version number of the
2330 tool is at least 5.0.0.
2331 This method is compatible with old beta versions,
2332 which didn't support the
2339 if ! eval "$(xz \-\-robot \-\-version 2> /dev/null)" ||
2340 [ "$XZ_VERSION" \-lt 50000002 ]; then
2341 echo "Your xz is too old."
2343 unset XZ_VERSION LIBLZMA_VERSION
2348 Set a memory usage limit for decompression using
2350 but if a limit has already been set, don't increase it:
2355 NEWLIM=$((123 << 20)) # 123 MiB
2356 OLDLIM=$(xz \-\-robot \-\-info\-memory | cut \-f3)
2357 if [ $OLDLIM \-eq 0 \-o $OLDLIM \-gt $NEWLIM ]; then
2358 XZ_OPT="$XZ_OPT \-\-memlimit\-decompress=$NEWLIM"
2365 .SS "Custom compressor filter chains"
2366 The simplest use for custom filter chains is
2367 customizing a LZMA2 preset.
2369 because the presets cover only a subset of the
2370 potentially useful combinations of compression settings.
2372 The CompCPU columns of the tables
2373 from the descriptions of the options
2374 .BR "\-0" " ... " "\-9"
2377 are useful when customizing LZMA2 presets.
2378 Here are the relevant parts collected from those two tables:
2398 If you know that a file requires
2399 somewhat big dictionary (e.g. 32 MiB) to compress well,
2400 but you want to compress it quicker than
2402 would do, a preset with a low CompCPU value (e.g. 1)
2403 can be modified to use a bigger dictionary:
2408 xz \-\-lzma2=preset=1,dict=32MiB foo.tar
2413 With certain files, the above command may be faster than
2415 while compressing significantly better.
2416 However, it must be emphasized that only some files benefit from
2417 a big dictionary while keeping the CompCPU value low.
2418 The most obvious situation,
2419 where a big dictionary can help a lot,
2420 is an archive containing very similar files
2421 of at least a few megabytes each.
2422 The dictionary size has to be significantly bigger
2423 than any individual file to allow LZMA2 to take
2424 full advantage of the similarities between consecutive files.
2426 If very high compressor and decompressor memory usage is fine,
2427 and the file being compressed is
2428 at least several hundred megabytes, it may be useful
2429 to use an even bigger dictionary than the 64 MiB that
2436 xz \-vv \-\-lzma2=dict=192MiB big_foo.tar
2443 .RB ( "\-\-verbose \-\-verbose" )
2444 like in the above example can be useful
2445 to see the memory requirements
2446 of the compressor and decompressor.
2447 Remember that using a dictionary bigger than
2448 the size of the uncompressed file is waste of memory,
2449 so the above command isn't useful for small files.
2451 Sometimes the compression time doesn't matter,
2452 but the decompressor memory usage has to be kept low
2453 e.g. to make it possible to decompress the file on
2455 The following command uses
2457 .RB ( "\-6 \-\-extreme" )
2458 as a base and sets the dictionary to only 64\ KiB.
2459 The resulting file can be decompressed with XZ Embedded
2460 (that's why there is
2461 .BR \-\-check=crc32 )
2462 using about 100\ KiB of memory.
2467 xz \-\-check=crc32 \-\-lzma2=preset=6e,dict=64KiB foo
2472 If you want to squeeze out as many bytes as possible,
2473 adjusting the number of literal context bits
2475 and number of position bits
2478 Adjusting the number of literal position bits
2480 might help too, but usually
2485 E.g. a source code archive contains mostly US-ASCII text,
2486 so something like the following might give
2487 slightly (like 0.1\ %) smaller file than
2495 xz \-\-lzma2=preset=6e,pb=0,lc=4 source_code.tar
2500 Using another filter together with LZMA2 can improve
2501 compression with certain file types.
2502 E.g. to compress a x86-32 or x86-64 shared library
2503 using the x86 BCJ filter:
2508 xz \-\-x86 \-\-lzma2 libfoo.so
2513 Note that the order of the filter options is significant.
2520 because there cannot be any filter after LZMA2,
2521 and also because the x86 BCJ filter cannot be used
2522 as the last filter in the chain.
2524 The Delta filter together with LZMA2
2525 can give good results with bitmap images.
2526 It should usually beat PNG,
2527 which has a few more advanced filters than simple
2528 delta but uses Deflate for the actual compression.
2530 The image has to be saved in uncompressed format,
2531 e.g. as uncompressed TIFF.
2532 The distance parameter of the Delta filter is set
2533 to match the number of bytes per pixel in the image.
2534 E.g. 24-bit RGB bitmap needs
2536 and it is also good to pass
2538 to LZMA2 to accommodate the three-byte alignment:
2543 xz \-\-delta=dist=3 \-\-lzma2=pb=0 foo.tiff
2548 If multiple images have been put into a single archive (e.g.\&
2550 the Delta filter will work on that too as long as all images
2551 have the same number of bytes per pixel.
2563 XZ Utils: <http://tukaani.org/xz/>
2565 XZ Embedded: <http://tukaani.org/xz/embedded.html>
2567 LZMA SDK: <http://7-zip.org/sdk.html>