p7zip
Compress/decompress 7z archives
TLDR
Archive a file, replacing it with a 7zipped compressed version
Archive a file keeping the input file
Decompress a file, replacing it with the original uncompressed version
Decompress a file keeping the input file
Skip some checks and force compression or decompression
SYNOPSIS
7z [command] [options]
PARAMETERS
a
Add files to an archive.
x
Extract files with full paths.
e
Extract files to the current directory (without paths).
l
List contents of an archive.
d
Delete files from an archive.
t
Test integrity of an archive.
u
Update files in an archive.
b
Benchmark the system's compression/decompression performance.
-o
Specify output directory for extracted files.
-p
Set a password for archive creation or extraction.
-m
Set compression method (e.g., -mlzma2, -mdeflate).
-mx
Set compression level (0-9, x0=no, x1=fastest, x9=ultra).
-t
Set archive type (e.g., -t7z, -tzip, -ttar).
-r
Recurse subdirectories when processing files.
-v
Create multivolume archives (e.g., -v1g for 1 GB volumes).
-y
Assume 'yes' to all queries (non-interactive).
DESCRIPTION
p7zip is the Unix/Linux port of the popular 7-Zip archive program, renowned for its exceptionally high compression ratio, especially with its native .7z format. It provides a command-line utility, typically invoked as 7z, 7za, or 7zr, allowing users to create, extract, update, and manage archives.
Unlike many traditional Unix archivers, p7zip supports a wide array of archive formats, including ZIP, GZIP, BZIP2, TAR, and more, in addition to its highly efficient 7z format. Its primary strength lies in its advanced compression algorithms, such as LZMA and LZMA2, which can significantly reduce file sizes, making it ideal for backups, distribution, and saving disk space. It's a versatile tool for both simple archival tasks and complex data management.
CAVEATS
While p7zip offers excellent compression, high compression levels (e.g., -mx=9) can be very CPU and RAM intensive, leading to longer processing times. Compatibility with certain obscure or proprietary archive formats may vary. Always ensure you have sufficient disk space, especially when extracting large archives, as the original compressed size can be misleading.
SUPPORTED FORMATS
p7zip supports a vast range of archive formats for both compression and decompression. For compression, it typically supports 7z, XZ, BZIP2, GZIP, TAR, ZIP. For decompression, it extends to ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, RAR, RPM, SquashFS, UDF, VHD, WIM, XAR, Z, and many others. This broad support makes it an incredibly versatile tool for handling almost any archive encountered on a Linux system.
DEFAULT COMPRESSION
When creating a .7z archive, p7zip uses the LZMA2 compression method by default. This method is highly optimized for performance and compression ratio, offering a good balance for most use cases without requiring explicit configuration of compression parameters.
HISTORY
p7zip is the official port of Igor Pavlov's 7-Zip archiver to POSIX-compliant operating systems like Unix, Linux, and macOS. The original 7-Zip project began in 1999 for Windows. p7zip provides the same powerful compression algorithms, notably LZMA and LZMA2, to a command-line interface suitable for scripting and server environments. It was developed to bring the benefits of 7-Zip's high compression and broad format support to the wider open-source community, maintaining feature parity where possible with its Windows counterpart.