7z(1)
Create, extract, and manage 7z archives with high compression ratios.
Synopsis
7z <command> [<switches>] <archive_name> [<file_names>...]Description
7z is a file archiver with a high compression ratio, supporting the 7z format and many others including zip, tar, gzip, bzip2, and xz. It uses the LZMA/LZMA2 compression algorithm which often achieves better compression than traditional tools.
Commands specify the action (a=add, x=extract, l=list, d=delete, t=test), while switches control compression level, output format, and other behaviors. The 7z format stores directory structures, file attributes, and can span multiple volumes.
Common options
| Flag | What it does |
|---|---|
a | Add files to archive |
x | Extract files from archive with full paths |
e | Extract files to current directory (ignore paths) |
l | List contents of archive |
-mx=9 | Set compression level (0=store, 9=ultra; default 5) |
-mmt=on | Enable multi-threaded compression |
-p | Set password for encryption |
-v | Create multi-volume archive (specify size, e.g., 700m) |
-t | Test archive integrity |
-r | Recurse into directories |
-ao | Overwrite mode (a=ask, s=skip, t=overwrite) |
Examples
Create a new 7z archive containing a file and directory
7z a archive.7z myfile.txt documents/Extract all files from archive preserving directory structure
7z x archive.7zExtract archive to a specific output directory
7z x archive.7z -o/home/user/targetList all files in archive with sizes and compression details
7z l archive.7zCreate ultra-compressed archive using all CPU threads
7z a -mx=9 -mmt=on backup.7z /home/user/Documents/Create password-protected 7z archive
7z a -p mypassword secure.7z important.txtTest archive integrity and report any errors
7z t archive.7zExtract first volume of multi-volume archive
7z x large.7z.001