7z
Compress or extract archives
TLDR
[a]dd a file or directory to a new or existing archive
Encrypt an existing archive (including filenames)
E[x]tract an archive preserving the original directory structure
E[x]tract an archive to a specific directory
E[x]tract an archive to stdout
[a]rchive using a specific archive type
[l]ist the contents of an archive
Set the level of compression (higher means more compression, but slower)
SYNOPSIS
7z [command] [switches...] archive_name [file_names...]
PARAMETERS
a
Add files to archive.
d
Delete files from archive.
e
Extract files from archive (with full paths).
l
List contents of archive.
t
Test integrity of archive.
u
Update files to archive.
x
Extract files from archive (without full paths).
-ppassword
Set password for archive.
-r
Recursive; process subdirectories.
-si
Read data from stdin.
-so
Write data to stdout.
-y
Assume Yes on all queries.
-ttype
Specifies the type of archive: 7z, zip, gzip, bzip2, xz, tar, etc.
-mparameters
Set compression method. Commonly used to define level of compression.
-oDirectory
Set destination directory.
DESCRIPTION
The 7z command is a powerful, open-source file archiver with a high compression ratio. It is primarily used to create and extract 7z archives, but it also supports other archive formats like ZIP, GZIP, BZIP2, XZ, TAR, and more. This allows 7z to function as a general-purpose archiving tool. The 7z format itself is known for its strong AES-256 encryption capabilities, making it suitable for protecting sensitive data. The command-line interface offers flexible options for creating solid archives, splitting archives into smaller parts, specifying compression levels, and password-protecting archives. It is widely used for software distribution, data backup, and general file management.
The command relies on the 7-Zip suite backend, and is known for creating archives with a very high degree of compression.
CAVEATS
The exact performance and compression ratios of 7z depend heavily on the type of data being archived and the chosen compression settings. While 7z offers high compression, it can be computationally intensive, especially for large files with high compression levels. The 7z command itself is a front-end to the 7-Zip archiver, so correct installation of 7-Zip is essential.
ARCHIVE TYPES
The -t switch allows you to create archives in different formats. Common options include 7z, zip, gzip, bzip2, and tar. The appropriate choice depends on compatibility requirements and desired compression levels.
SOLID ARCHIVES
The 7z format supports "solid" archives, where files are compressed together as a single stream. This can improve compression ratios, especially for collections of small files. However, solid archives can be slower to update or extract individual files from. The default behavior may or may not be solid, depending on the implementation, so explore further options or parameters to be explicit.
HISTORY
7-Zip was initially developed by Igor Pavlov, with the first public release in 1999. It gained popularity due to its open-source nature, high compression ratios, and support for multiple archive formats. The 7z command provides a command-line interface to the 7-Zip archiver, making it suitable for scripting and automation. Over the years, 7-Zip and the 7z command have been continuously improved with enhanced compression algorithms, security features, and platform support. It became a standard tool for software developers, system administrators, and general users who need efficient file archiving.