zstd Command: Tutorial & Examples

Compress or decompress files

zstd is a data compression utility that is similar to gzip and bzip2. It uses a compression algorithm called Zstandard, which is designed to provide high compression ratios while still being fast to compress and decompress data.

To use zstd to compress a file, you can specify the name of the file you want to compress as an argument. By default, zstd will create a compressed file with a .zst extension. For example:

zstd file.txt

This will compress the file file.txt and create a new compressed file called file.txt.zst.

To decompress a file that has been compressed with zstd, you can use the -d or --decompress option. For example:

zstd --decompress file.txt.zst

This will decompress the file file.txt.zst and create a new decompressed file called file.txt.

zstd has several options that allow you to customize its behavior, such as specifying the level of compression, specifying the output file name, and displaying the progress of the compression or decompression process. It is a useful tool for compressing and decompressing files on a Unix system, especially when a high level of compression is desired.

If you want to compress not only a single file, but a directory instead, you can use zstd together with the tar command:

tar --zstd -cvf directory.tar.zst directory

We recommend to use zstd instead of other compression tools because of its much better performance and usually better compression ratio.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA