How to Open a GZ File in Linux

There are various tools to compress any file to minimize its size for saving storage. GZ files are squeezed through the “GZIP” tool, which is a little bit similar to the zip file. GZIP is one of the most popular compression programs that decrease any file size while keeping the original timestamp, ownership, and file mode. Generally, this compression is used for compressing the web elements to reduce the load time of webpages. However, many people don’t know how to open a GZ file; we will cover complete details on opening a GZ file in Linux.

How to Open a GZ File in Linux

There is a specific process to open a GZ file in Linux, so here is the step-by-step procedure to open it from the terminal:

First, unzip the GZ file using the Linux terminal by “-d” Flag; to do this, open the terminal and execute the following command:

$ gzip -d FileName.gz

Once you execute the command, the system starts to restore all of the files in their original format. This “-d” Flag will replace the GZ file with the extracted file.

In case you don’t want to replace the GZ file with the extracted file, then you can use the “-dk” flag by executing the following command:

$ gzip -dk FileName.gz

There is another command line that is similar to the “-d” Flag, but it requires the gunzip command so execute the following command for it:

$ gunzip FileName.gz

Note: In the above commands, “FileName” stands for the name of the GZ file, so make sure to replace it with your file’s name instead.

The “tar” files end with.tar.gz, which are compressed .tar archive, execute the following command in the terminal to extract “tar” files.

$ tar -xf archive.tar.gz

Once you execute the command successfully, the system will start to detect the current archive extraction.


That concludes the complete information GZ file and how one can extract and open GZ file easily on your Linux system. We have included four different methods to extract GZ files without having any errors. These methods are tried and tested on various Linux machines, so you can use these methods on your Linux system without facing issues.

About the author

Simran Kaur

Simran Kaur

Simran works as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Travelling, sketching, and gardening are the hobbies that interest her.