How to decompress .gz files in Linux

Ubuntu LogoI’ve been struggling this morning with a compressed SQL file – it had been given a .gz file extension, and I was trying to use the tar command to decompress it. Apparently this is stupid – there’s a dedicated utility to decompress a .gz file – gunzip.

It’s as simple as this:

$ gunzip big-database-dump.sql.gz
$ ls big-database-dump.sql

(The ls command simply lists the extracted file, by the way)

If you’re using Ubuntu, there’s a very easy way to extract the file using the GUI – simply browse to the .gz file you want, right click on it and choose the Extract here command.

However, the time to use the tar command is when you’re opening up a file like drupal-6.15.tar.gz

tar -zxvf Drupal-6.15.tar.gz

Hope this helps out other Ubuntu/Linux newbies who’ve struggled with file decompression!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s