Linux offers powerful tools for file compression and extraction. Whether you're backing up data, transferring files, or organizing directories, mastering commands like tar
, zstd
, and unzip
is essential. Below are practical examples and explanations for each.
Command:
tar -xvzf user.admin.dorgul.tar.gz
Explanation: This extracts the contents of a gzip-compressed tar archive.
Command:
tar -cvzf ./tar.gz /document
Explanation: This compresses the /document
directory into a gzip-compressed archive named tar.gz
.
Command:
zstd -d filename.tar.zst
Explanation: Decompresses a Zstandard-compressed tar file into its original .tar
format.
Command:
zstd file.txt
Explanation: Compresses file.txt
into file.txt.zst
using Zstandard.
Command:
tar -I zstd -xvf archive.tar.zst
Explanation: Uses tar with Zstandard to extract the contents of archive.tar.zst
.
Command:
unzip file.zip -d destination_folder
Explanation: Extracts file.zip
into the folder destination_folder
.
Whether you're working with .tar.gz
, .tar.zst
, or .zip
files, Linux provides efficient tools for compression and extraction. Understanding these commands helps streamline workflows, automate backups, and manage data with precision.