zstd Command: Tutorial & Examples
Compress or decompress files
zstd is a data compression utility that is similar to
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.
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
extension. For example:
This will compress the file
file.txt and create a new compressed file called
To decompress a file that has been compressed with
zstd, you can use the
--decompress option. For example:
zstd --decompress file.txt.zst
This will decompress the file
file.txt.zst and create a new decompressed file called
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 --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.