How to Install zstd on Various Linux distros

Before you can use zstd, you need to install it – if you don’t have it already installed on your Linux distro. Fortunately, installing zstd is as simple as executing a couple of commands. Note: based on which Linux distro you’re running, you may have to install dependencies and various tools before compiling and installing zstd. That’s why the first thing you should do is update your system. For Debian and Ubuntu-based distro, you can use the update and upgrade commands: To ensure that you have all the dependencies that zstd needs, install build-essentials, wget, and tar using the command: Now that you have the all the required dependencies and tools installed, you can move on and install zstd.

On Debian/Ubuntu/Linux Mint

To install zstd on a Debian/Ubuntu/Linux Mint system, execute the command:

On Fedora/Red Hat/CentOS/AlmaLinux

To install Zstandard on Fedora/Red Hat/CentOS/AlmaLinux systems, execute the command;

On Arch Linux/Manjaro

To install zstd on Arch Linux/Manjaro systems, execute the command: Now that we have zstd installed and ready to go, we can start using it to compress files.

Compressing Files with zstd

Using zstd to compress a file is easy. All you have to do is execute the command zstd [filename]. Using the above command creates a new, compressed file with the .zst extension. For example, to compress a “samplecompression.text” in the “/var/log” directory, we would execute the command: the following is an example output: The above output shows the compression factor, i.e 44.08% from 1141 bytes for 503 bytes.

Compressing Multiple Files

To use zstd to compress multiple files simultaneously, all you have to do is specify the files you want to compress, separated by a space between them. For example, to compress “compress.txt,” “compress2.txt,” “compress3.txt,” and “compress4.txt”: You can also use the wildcard “*” to compress all the files and folders within your current/specified directory. For example:

Decompressing Files with zstd

When you need to decompress a file with zstd, use the -d option or unztd. For example, to decompress the file used throughout this guide, you would use any of the following commands: Ensure the source of the file from the archive does not exist, or zstd will prompt you to overwrite the existing file.

Conclusion

This tutorial has illustrated how to compress and decompress files using the zstd utility. Meanwhile, you can learn how to extract zip files in Linux.