Skip to content

7-Zip (p7zip)

Creates and extracts 7z, with the best general-purpose compression ratio available.

Homebrew formula

What it does

7z implements the 7z format — LZMA/LZMA2 compression, solid archives, AES-256 encryption including encrypted headers — and reads most other formats too.

7z a archive.7z folder/              # create
7z a -mx=9 -mhe=on -p archive.7z f/  # max compression, encrypted headers, password
7z x archive.7z                      # extract preserving paths
7z l archive.7z                      # list contents
7z t archive.7z                      # test integrity

Notes

-mhe=on encrypts the file list as well as the contents; without it an encrypted archive still reveals every filename inside. -mx=9 is slow and memory-hungry, but the ratio difference on source code and text is substantial.

The p7zip formula is the POSIX port; Homebrew also carries sevenzip, the official upstream build.

Alternative to

AlternativeTypeTrade-off
sevenzipOpen sourceThe official upstream 7-Zip build, also in Homebrew, and better maintained
KekaOpen sourceThe same formats with a GUI
zstdOpen sourceMuch faster for everyday compression, if the recipient has it
tar plus xzBuilt inUniversally available on Unix

Install

brew install p7zip

Links

This post is licensed under CC BY 4.0 by the author.
Last updated on