$linuxjunkies
>

zstd(1)

zstd is a fast real-time compression algorithm that provides high compression ratios with faster speed than gzip or bzip2.

UbuntuDebianFedoraArch

Synopsis

zstd [OPTION]... [FILE]...

Description

zstd (Zstandard) is a modern compression utility offering excellent speed-to-ratio tradeoffs. It compresses files to .zst format and supports both compression and decompression with configurable compression levels (1-22). zstd is significantly faster than gzip at similar compression levels and is increasingly used in Linux distributions and archival tools.

By default, zstd compresses files in-place, removing the original and creating a .zst file. It supports parallel compression, streaming, and dictionary-based compression for optimal results on similar data.

Common options

FlagWhat it does
-d, --decompressDecompress the file (reverse operation)
-k, --keepKeep input file; don't delete it after compression/decompression
-f, --forceOverwrite output file without prompting
-1 to -22Set compression level (1=fastest, 22=best ratio; default is 3)
-T#, --threads=#Use # threads for parallel compression (0=auto-detect)
-c, --stdoutWrite compressed data to stdout instead of file
-o FILE, --output=FILEWrite output to FILE instead of default name
-v, --verboseShow compression progress and statistics
-q, --quietSuppress messages and progress info
-r, --recursiveRecursively compress all files in directories
--ultraEnable ultra compression levels (20-22, slower)

Examples

Compress file.txt to file.txt.zst, removing the original

zstd file.txt

Compress file.txt to file.txt.zst while keeping the original

zstd -k file.txt

Decompress file.txt.zst back to file.txt

zstd -d file.txt.zst

Compress with maximum compression ratio (slower but smaller)

zstd -22 large.iso

Compress multiple files using 4 threads, output to archive.zst

zstd -T4 -o archive.zst file1.txt file2.txt file3.txt

Compress stdin to stdout, useful for piping

cat file.bin | zstd -c > file.bin.zst

Recursively compress all files in the data/ directory

zstd -r data/

Compress with auto-detected threads, showing verbose output

zstd -v -T0 backup.tar

Related commands