lha(1)
π lha(1) β the .lzh compression tool, bestie edition π
okay so first things first: this is the manual for lha, and yeah it lives in section 1 (General Commands Manual) of your man pages, iykyk. Buckle up, because this one is a whole journey and I'm gonna hold your hand through every single bit of it. π«Ά
β¨ NAME β¨
lha β a compression tool for .lzh archive files. that's the whole vibe, that's the job. π
β¨ SYNOPSIS β¨
lha [-]{lvtxep[q{num}][finv]}[w=<dir>] archive_file [file ...]
yes it's giving cryptic. yes we're gonna break it down. no you're not allowed to just copy-paste it and hope for the best, bestie. π
β¨ DESCRIPTION β¨
so lha is the tool you reach for when you need to extract .lzh archive files. and listen, it's not just the plain .lzh β it also handles variants of the .lzh archive format, like .lzs and .pma. so it's versatile, it's flexible, it's serving range. π
this particular version of the lha tool is part of Lhasa, which is a free implementation of the .lzh format. so like, free as in freedom, free as in you don't have to pay, free as in iconic. π
β¨ COMMAND SYNTAX β¨
ngl, the lha tool has a genuinely unusual command syntax compared to most other Unix commands. it does its own thing. main character energy. π¦
here's how it works:
- the first parameter to the program specifies the command to perform and all the additional options. yes, all of them. crammed in there together.
- the second parameter specifies the path to the archive file you want to operate on.
- after that comes a list of wildcard patterns to match against the filenames of the archived files.
and here's the key detail: the first character of that command parameter is what actually picks the command to perform. it's one of these:
-lβ list contents of the specified archive.-vβ verbosely list contents of the specified archive.-tβ test the integrity of the specified archive: decompress its contents and check the CRC.-eor-xβ extract archive. files get extracted to the current working directory unless thewoption is specified.-pβ extract archive, but send the decompressed files to stdout instead of writing them to the filesystem as actual files. this is the one you want when you're piping into something else in a shell pipeline. she's useful, she's underrated. π₯
β¨ OPTIONS β¨
the remainder of the command parameter is where you specify additional options. so everything after that first command character. let's go through them one by one, no skipping, no shortcuts: π
q[012]β quiet mode. higher numbers suppress more output. level0is normal operation. if you don't specify a number, full suppression (level2) is what you get. oh and heads up: the quiet option also turns on the force overwrite option (f). so it's doing two things at once, multitasking queen. πfβ force overwrite of existing files: do not prompt.iβ ignore paths of archived files: extract all archived files to the same directory, ignoring subdirectories. flattening the whole thing out.nβ do not perform any actual operations: instead, do a dry run of the requested operation and describe what would have been done on standard output. a little preview, a little dress rehearsal. πvβ verbose mode: causes extra information to be written to standard output.w=dirβ specify the destination directory for extracting files. β οΈ important: this must be the last option of the first parameter. no exceptions, she has to go last.
β¨ LIST OUTPUT FORMAT β¨
Lhasa inherits its list output format from the original Unix port of lha, and it retains the exact same format for compatibility, because some tools out there literally parse the output. so we can't just change it, it's legacy, it's iconic, it stays. π
four different output formats are supported, and which one you get depends on the command line arguments:
lha -l filename.lzhβ shows: Unix permissions / OS type, UID/GID, uncompressed size, compression ratio, modification time, filename.lha -lv filename.lzhβ two line output. first line shows the filename, second line shows: Unix permissions / OS type, UID/GID, uncompressed size, compression ratio, modification time, filename, header level.lha -v filename.lzhβ shows: Unix permissions / OS type, UID/GID, compressed size, uncompressed size, compression ratio, compression format, checksum, modification time, filename.lha -vv filename.lzhβ two line output. first line shows the filename, second line shows: Unix permissions / OS type, UID/GID, compressed size, uncompressed size, compression ratio, compression format, checksum, long form modification time, header level.
πΈ what each of those fields actually means πΈ
detailed descriptions, coming right up. every single field, explained:
- Unix permissions / OS type (PERMSSN) β for files compressed on a Unix system, this lists the permissions in the same format that
ls(1)uses when it's invoked with the-loption. if the file was not created on a Unix system, the OS type is instead displayed in square brackets. examples are"[MS-DOS]"and"[MacOS]"; the OS name never contains a space. and if the file was created on Microware OS-9, the permissions for that system will also be shown. - Unix user ID / group IDs (UID/GID) β for files compressed on a Unix system, this lists the user and group IDs of the file, similar to the output you'd see from
ls(1)when it's invoked with the-lnoption. if the file was not created on a Unix system,"*****/*****"is shown; see LIST FORMAT DIFFERENCES below. π - Compressed size (PACKED) β size of the file in bytes as it's stored inside the archive (not including the header, which contains metadata about the file). if an uncompressed format like
-lh0-is used, this will be equal toSIZE. - Uncompressed size (SIZE) β size of the file in bytes before it was compressed.
- File compression ratio (RATIO) β compressed size as a percentage of uncompressed size. this measures the effectiveness of the compression format; the smaller the percentage, the better. the value is (pessimistically) rounded up to the next 0.1%. if an uncompressed format like
-lh0-is used, this will be equal to 100%. for directories,"******"is shown. and ngl, note that the value here is backwards relative tounzip(1), which instead shows the percentage of the original file size reduced. so don't get it twisted. π - Compression format (METHOD) β the compression format used to store this file. see the COMPRESSION FORMATS section below.
- Checksum (CRC) β CRC16 checksum of the file's contents in hexadecimal format. > β οΈ warning: while this is useful for casually checking file integrity, it's only a 16-bit checksum and should not be considered reliable for protecting files larger than a few kilobytes. so like, cute for a vibe check, not for actual security. π¨
- Modification time (STAMP) β date and time that the file was last modified before it was stored in the archive. if the file doesn't have a timestamp stored, nothing is shown. the output can be in one of two forms: if the date is within the past six months, the month, day and time are shown; an example is
"Aug 24 12:38". for older files, the month, day and year are shown; an example is"Aug 24 2020". - Long form modification time (STAMP) β this is only used when listing in the
-vvformat. the full date and timestamp are listed in numeric form, close to ISO 8601 format (though not quite conformant with that standard). an example is"2020-08-24 12:38:25". β¨ - Header level (LV) β the Lha header format used to store this file. supported formats are
0-3.
β¨ LIST FORMAT DIFFERENCES β¨
okay so the list mode output from the original Unix lha tool was not designed to be machine-readable. it just wasn't the goal. but since some tools do try to parse the list output anyway, Lhasa's list output has been deliberately tweaked slightly to make the output more consistent and easier to parse. a little glow-up, for the parser girlies. π
here are the main differences:
- If a file was not created on a Unix system, a spacer word is shown in the UID/GID column. the original
lhajust showed whitespace. - The OS type for archives generated by MacLHA is listed as
"MacOS"(no space). the originallhashowed"Mac OS".
β οΈ note that in general, the approach of parsing text output is inherently fragile and prone to bugs. it's recommended that you instead use the proper API (liblhasa). fr fr, use the API. π«Ά
β¨ COMPRESSION FORMATS β¨
here's the tea on the various different supported compression formats (as listed when using the list command documented above). and a fun fact: all formats are variants on the LZSS compression algorithm. every single one. family reunion. π
-lz4-β uncompressed (stored) data, as used by the original LArc tool. this is not related to the LZ4 compression algorithm of the same name. don't confuse them, they're strangers with the same name. π-lz5-,-lzs-β compression formats introduced with the original LArc tool.-lzs-uses a 2KiB sliding window while-lz5-uses a 4KiB window.-lhd-β directory entry. no data is stored, only headers.-lh0-β uncompressed (stored) data, as used in LHarc and LHa.-lh1-β compression algorithm introduced with LHarc. this uses a 4KiB sliding window with dynamic Huffman encoding.-lh4-,-lh5-,-lh6-,-lh7-β new algorithm introduced with LHa (aka LHarc v2.0). the original versions (-lh4-and-lh5-) used 8KiB and 16KiB sliding window sizes, respectively. later versions introduced new variants with larger window sizes:-lh6-(64KiB) and-lh7-(128KiB). they grow up so fast. π¦-lhx-β variant on the-lh4-format listed above introduced byUNLHA32.dllthat extends the window size to 1MiB.-lk7-β variant on the-lh4-format listed above that was introduced by the LHark tool (a fork of LHa). this is actually named-lh7-within the archive files, but Lhasa renames it internally to avoid clashing with the other algorithm of the same name. uses a 128KiB sliding window, with some minor improvement to the algorithm. sneaky little name swap, we love a workaround. π-pm0-β uncompressed (stored) data, as used by the PMarc tool.-pm1-β algorithm used by version 1 of the PMarc tool.-pm2-β algorithm used by version 2 of the PMarc tool.
β¨ UNSUPPORTED FORMATS β¨
and now for the ones that Lhasa does not currently support (but possibly will be in the future, fingers crossed π€):
-lh2-,-lh3-β these formats can be decompressed by LHa v2.0 but the tool could not actually generate archives with these formats; they appear to have only been supported in beta versions before the v2.0 release. as a result, few if any examples exist in the wild. rare specimens, basically. π-lh8-,-lh9-,-lha-,-lhb-,-lhc-,-lhe-β extensions of the-lh4-format to even larger window sizes.-ll0-,-ll1-β generated by ThunderSoft's PAKLEO utility (.pll).-sw0-,-sw1-β used in SourceWare Archival Group's.swg(SWAG packet) format.-lz6-,-LD6-β generated by LDarc and LDIFF (.lzd).-hf0-,-ah0-,-ari-,-arn-,-arw-β generated by the Micrognosis Compression Archiver utility.-pc1-β format generated by the PopCom! compression utility for CP/M.
if you encounter examples of these in the wild, please get in touch. seriously, they wanna hear about it. π
β¨ EXAMPLES β¨
here are some examples for how to invoke the program. copy, paste, thrive:
lha -v foobar.lzsβ list the contents of the filefoobar.lzs(producing verbose output).lha -xf foobar.exeβ extract the contents of a self-extracting archive file namedfoobar.exeto the current directory, overwriting existing files with the same names if they exist.lha -xqw=/tmp foobar.lzhβ extract the contents offoobar.lzhto/tmp, overwriting any existing files found there, and suppressing normal output (similar to how other Unix tools such ascp(1)ortar(1)act silently by default).
β¨ WWW β¨
https://lhasa.soulsphere.org/ π
π BUG REPORTS π
okay so if you found a bug (and bestie, you will, that's just software π) you don't email anybody, you go straight to the GitHub issue tracker:
that's the spot. drop it there. the maintainer will see it, the internet will see it, we all grow. β¨
π SEE ALSO π
if lha isn't giving what you need, these besties are right there:
go forth and decompress, babe π«Ά
π HISTORY π (yes it's giving lore, sit down)
so the .lzh format did not come from nowhere, it has a whole ancestry and honestly it's kind of iconic.
It all started with Kazuhiko Miki's MS-DOS archive tool, LArc, which used the LZSS algorithm developed by Haruhiko Okumura, and it used the .lzs filename extension.
Then the container format got reused for LHarc, by Haruyasu Yoshizaki (aka Yoshi), which brought a brand new algorithm named LZHUF and the .lzh extension. yes, a glow-up era πΈ
In later versions, LHarc got renamed to LHA and extended with more effective compression algorithms. she kept evolving. main character behavior fr fr π
Versions of the LHA tool were later ported to various different operating systems, including the Amiga, Atari, MacOS, OS/2 and Unix. global domination honestly.
A tool for MSX-DOS named PMarc reused the container format with a new compression algorithm (.pma extension). not me knowing that. iykyk.
The Unix version of the tool was developed by Masaru Oki, Nobutaka Watazaki and Tsugio Okamoto, but β and this is the messy part β it was released under a software license that does not conform to the Free Software or Open Source Definitions. π
Lhasa was developed as a drop-in replacement that is Free Software and Open Source. slay. that's the whole reason we're here bestie π
And the name "LHA" plus the .lzh filename extension? They're a reference to the compression algorithm itself: a combination of LempelβZivβStorerβSzymanski dictionary coding and Huffman encoding. Similar schemes are used in other compression algorithms such as Deflate (which is what's used in gzip/zlib, PNG image files, and the .zip format). so basically they were all in the same friend group. β¨
π BUGS π
okay real talk, here's what it can't do yet:
- The current version does not allow the creation of new archive files. you can look, you can extract, but you cannot make. not yet. π
- Some obscure compression algorithms are not currently supported (peep the UNSUPPORTED FORMATS section above, it's all listed there).
- The tool does not currently do text format conversion for non-ASCII filenames when listing the contents of archives. Non-ASCII characters are replaced by a question mark. so if your filename was giving πΈ, it's giving
?now. tragic but true.
βοΈ AUTHOR βοΈ
Lhasa was written and is maintained by Simon Howard. one person. carrying all of this. respect. π«‘
Β©οΈ COPYRIGHT Β©οΈ
so here's the legal bit, and I'm quoting it exactly because legal text is not the vibe to freestyle:
Copyright Β© 2011-2025 Simon Howard.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
so yeah β free to use, no promises, don't sue. the standard deal. π
okay bestie that's the whole page, you made it to the end π and the very last line of the original is just the little footer tag that says this is the lha(1) manual page β source and version and date all bundled up in that one tidy tag, like a signature at the bottom of a letter. so consider this signed, sealed, and slayed. go extract something. ππ
π¦ where this page comes from
- ubuntu resolute: lhasa 0.5.0-1
- ubuntu stonking: lhasa 0.5.0-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms