Extract a gzip compressed tar archive in Linux

Contributor Icon Contributed by qmchenry Date Icon October 3, 2003  
Tag Icon Tagged: Linux

The version of tar in most Linux distributions supports gzip compression. This means that a gzipped tar file can be extracted in one simple command.


To extract the archive filename.tar.gz into the current directory:

tar xzf filename.tar.gz

If this fails, the version of tar may not support gzip compression. In this case, you can use the traditional two-stage command:

gzip -dc filename.tar.gz | tar xf -

Previous recipe | Next recipe |
 
  • bofh468
    Another useful switch is -j for handling bzip2 compression. To do the same as above for a bzip-compressed tarball:


    tar xjf filename.tar.bz2

  • barretj
    another usefull tar command is this:

    tar czvf tarball.tar.gz /tmp/tarball

    this will tar and gzip the directory /tmp/tarball into the file tarball.tar.gz
  • santhosh
    i got the following error when i extracted.
    gzip: stdin: not in gzip format
    tar: Child returned status 1
    tar: Error exit delayed from previous errors.
    Plz suggest any way to extract in linux?
  • smeezekitty
    santhosh are you sure its not a bzip not gzip
blog comments powered by Disqus