Home > Back-end >  How to extract tgz file in Linux command line
How to extract tgz file in Linux command line

Time:04-02

I was working on Linux and I was installing Python by following enter image description here

Then I researched on the internet a lot and found this tutorial and command useful to successfully extract the file.

The command is:

tar zxvf Python-3.7.5.tgz

My question is why

tar -xf Python-3.8.3.tgz // was not working

And why

tar zxvf Python-3.7.5.tgz

Worked successfully?

What is the difference and logic behind -xf and zxvf ?

CodePudding user response:

Use also option z (z means that it's compressed)

tar -xzf Python-3.8.3.tgz

CodePudding user response:

According to the man page:

-z, --gzip, --gunzip, --ungzip
    Filter the archive through gzip(1).

This flag tells tar that the file is compressed and it should pass it through gzip to uncompress it first before unarchiving it. This works for all files with gz in the file extension.

CodePudding user response:

The extension .tgz is short for .tar.gz meaning that first a tar package has been created and then this has bee gzipped.

You need to tell tar´ that the package is gzipped, and that is done with the argument z`. The dash is optional; different versions has used dash, others have not, so GNU tar supports both variants.

  • Related