LinuxCommandLibrary

7zr

Create and extract 7z archives

TLDR

[a]rchive a file or directory

$ 7zr a [path/to/archive.7z] [path/to/file_or_directory]
copy

Encrypt an existing archive (including file names)
$ 7zr a [path/to/encrypted.7z] -p[password] -mhe=[on] [path/to/archive.7z]
copy

E[x]tract an archive preserving the original directory structure
$ 7zr x [path/to/archive.7z]
copy

E[x]tract an archive to a specific directory
$ 7zr x [path/to/archive.7z] -o[path/to/output]
copy

E[x]tract an archive to stdout
$ 7zr x [path/to/archive.7z] -so
copy

[l]ist the contents of an archive
$ 7zr l [path/to/archive.7z]
copy

Set the level of compression (higher means more compression, but slower)
$ 7zr a [path/to/archive.7z] -mx=[0|1|3|5|7|9] [path/to/file_or_directory]
copy

SYNOPSIS

7zr [global-switches...] <command> [switches...] [<archive>...] [<files>...] [-si[name]]

PARAMETERS

a
    Add files to archive

b
    Benchmark

d
    Delete files from archive

e
    Extract files (no paths)

h
    Calculate hash sums

i
    Show format info

l
    List archive contents

rn
    Rename files in archive

r
    Repair archive

t
    Test archive integrity

u
    Update archive

x
    Extract with full paths

-t{Type}
    Set archive type (7z, zip, etc.)

-mx[N]
    Set compression level 0-9 (default 5)

-mfb{N}
    Set number of fast bytes

-mmt[N]
    Set number of CPU threads

-p{Password}
    Set password

-o{Directory}
    Set output directory

-y
    Assume Yes to all queries

-v{Size}[b|k|m|g]
    Create volumes of specified size

-slt
    List technical info

-ssc[-]
    Enable/disable case-sensitive

-slc
    Convert LF to CRLF

DESCRIPTION

7zr is the standalone command-line version of 7-Zip, a high-performance file archiver with an extremely high compression ratio. It supports packing and unpacking multiple formats including 7z (LZMA), XZ, GZIP, BZIP2, TAR, and ZIP. On Linux, it's provided by the p7zip package.

Key features include strong AES-256 encryption, solid compression for better ratios, multithreading for speed, and support for large files (over 4GB). Use it to create, extract, list, test, update, or repair archives. It's ideal for scripts and automation due to its robust options.

Unlike full 7z, 7zr focuses solely on the 7z format but handles others for extraction. It's lightweight, efficient for servers, and widely used for data backups, distribution, and handling compressed files in Unix environments.

CAVEATS

p7zip (including 7zr) is discontinued; use 7zz or 7z from official 7-Zip for modern support.
High memory usage with large files or high compression.
Not all GUI features available.

COMMON EXAMPLES

7zr a archive.7z file.txt - Create archive.
7zr x archive.7z - Extract.
7zr l archive.7z - List contents.
7zr t archive.7z - Test.

SUPPORTED FORMATS

Pack: 7z, XZ, GZIP, BZIP2, TAR, ZIP.
Unpack: additionally WIM, ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, RAR*, SquashFS, UDF, VHD, VMDK, XAR, Z.

HISTORY

Developed by Igor Pavlov as part of 7-Zip (1999). p7zip port for POSIX/Linux by Mohamed Aly Serag (2004-2016). Widely used in distros via p7zip-full; succeeded by official 7-Zip ports.

SEE ALSO

7z(1), unzip(1), zip(1), tar(1), xz(1), gzip(1)

Copied to clipboard