Skip to content

How to Unzip (Extract) a GZ File in Linux

Advertisement

Unzipping or extracting .gz files in Linux is something many people need to do often. This article offers a detailed guide on how to unzip these files using different ways. Whether you are new to Linux or have some experience, you will find easy-to-follow steps here. We cover several techniques, from using basic commands in the terminal to employing software tools that make the process simpler. This guide helps you understand and perform file extraction smoothly and efficiently, ensuring you can handle .gz files without any trouble.

1. Overview

A .gz file, short for GNU Zip, is a compression format used in Unix and Linux systems. It employs the gzip compression algorithm and is often used to compress single files. For multiple files, .tar.gz or .tgz are used, combining .tar (tape archive) with gzip compression.

2. Using the gunzip Command

The most straightforward method to extract a .gz file is using the gunzip command. Here’s how:

  1. Open the Terminal: Access the terminal through your Linux interface.
  2. Navigate to the File Directory: Use the cd command to navigate to the directory containing your .gz file.
  3. Run the gunzip Command: Type gunzip filename.gz. This will extract the file and create a new file without the .gz extension.
    gunzip filename.gz 
    

    How to Extract .GZ File
    Extracting a .GZ File

3. Using the gzip Command

Alternatively, you can use the gzip command with the -d flag, which stands for ‘decompress’. The command looks like this:

gzip -d filename.gz 

4. Extracting .tar.gz Files

Extracting .tar.gz files in Linux is a common task, as this format is frequently used for distributing applications and transferring files. The .tar.gz extension indicates that the file is a TAR archive compressed using the gzip compression algorithm.

For .tar.gz files, use the tar command:

tar -xzf filename.tar.gz 

Here, -x stands for extract, -z tells tar to uncompress the archive (as it’s gzipped), and -f specifies the filename.

Conclusion

Extracting .GZ files in Linux is a skill that can significantly streamline your work and data management. With the techniques outlined in this guide, extracting .GZ files should no longer be a daunting task. As you continue to work with Linux, these skills will not only help you manage compressed files better but also boost your confidence in handling various file formats.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top