Linux / UNIX command to open .gz files

by Vivek Gite on October 4, 2007 · 7 comments

Q. I have download files from the Internet. Each file has .gz extension. How do I open .gz files under Linux?

A. You need to use gzip / gunzip program. It is a software application used for file compression. It is based on the DEFLATE algorithm, which is a combination of LZ77 and Huffman coding. DEFLATE was intended as a replacement for LZW and other patent-encumbered data compression algorithms

How do I extract a gz file?

Use guzip command as follows:
$ gunzip file.gz
OR
$ gzip -d file.gz
To see new file, enter:
$ ls -l

How do I extract a tar.gz or .tgz file?

Files with extension tar.gz or .tgz are tar files compressed with gzip. On Unix system extract them with following command:
$ gunzip < file.tar.gz | tar xvf -
$ gunzip < file.tgz | tar xvf -

If you have GNU tar (Linux system) you can use the z option directly:
$ tar xvzf file.tar.gz
$ tar xvzf file.tgz

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 7 comments… read them below or add one }

1 Carolanne October 15, 2007

I can extract a .gz file using WinZip but how do I open a .gz file under Windows XP?

Reply

2 Balakrishna Bhat March 17, 2009

Sir,
I have some softwares downloaded from internet and few copied from Chip Magazine’s data dvds. I have dual-boot system[Windows xp home and ubuntu 8.10].I do not have much experience about computers and want to install few softwares which are in tar.gz formats and few are in tar.bz2 formats. I do not know how to install them-Only the deb or i386 formats are can be installed through Gdebi installer.Will you suggest me how to?

Reply

3 Luciano July 21, 2009

Nice blog!!
Keep it up!!

Reply

4 Balakrishna Bhat July 21, 2009

Really nice one-exactly the one needed.

Reply

5 kamal September 19, 2010

It’s giving me following error :

====
root@server [/10gR2_db]# gzip -d 10201_database_linux_x86_64.cpio.gz

gzip: 10201_database_linux_x86_64.cpio.gz: unexpected end of file
root@server [/10gR2_db]
====

Reply

6 ahmadalza September 10, 2011

#mv 10201_database_linux_x86_64.cpio.gz 10201_database_linux_x86_64_cpio.gz

Reply

7 sai November 30, 2011

thank you for the help. really appreciate it.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 4 + 9 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: