unzip tar.gz linux terminal code example

Example 1: bash command for unzipping tar.gz files

# Basic syntax:
tar -zxvf file.tar.gz

# Where:
#	- x tells tar to extract the files
#	- v tells the command to list all of the files in the archive
#	- z tells the tar command to uncompress the file (gzip)
#	- f tells tar that you are going to give it a file name to work with

Example 2: how to extract tar.gz

If your tar file is compressed using a gzip compressor, use the following command to extract it.

    $ tar xvzf file.tar.gz
    
If your tar file is compressed using a bZip2 compressor, use the following command to extract it.

    $ tar xvjf file.tar.bz2