← 返回命令列表

Linux command

p7zip 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Extract archive

7z x [archive.7z]

Extract to specific directory

7z x [archive.7z] -o[/path/to/output]

Create 7z archive

7z a [archive.7z] [files_or_dirs]

Create with maximum compression

7z a -mx=9 [archive.7z] [files]

List archive contents

7z l [archive.7z]

Test archive integrity

7z t [archive.7z]

Add password encryption

7z a -p[password] [archive.7z] [files]

Create encrypted archive

7z a -p[password] -mhe=on [archive.7z] [files]

说明

p7zip is the Unix port of 7-Zip, providing high-ratio compression. The 7z format typically achieves 30-70% better compression than ZIP using LZMA/LZMA2 algorithms. The package provides three commands: 7z (full-featured), 7za (standalone), and 7zr (reduced, 7z format only). Most users use 7z or 7za. Archive format support includes: 7z, ZIP, GZIP, BZIP2, XZ, TAR, and extraction from many others (RAR, CAB, ISO, DMG, etc.). The -t option overrides automatic format detection. Solid archives (-ms=on) compress files as a single block, improving compression when archiving many similar files. However, this means extracting one file requires decompressing all preceding files. Encryption uses AES-256. The -mhe option encrypts filenames in addition to content, hiding what's in the archive. Password can be provided on command line (visible in process list) or prompted interactively.

参数

a
Add files to archive.
x
Extract with full paths.
e
Extract to current directory.
l
List archive contents.
t
Test archive integrity.
d
Delete from archive.
u
Update files in archive.
-mx= _LEVEL_
Compression level (0=store, 1=fastest, 5=normal, 7=maximum, 9=ultra).
-p_PASSWORD_
Set password (no space between switch and value; prompts interactively if omitted).
-mhe=on
Encrypt header so filenames inside the archive are also hidden.
-o_DIR_
Output directory for `x`/`e` (no space between `-o` and the path).
-r
Recurse subdirectories.
-y
Assume yes to all prompts.
-t _TYPE_
Archive type: 7z, zip, tar, gzip, bzip2.
-v _SIZE_
Create volumes of specified size.
-m0= _METHOD_
Compression method: lzma, lzma2, bzip2, ppmd.
-ms=on
Enable solid archive mode.

FAQ

What is the p7zip command used for?

p7zip is the Unix port of 7-Zip, providing high-ratio compression. The 7z format typically achieves 30-70% better compression than ZIP using LZMA/LZMA2 algorithms. The package provides three commands: 7z (full-featured), 7za (standalone), and 7zr (reduced, 7z format only). Most users use 7z or 7za. Archive format support includes: 7z, ZIP, GZIP, BZIP2, XZ, TAR, and extraction from many others (RAR, CAB, ISO, DMG, etc.). The -t option overrides automatic format detection. Solid archives (-ms=on) compress files as a single block, improving compression when archiving many similar files. However, this means extracting one file requires decompressing all preceding files. Encryption uses AES-256. The -mhe option encrypts filenames in addition to content, hiding what's in the archive. Password can be provided on command line (visible in process list) or prompted interactively.

How do I run a basic p7zip example?

Run `7z x [archive.7z]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does a do in p7zip?

Add files to archive.