For decades, Linux administrators and developers relied on gzip (.tar.gz) and xz (.tar.xz) for archiving directory trees and backing up servers. While gzip compresses quickly with modest compression ratios and xz delivers high compression at the cost of slow CPU execution, neither algorithm was designed for modern multi-core processors. Meta’s Zstandard (zstd) algorithm provides an optimal balance, delivering compression ratios comparable to xz while matching or exceeding the decompression speed of uncompressed storage. Using GNU tar with native zstd integration allows you to create lightning-fast, multi-threaded .tar.zst archives directly from the command line.
Advantages of Zstandard (zstd) over Gzip and XZ
Zstandard was engineered to eliminate traditional compression trade-offs:
- Extreme Decompression Speed: Regardless of the compression level chosen (from level 1 to level 19),
zstddecompresses at near-memory bus speeds (often exceeding 1 GB/s per core), significantly speeding up software deployments and container image unpacking. - Scalable Compression Levels: Offers 19 standard compression levels. Levels 1–3 provide ultra-fast real-time archiving, while levels 15–19 provide compression density approaching
xz. - Native Multi-Threading: Supports multi-threaded processing out of the box, allowing compression workloads to scale across all available CPU cores.
- Native GNU tar Support: Modern distributions (including Ubuntu, Debian, Fedora, and Arch) bundle GNU
tarversion 1.31 or newer, which features native--zstdflag recognition.
Installing the zstd Utility on Linux
Before GNU tar can invoke the Zstandard compression engine, verify that the zstd binary is installed on your operating system:
- On Ubuntu and Debian systems:
sudo apt update && sudo apt install zstd - On Fedora, RHEL, and CentOS Stream:
sudo dnf install zstd - On Arch Linux:
sudo pacman -S zstd
Creating a .tar.zst Archive Using Native tar Syntax
To archive and compress a directory into a Zstandard tarball:
- Open your terminal and navigate to the directory containing your project or backup files.
- Execute the archiving command using the
--zstdflag:tar --zstd -cf backup.tar.zst /path/to/source_directory - Alternatively, use short flag notation (
-I zstd):tar -I zstd -cf project_files.tar.zst ./my_project - To display progress and list files as they are archived, include the verbose flag (
-v):tar --zstd -cvf site_backup.tar.zst /var/www/html
Leveraging Multi-Core Multi-Threading and Custom Compression Levels
By default, basic zstd invocation uses a single CPU core at compression level 3. To harness all CPU cores and select custom compression strength, pass options to zstd via the -I (use-compress-program) flag:
- To compress using all available CPU threads (
-T0) at standard level 3:tar -I 'zstd -T0' -cf multi_threaded_backup.tar.zst ./data_folder - To achieve maximum compression density for archival storage (level 19) across all CPU threads:
tar -I 'zstd -19 -T0' -cf cold_storage_archive.tar.zst ./database_dumps - For ultra-fast real-time archiving where speed is the primary objective:
tar -I 'zstd -1 -T0' -cf fast_snapshot.tar.zst ./build_artifacts
Listing Archive Contents Without Extracting
To inspect the file list inside a .tar.zst archive without unpacking files to disk:
tar --zstd -tf backup.tar.zst
You can pipe this output into grep or less to verify specific file paths before extraction.
Extracting a .tar.zst Archive
To unpack a Zstandard compressed tarball:
- Extract into the current directory:
tar --zstd -xf backup.tar.zst - To extract files into a specific target destination directory:
tar --zstd -xf backup.tar.zst -C /opt/extracted_data/ - GNU
tarautomatically detects the.zstfile signature on modern builds, so simply runningtar -xf backup.tar.zstalso works seamlessly across modern Linux distributions.