Home » Command to unzip a .tar.gz file

Command to unzip a .tar.gz file

Below is the command to unzip a .tar.gz file :

tar -xvzf file.tar.gz

To elaborate, tar combined all of the files into a single package, community images.tar. The gzip programme compressed data, hence the gz extension. So the command accomplishes below things:

f: this must be the command’s final flag, and the tar file must come immediately after. It instructs tar on the name and location of the compressed file.
z: instructs tar to use gzip to decompress the archive.
x: tar can both collect and extract files. The latter is accomplished by x.
v:Tar talks a lot while v is around. The verbose output displays all of the files that are being extracted.

To extract the data into a specific folder then use:

tar -xvzf file_name.tar.gz -C /path/to/destination/folder

Also Read:

How to upgrade a single package using apt-get