In our previous article, we explored the top 5 command line archive tools, including tar, shar
, ar
, cpio
, and gzip.
In this follow-up, we will cover 5 more archiving and compression utilities that are useful for various scenarios, along with their features, options, and practical examples.
6. bzip2 Command
bzip2 is a file compression tool that uses the Burrows-Wheeler algorithm and Run-Length Encoding (RLE) to achieve higher compression ratios than gzip and it produces compressed files with an .bz2
extension.
bzip2 Options:
-d
: Decompress a file.-z
: Compress a file (default behavior).-k
: Keep the original file while compressing.-f
: Force overwrites if the output file exists.
Compress a file:
bzip2 filename.txt
Decompress a .bz2
file:
bzip2 -d filename.txt.bz2
Compress a file and retain the original:
bzip2 -k filename.txt
7. xz Command
xz is another popular file compression utility that uses the LZMA2 algorithm, offering better compression ratios than gzip and bzip2 for larger files and it produces .xz
compressed files.
xz Options:
-d
: Decompress a file.-k
: Keep the original file after compression.-z
: Compress a file (default behavior).-f
: Force overwrites of existing files.
Compress a file:
xz filename.txt
Decompress an .xz
file:
xz -d filename.txt.xz
Compress a file and keep the original:
xz -k filename.txt
8. zip Command
zip is one of the most common file archiving utilities that compresses files into a single .zip
archive and it is widely used for cross-platform file sharing.
zip Options:
-r
: Recursively archive directory contents.-u
: Update the archive with new files.-d
: Delete specified files from the archive.-m
: Move files into the archive and delete the originals.
Create a zip archive:
zip archive_name.zip file1 file2 file3
Compress a directory recursively:
zip -r archive_name.zip /path/to/directory
Extract a zip archive:
unzip archive_name.zip
9. rar Command
rar is a proprietary archiving utility that is widely used for compressing large files and it supports password-protected archives and multi-volume archives.
rar Options:
a
: Add files to the archive.x
: Extract files from the archive.v
: Create multi-volume archives.p
: Set a password for the archive.
Create a rar archive:
rar a archive_name.rar file1 file2
Extract a rar archive:
rar x archive_name.rar
Create a password-protected rar archive:
rar a -p archive_name.rar file1 file2
10. 7zip Command (7z)
7z is a high-compression utility that uses the LZMA algorithm to create .7z
files and it provides better compression than most other utilities.
7z Options:
a
: Add files to an archive.x
: Extract files from an archive.l
: List the contents of an archive.d
: Delete a file from the archive.
Create a 7z archive:
7z a archive_name.7z file1 file2
Extract a 7z archive:
7z x archive_name.7z
Conclusion
With these additional tools, you now have a comprehensive arsenal of archiving and compression utilities to handle any file compression task on Linux. Each tool has its strengths and use cases, so choose the one that best fits your needs.
Stay tuned for more tutorials and tips on Tecmint, and feel free to share your feedback in the comments section below!