How to Unzip or Open Gz File in Linux

1 min

In this tutorial, we will explain how to unzip or open gz file in Linux as part of the Linux commands series.

Gzip is a widely used algorithm that compresses files while retaining original properties, commonly applied to speed up web page loading.

Files those compressed with gzip ends with extension .gz or .z.

In this article, you will learn how to unzip or open .gz files.

Unzipping gz File

You can unzip a .gz file using the gzip utility in Linux. The syntax is as follows:

gzip -d my_file.gz

The above command will unzip the file and remove the source .gz file.

If you want to keep the compressed file use the -k switch to the command:

gzip -dk my_file.gz

There is another command which you can try to unzip a .gz file is gunzip. Internally it executes gzip -d command. You can use the following same command with gunzip.

gunzip my_file.gz

If you are comfortable using desktop environments in Linux, you can use the “Extract” option in the context menu of any common file manager. If you are a Windows user, you can download and install 7zip to extract gz files.

Extracting tar.gz File

The most common type of archive is tar.gz file which you encounter in Linux. You can extract a tar.gz file using the tar command with -xf option with the file name. Here’s a common example:

tar -xf my_archive.tar.gz

The command will identify the compression type and will extract the archive in the current working directory in your terminal.


To summarize, use gunzip to open a .gz file. You can also use the tar command to unzip tar.gz files.


Creator and author of Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments