How to Compress / Archive or Decompress / Unarchive / extract with Gzip, Zip, and Tar
When the compressed files are downloaded on unix or linux, their extension are somtimes different like gz, zip, tar, tar.gz. The commands to extract / decompress / unarchive these files are different, so here is the guide:
How to compress /archive files with “zip”
zip -r filename.zip file1 file2 file2
How to decompress / unarchive / extract .zip extension
unzip filename.zip
How to compress /archive files with “gzip”
gzip filename.gz file1 file2 file3
How to decompress / unarchive / extract .gz extension
gunzip filename.gz
How to compress /archive files with “tar”
tar -cvf foo.tar file1.txt file2.txt file3.txt
Or compress / archive the whole directory with “tar”
tar -cvf filename.tar files/directories
How to decompress / unarchive / extract .tar extension
tar -xvf filename.tar
How to decompress / unarchive / extract .tgz or .tar.gz extension
tar -xzvf filename.tgz
or
tar -xzvf filename.tar.gz
