$linuxjunkies
>

7z(1)

Create, extract, and manage 7z archives with high compression ratios.

UbuntuDebianFedoraArch

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

FlagWhat it does
aAdd files to archive
xExtract files from archive with full paths
eExtract files to current directory (ignore paths)
lList contents of archive
-mx=9Set compression level (0=store, 9=ultra; default 5)
-mmt=onEnable multi-threaded compression
-pSet password for encryption
-vCreate multi-volume archive (specify size, e.g., 700m)
-tTest archive integrity
-rRecurse into directories
-aoOverwrite 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.7z

Extract archive to a specific output directory

7z x archive.7z -o/home/user/target

List all files in archive with sizes and compression details

7z l archive.7z

Create 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.txt

Test archive integrity and report any errors

7z t archive.7z

Extract first volume of multi-volume archive

7z x large.7z.001

Related commands