Efficient File Compression with pigz
Unlock the potential of pigz, a parallel implementation of gzip designed for efficient file compression and decompression. Explore essential commands for compressing and decompressing files, adjust compression levels to balance speed and size, harness the power of multicore processing, efficiently handle files including compression of multiple files into a single archive and decompression of archives, utilize different compression modes like ZLIB and LZMA, manage output options for customized handling, and delve into advanced usages such as independent blocks and processing tar files. Discover how pigz can streamline your file compression tasks.
Basic Usage
Compress a file
pigz filename
Decompress a file
unpigz filename.gz
pigz -d filename.gz
Compression Levels
Here's a table that provides the various compression levels you can use with pigz, and the corresponding commands:
Level | Description | Command |
---|---|---|
1 | Fast compression | pigz -1 filename |
2-8 | Tradeoff between speed & size | pigz -5 filename |
9 | Best compression, slowest speed | pigz -9 filename |
Multicore Processing
Use specific number of processors
pigz -p 4 filename
Compress a file using all available cores
pigz -p $(nproc) filename
File Handling
Keep the original files
pigz -k filename
Compress multiple files into a single archive
tar cf - paths... | pigz > archive.tar.gz
Decompress an archive
unpigz -c archive.tar.gz | tar xf -
Compression Modes
Use Standard compression (default)
pigz filename
Use ZLIB compression
pigz -z filename
Use LZMA compression
pigz -l filename
Output
Write output to stdout
pigz -c filename > output.gz
Verbose mode
pigz -v filename
Advanced Usages
Compress a file with maximum compression and highest number of processing cores
pigz -9 -p $(nproc) filename
Use independent blocks for improved multicore inflation
pigz -i filename
Process a tar file with pigz
tar cf - paths... | pigz -p $(nproc) -9 > file.tar.gz
Others
Test the compressed file integrity
pigz -t filename.gz
Show the pigz version
pigz -V