Zstd
Overview
Zstandard (zstd) is a fast, efficient compression algorithm designed to replace gzip, offering better compression speeds and slightly smaller file sizes. It is free, widely available, and lossless, meaning no data is lost during compression or decompression. Many industry leaders have adopted zstd as their default compression method, including Acronis, Plesk, Cloudflare, and Red Hat Enterprise Linux 9. Modern browsers like Chrome (v123+) and Firefox (v126+) also support zstd by default.
Why choose Zstandard?
- Faster Compression and Decompression: Zstd outperforms gzip significantly in speed.
- Better Compression Ratio: Files are typically compressed smaller than gzip.
- Wide Adoption: Used by major software and platforms for improved performance.
- Lossless Compression: Fully reversible without data loss.
- Optimized for Modern Hardware: Utilizes more RAM and CPU optimizations than gzip’s 32 kB limit.
Equivalent zstd vs gzip commands
| Task | zstd Command | gzip Equivalent |
|---|---|---|
| Compress (delete original) | zstd --rm | gzip |
| Compress (keep original) | zstd | gzip --keep |
| Decompress (delete original) | unzstd --rm | gunzip |
| Decompress (keep original) | unzstd | gunzip --keep |
| Multi-threaded compression | zstdmt --rm | pigz |
| Multi-threaded (keep original) | zstdmt | pigz --keep |
| View compressed files | zstdless | less |
| Search compressed files | zstdgrep | zgrep |
| Output to stdout | zstdcat | zcat |
| Compress tar archive (single-threaded) | tar -I zstd | tar -z |
| Compress tar archive (multi-threaded) | tar -I zstdmt | tar -I pigz |
Installation
Zstandard (zstd) is available in the EPEL repository on CentOS systems. Follow the steps below to install it cleanly:
For CentOS 7 and 8
Enable the EPEL repository (if not already enabled):
yum install epel-releaseInstall zstd:
yum install zstdOptional: disable EPEL after installation (Recommended for CentOS 7)
If you prefer not to leave EPEL enabled system-wide (e.g., to avoid conflicts or updates from EPEL), you can temporarily enable it just for the installation:
yum install epel-release
yum-config-manager --disable epel
yum --enablerepo=epel install zstd
This approach ensures that only zstd is installed from EPEL without affecting other system packages.
Summary
Zstandard (zstd) is a modern, lossless compression algorithm that offers faster performance and better compression ratios than gzip. Widely adopted by industry leaders like Cloudflare, Plesk, and Red Hat, it supports multi-threading and is optimized for modern hardware. Zstd is a drop-in replacement for gzip with equivalent commands and improved efficiency. It’s available via EPEL on CentOS and ideal for tasks like backups and file archiving.