$linuxjunkies
>

pigz(1)

pigz is a parallel implementation of gzip that compresses files using multiple processors for faster compression and decompression.

UbuntuDebianFedoraArch

Synopsis

pigz [OPTION]... [FILE]...

Description

pigz compresses files in parallel, using multiple cores to speed up gzip compression. It maintains full compatibility with gzip format, so compressed files can be decompressed with standard gunzip or gzip -d. By default, pigz uses all available processors to divide the work.

pigz is especially useful for compressing large files or multiple files simultaneously. It automatically detects the number of CPU cores and distributes compression tasks accordingly, making it significantly faster than single-threaded gzip on modern multi-core systems.

Common options

FlagWhat it does
-kkeep input files after compression (do not delete)
-ddecompress instead of compress
-9use maximum compression level (1-9, default is 6)
-1use fastest compression with minimal compression ratio
-p nuse n parallel threads instead of auto-detected number
-ttest the integrity of compressed files
-llist information about compressed files
-vverbose output showing compression details
-rrecursively compress all files in directories
-S .sufuse custom suffix for compressed files (default .gz)
-cwrite output to stdout instead of creating new files
-fforce overwriting of output files

Examples

Compress largefile.log in parallel, creating largefile.log.gz and removing the original

pigz largefile.log

Compress all .txt files in parallel while keeping originals

pigz -k *.txt

Decompress file.gz back to original format

pigz -d file.gz

Compress backup.tar using exactly 4 parallel threads

pigz -p 4 backup.tar

Compress with maximum compression level, keeping the original file

pigz -9 -k largefile.sql

Recursively compress all files in /var/log/ directory

pigz -r /var/log/

List compression information and ratios for all .gz files

pigz -l *.gz

Pipe input through pigz and write compressed output to stdout

cat data.txt | pigz > data.txt.gz

Related commands