Wednesday, October 18, 2017

UNIX / Linux Decompress “.tar.Z”, “.tar.gz”, “.tar.bz2” ,".tgz"

Type man tar for more information, but this command should do the trick:
tar -xvzf community_images.tar.gz
To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:
  • f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.
  • z: tells tar to decompress the archive using gzip
  • x: tar can collect files or extract them. x does the latter.
  • v: makes tar talk a lot. Verbose output shows you all the files being extracted.
 -----------------
Q. I’ve downloaded a file from internet in .tgz format. How do I decompress .tgz file under UNIX or Linux operating system using a shell prompt?

A. This is archive file also known as tar ball. If an archive is compressed with an external tool, the compression program adds its own suffix as usual, resulting in filename endings like “.tar.Z”, “.tar.gz”, and “.tar.bz2” or tgz. To open such file type the following command at Linux shell prompt (GNU tar syntax):
$ tar -zxvf filename.tgz
$ tar -zxvf filename.tar.gz
$ tar -jxvf filename.tar.bz2
 
UNIX decompress tgz / tar.gz file
Type the following command:
$ gzip -dc filename.tgz | tar xf -
$ gzip -dc filename.tar.gz | tar xf -

If file extension ends with .Z, enter:
$ zcat filename.tar.Z | tar xf -

No comments:

Post a Comment