7z
37c3317fd058; modified for Encode Wiki · CC BY-SA 4.07z is the native format of 7-Zip, Igor Pavlov’s open-source archiver. It uses LZMA2 (the algorithm behind xz) with large dictionaries, and by default compresses all files together as one solid block, so similar files share context. For collections of many similar files, it is typically the smallest common archive format, well ahead of ZIP. It also does AES-256 encryption (including file names) and applies filters that help executables and some binary data.
7-Zip is also a general archive reader: it opens ZIP, tar, gz, xz, bz2, RAR, ISO, WIM, disk images and many others, and since 24.01 it can unpack .zst files.
Install
Section titled “Install”On Windows use the 7-Zip installer. On Linux, use your distribution’s 7zip package or the official 7zz build from 7-zip.org; the old p7zip is unmaintained. The command is 7z or 7zz.
Common commands
Section titled “Common commands”7z a archive.7z dir/ # create (LZMA2, level 5)7z a -mx=9 archive.7z dir/ # maximum compression7z a -mx=9 -md=256m archive.7z dir/ # bigger dictionary7z x archive.7z -oout/ # extract with paths into out/7z l archive.7z # list7z t archive.7z # test7z a -p -mhe=on secret.7z dir/ # AES-256, encrypt file names too (prompts for password)The options that matter:
| Switch | Effect |
|---|---|
-mx=0…9 | Level; default 5. 9 is “ultra” |
-md=Nm | LZMA2 dictionary size; bigger finds more repeats but needs that much RAM to compress and extract |
-ms=on | Solid archive (default); -ms=off allows fast extraction of single files at a worse ratio |
-mmt=N | Thread count; all cores by default |
-mhe=on | Encrypt file names as well as data (needs a password) |
-t7z, -tzip, -txz, -tbzip2, -tgzip | Output format |
Use -bso0 -bsp0 to silence output in scripts.
Pitfalls
Section titled “Pitfalls”- Solid archives are slow to extract from. Pulling one file out of a solid 7z means decoding everything before it in the same block. Use
-ms=offor smaller solid blocks (-ms=100m) when you need random access. - Not for Unix backups. 7z does not preserve Unix owner/group, ACLs or extended attributes, so use tar with xz or zstd for system backups and preserve permissions.
- No recovery data. A damaged 7z can often be partly extracted, but there is no built-in repair; keep a second copy or use PAR2.
- Compatibility: not built into macOS or most Linux file managers without a 7-Zip/p7zip install. Choose ZIP for strangers.
- Large dictionaries require the same memory on extraction;
-md=1536marchives can fail on small devices.