How to Unzip (Extract) Gz File in Linux

Updated on

2 min read

Unzip Gz File

Gzip is a popular compression algorithm used to reduce file sizes while maintaining original mode, ownership, and timestamp. It is commonly used to compress web content to speed up page loading.

By convention, a file compressed with gzip ends with either .gz or .z.

This article explains how to extract (or unzip) .gz files.

Unzipping gz File

On Linux and macOS, you can use the gzip utility to decompress a .gz file. The syntax is as follows:

gzip -d file.gz

The command will restore the compressed file to its original state and remove the .gz file.

If you want to keep the compressed file, pass the -k option to the command:

gzip -dk file.gz

Another command that you can use to decompress a .gz file is gunzip . This command is a convenience alias to gzip -d.

To open a .gz file with gunzip simply provide the file name to the command:

gunzip file.gz

If you’re a desktop user and you are not comfortable with the command-line interface, you can use your file manager to extract .gz files. To open (unzip) a .gz file, right-click on the file you want to decompress and select “Extract”.

Windows users need to install additional software such as 7zip to open .gz files.

Extracting tar.gz File

Gzip algorithm is designed to compress only a single file.

The tar file format allows you to combine multiple files into a single archive that can be compressed with the Gzip algorithm. This results in a compressed file that is smaller in size and easier to transfer or store.

Files that end in .tar.gz are .tar archives compressed with gzip.

To extract a tar.gz file , use the tar command with the -xf options followed by the compressed archive name:

tar -xf archive.tar.gz

The command will auto-detect the compression type and will extract the archive in the current working directory .


To decompress a .gz file, use the gzip -d or gunzip command followed by the file name.

If you have any questions, please leave a comment below.