Compression

7z

High-compression file archiver supporting 7z, ZIP, GZIP, BZIP2, TAR, and more.

Synopsis

syntax
7z [COMMAND] [OPTION]... ARCHIVE [FILE]...

Examples

Create 7z archive
7z a archive.7z dir/
Extract archive with directory structure
7z x archive.7z
List archive contents
7z l archive.7z
Maximum compression with password
7z a -mx=9 -p backup.7z data/

Common options

FlagDescription
aAdd files to archive
xExtract with full paths
lList archive contents
-pSet password
-mxCompression level (0-9)

About 7z

The `7z` command high-compression file archiver supporting 7z, ZIP, GZIP, BZIP2, TAR, and more. Compression commands reduce file sizes for storage and transfer.

Linux supports multiple compression formats, each with different speed and ratio trade-offs. Understanding these tools is essential for working with archives, backups, log rotation, and software distribution packages.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man 7z`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Compression Commands

Other commands in the Compression category

Related tools