How to Create Zstd Compressed Archive on Ubuntu
This article provides a step-by-step guide to creating compressed archives using Zstandard (zstd) on Ubuntu. It covers installation, basic compression commands, and how to customize compression levels for optimal performance.
Install Zstd
While newer versions of Ubuntu may include zstd by default, you can ensure it is installed by updating your package list and installing the tool via the terminal. Run the following command:
sudo apt update
sudo apt install zstdCreate a Compressed Archive
To create a compressed archive, you typically combine
tar with the zstd compression algorithm. This creates a
.tar.zst file. Navigate to the directory containing the
files or folders you wish to compress and execute the following
command:
tar --zstd -cf archive-name.tar.zst /path/to/folderHere is the breakdown of the flags used: * --zstd: Tells
tar to use zstd compression. * -c: Creates a new archive. *
-f: Specifies the filename of the archive.
Adjust Compression Levels
Zstd allows you to balance compression speed and ratio using levels
ranging from 1 (fastest) to 19 (slowest, best compression). The default
level is usually 3. To specify a level, add the
--zstd-compress-level option:
tar --zstd --zstd-compress-level=10 -cf archive-name.tar.zst /path/to/folderUsing a higher level is useful for long-term storage, while lower levels are better for quick backups.
Verify and Extract
To verify the contents of your archive without extracting them, use
the -t flag:
tar --zstd -tf archive-name.tar.zstTo extract the files later, use the -x flag:
tar --zstd -xf archive-name.tar.zst