LZMA(1)

πŸ“¦
version 25.00 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– LZMA(1) β€” the manual page, but make it make sense πŸ’–

okay bestie, gather round, because this is the lzma, unlzma and lzcat situation and it's lowkey iconic. this is section 1 of the general commands manual, so it's a real tool you type at a real terminal. let's go 🫢


✨ NAME ✨

lzma, unlzma, lzcat β€” the LZMA compression and decompression tool. three names, one queen πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

lzma [-123456789cdefhkLqtvV] [-S suffix] [filenames ...]
unlzma [-cfhkLqtvV] [-S suffix] [filenames ...]
lzcat [-fhLqV] [filenames ...]

that's it. that's the whole vibe. ✨


🌸 DESCRIPTION 🌸

LZMA stands for Lempel-Ziv-Markov chain-Algorithm, and it's basically a glow-up of the famous LZ77 compression algorithm. the way they improved it? maxing out the compression ratio as hard as possible while still keeping decompression speedy and memory requirements for decompressing nice and low. main character energy fr πŸ’…

the lzma command line tool has an interface that's super similar to gzip(1) and bzip2(1), and the whole point is to make using LZMA compression easy for anyone who's already comfy with gzip and bzip2. iykyk.

in this manual, lzma gets compared mostly to bzip2, because bzip2 is currently one of the most widely used free software tools for compressing tar files made for distribution. comparing lzma to gzip just isn't it β€” neither lzma nor bzip2 can compete with gzip when it comes to compression speed. but on the flip side, gzip's compression ratio is worse than lzma's and bzip2's. trade-offs, bestie 😭

lzma gives you notably better compression ratio than bzip2, especially with files that have content other than plain text. and the other flex? lzma decompresses fast β€” many times quicker than bzip2. the major L though: getting the highest compression ratios eats an extensive amount of system resources, both CPU time and RAM. also, software to handle LZMA compressed files isn't installed by default on most distributions, so like... good luck out there πŸ™ˆ

when you compress or decompress with lzma, the new file gets the same ownership information, permissions and timestamps as the original file. but heads up: this information is not stored into the compressed file the way gzip does it.


πŸ¦‹ STREAMED VS. NON-STREAMED πŸ¦‹

LZMA files can be either streamed or non-streamed, and this is the lore you need.

Non-streamed files are only created when the size of the file being compressed is known. in practice that means the source file must be a regular file. in other words: if you're compressing from the standard input or from a named pipe (fifo), the compressed file will always be streamed. periodt.

both streamed and non-streamed files are compressed identically β€” the only differences live at the beginnings and ends of LZMA compressed files:

  • Non-streamed files contain the uncompressed size of the file in the LZMA file header.
  • Streamed files have the uncompressed size marked as unknown.

and to know where to stop decoding, streamed files have a special End Of Stream marker at the end of the LZMA file. that EOS marker makes streamed files five or six bytes bigger than non-streamed ones. tiny but real πŸ’€

so in practice, creating non-streamed files has two advantages:

  1. the compressed file is a few bytes smaller, and
  2. the uncompressed size of the file can be checked without decompressing the file.

πŸ’œ OPTIONS πŸ’œ

short options can be grouped like -cd. cute, right? πŸŽ€

  • -c, --stdout, --to-stdout β€” the output is written to the standard output. the original files are kept unchanged. when compressing to the standard output there can be only one input file. this option is implied when input is read from the standard input or the script is invoked as lzcat. the suffix is not considered in this mode.
  • -d, --decompress, --uncompress β€” force decompression regardless of the invocation name. this is the default when called as unlzma or lzcat.
  • -f, --force β€” force compression or decompression even if the source file is a symlink, the target exists, or the target is a terminal. in contrast to gzip and bzip2, if the input data is not in LZMA format, --force does not make lzma behave like cat. and lzma never prompts about whether the target file should be overwritten; existing files are skipped or, in the case of --force, overwritten. no takebacks πŸ’…
  • -h, --help β€” show a summary of supported options and quit.
  • -k, --keep β€” do not delete the input files after compression or decompression.
  • -L, --license β€” show licensing information of lzma.
  • -q, --quiet β€” suppress all warnings. you can still check the exit status to detect if a warning had been shown.
  • -S, --suffix .suf β€” use .suf instead of the default .lzma. a null suffix forces unlzma to decompress all the given files regardless of the filename suffix.
  • -t, --test β€” check the integrity of the compressed file(s). without --verbose, no output is produced if no errors are found.
  • -v, --verbose β€” show the filename and percentage reduction of each processed file.
  • -V, --version β€” show the version number of lzma.
  • -z, --compress β€” force compression regardless of the invocation name.
  • -1 .. -9 β€” set the compression ratio. these options have no effect when decompressing.
  • --fast β€” alias to -1.
  • --best β€” alias to -9.

😭 DIAGNOSTICS 😭

exit status, bestie, memorize these:

  • 0 β€” everything OK. slay. ✨
  • 1 β€” an error occurred. πŸ’€
  • 2 β€” something worth a warning happened but no errors.

it can be especially useful with tar(1) patched to support LZMA compression. πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

the LZMA algorithm and the implementation used in LZMA utils was developed by Igor Pavlov. the original code is available in LZMA SDK, which can be found from http://7-zip.org/sdk.html .

the lzma command line tool was written by Ville Koskinen. http://tukaani.org/lzma/

this manual page is inspired by the manual pages of gzip and bzip2. respect the ancestors 🫢


🌈 SEE ALSO 🌈

gzip(1), bzip2(1)


and that's the whole page, no notes πŸ’– this was LZMA utils, dated 23 Dec 2005 β€” yeah, she's vintage, she's still serving, and she's still called LZMA(1). bye bestie, go compress something πŸŽ€βœ¨

πŸ“¦ where this page comes from