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 <command> [<switches>...] <archive_name> [<file_names>... [<@listfiles>...]]

PARAMETERS

a
    Add (compress) files to an archive.
Usage: 7zr a archive.7z files...

e
    Extract files from an archive to the current directory, without full path names.

x
    Extract files from an archive with full path names, preserving the directory structure.

l
    List the contents of an archive.

t
    Test the integrity of an archive.

d
    Delete files from an archive.

u
    Update files in an archive (add new files, replace older files).

-o{Directory}
    Set the output directory for extracted files.
Example: -o/tmp/extracted

-p{Password}
    Set the password for encryption/decryption.
Example: -pMySecurePass

-r[-[0|1]]
    Recurse subdirectories when adding files. -r for all, -r0 for no recursion, -r1 for only explicitly included ones.

-m{Method}
    Set the compression method (e.g., LZMA2, Deflate, BZip2).
Example: -m0=lzma2

-mx={level}
    Set the compression level (0-9). -mx=0 for no compression, -mx=9 for ultra compression.
Example: -mx=7

-sfx[{name}]
    Create a self-extracting archive. Optionally specify the module name.

-t{Type}
    Set the type of archive (e.g., 7z, zip, tar, gzip, xz).
Example: -tzip

-v{Size}[b|k|m|g]
    Create multi-volume archives. Specify volume size (bytes, kilobytes, megabytes, gigabytes).
Example: -v100m

-y
    Assume Yes on all queries (non-interactive mode).

-ao{a|s|t|u}
    Set overwrite mode for extraction: a (All), s (Skip), t (auto-rename Target), u (auto-rename existing).

DESCRIPTION

7zr is a robust command-line utility for Linux/Unix systems, serving as a standalone version of the renowned 7-Zip file archiver. It is primarily known for its exceptionally high compression ratio, especially with its native .7z format. Beyond 7z, it supports a multitude of other archive formats for both compression and extraction, including ZIP, GZIP, BZIP2, TAR, XZ, and many more. It provides features like strong AES-256 encryption, the ability to create self-extracting archives (SFX), and support for multi-volume archives. While often similar to the more general 7z command, 7zr is sometimes a more focused or statically linked variant, emphasizing portability and core 7z functionality, making it a staple for efficient data management in server environments and scripts.

CAVEATS

While 7zr is highly capable, it is generally a command-line-only tool, which can present a steep learning curve for users unfamiliar with CLI archiving tools. The distinction between 7zr and 7z can be subtle; 7zr is often a specific build focusing on the .7z format and may lack support for some proprietary formats (like RAR) that 7z might offer, depending on compilation options. High compression levels can be very CPU and memory intensive, impacting performance on less powerful systems.

KEY FEATURES

  • Superior compression ratio using LZMA2 and LZMA algorithms.
  • Strong AES-256 encryption.
  • Ability to create self-extracting archives (SFX).
  • Support for creating and extracting a wide range of archive formats beyond .7z.
  • Efficient handling of very large files.

SUPPORTED FORMATS

7zr supports: 7z, XZ, GZIP, BZIP2, TAR, ZIP, WIM. It can also extract from: AR, CPIO, RPM, DEB, ISO, LZH, LZMA, NSIS, RAR, Z, CAB, CHM, MSI, HFS, MBR, NTFS, SquashFS, CramFS, UDF, VHD, VMDK.

HISTORY

7zr is part of the p7zip project, which is the official port of Igor Pavlov's 7-Zip archiver to POSIX systems like Linux. 7-Zip itself began development in 1999. The 7zr executable specifically is often a streamlined or statically linked version within the p7zip distribution, designed to be more portable or to provide core 7z functionality with minimal dependencies. Its development mirrors the ongoing enhancements of the main 7-Zip project, bringing its industry-leading compression ratios and robust feature set to the Linux command line.

SEE ALSO

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

Copied to clipboard