HowTo: Unpack .tgz File On Linux

by on November 19, 2013 · 3 comments· LAST UPDATED November 19, 2013

in , ,

I am a new Linux user. I am having problem with the Terminal. How do I unpack .tgz (tar.gz) file on Linux using command line options?

Most Linux and open source software files are distributed in either .tgz or .tar.gz extensions format over the Internet. These files are gzipd tar balls and include multiple files and sub-directories into a single file using tar command. To save the bandwidth tar files are cpmpressed using gzip program.

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Estimated completion time2m

Unpacking .tgz files command

The syntax is as follows:

tar zxvf fileNameHere.tgz

Or try the geeky bash pipe based syntax:

gunzip -c fileNameHere.tgz | tar xvf -


In this example, unpack a file called backups.tgz, enter:

tar zxvf backups.tgz


gunzip -c backups.tgz | tar xvf -

Sample outputs:

tar: Removing leading '/' from member names
x Users/vivek/Downloads/db.txt
x Users/vivek/Downloads/resume.txt
x Users/vivek/Downloads/vendors.txt
x Users/vivek/Downloads/sales.txt

To unpack and put files in a different folder (directory) say /tmp/data, enter:

tar zxvf backups.tgz -C /tmp/data
ls -l /tmp/data

tar command options

  • -z : Uncompress the resulting archive with gzip command.
  • -x : Extract to disk from the archive.
  • -v : Produce verbose output i.e. show progress and file names while extracting files.
  • -f backup.tgz : Read the archive from the specified file called backup.tgz.
  • -C /tmp/data : Unpack/extract files in /tmp/data instead of the default current directory.

See tar(1) command man page for more information.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 3 comments… read them below or add one }

1 Alsalgo November 20, 2013 at 7:29 am

You can try too:

gzip -dc backups.tgz | tar xvf -
gzip -dc backups.tar.gz | tar xvf -
gzip -dc backups.tar.Z | tar xvf -


2 paul muhia January 17, 2015 at 9:43 am

It’s just what i have been looking for. Much thanks.


3 adoare January 22, 2015 at 6:22 pm

Thank you for the information, I was able to find what i was looking for in a jiff and i was able to understand the instructions.


Leave a Comment

Tagged as: , ,

Previous Faq:

Next Faq: