zip
and unzip
zip
: This is one of the most popular tools for creating compressed files in Linux. It packages files and directories into a single archive file with a .zip
extension.
Usage:
zip archive_name.zip file1 file2 dir1
unzip
: This tool is used to extract files from a .zip
archive.
Usage:
unzip archive_name.zip
tar
tar
: Short for Tape Archive, tar
is commonly used to combine multiple files into a single file, known as a tarball, with extensions like .tar
. While tar
itself does not compress files, it is often used in conjunction with compression tools like gzip
or bzip2
.
Usage:
tar -cvf archive_name.tar file1 file2 dir1
gzip
and gunzip
gzip
: This tool compresses files using the GNU zip algorithm, typically resulting in .gz
files.
Usage:
gzip file1
gunzip
: This is used to decompress .gz
files.
Usage:
gunzip file1.gz
Combining tar
and gzip
:
tar -czvf archive_name.tar.gz file1 file2 dir1
tar -xzvf archive_name.tar.gz
bzip2
and bunzip2
bzip2
: This tool provides higher compression ratios than gzip
, but it is slower. It results in files with a .bz2
extension.
Usage:
bzip2 file1
bunzip2
: This is used to decompress .bz2
files.
Usage:
bunzip2 file1.bz2
Combining tar
and bzip2
:
tar -cjvf archive_name.tar.bz2 file1 file2 dir1
tar -xjvf archive_name.tar.bz2
xz
and unxz
xz
: This tool provides high compression ratios and is used to compress files to .xz
format.
Usage:
xz file1
unxz
: This is used to decompress .xz
files.
Usage:
unxz file1.xz
Combining tar
and xz
:
tar -cJvf archive_name.tar.xz file1 file2 dir1
tar -xJvf archive_name.tar.xz
7z
and p7zip
7z
: This is the command-line version of the 7-Zip compression tool, providing high compression ratios. The files compressed by this tool typically have a .7z
extension.
Usage:
7z a archive_name.7z file1 file2 dir1
p7zip
: This is a Unix port of 7-Zip, providing the 7z
and 7za
commands.
7z
Extraction:
7z x archive_name.7z