How To Unzip/Extract Gz File In Linux?

Gzip is a popular compression algorithm and tool used to compress files to reduce file sizes? The gzip compression is very popular in Linux and Unix-based operating systems and distributions. The gzip files generally have the *.gz or *.z extension. In this tutorial, we explain how to extract or unzip the gzip files by using different commands like gzip , gunzip and zcat .

List gz File Contents

Before unzipping or extracting the gz file we generally list the file contents or files and folders. The gzip command is used to list gz file contents. The -l option is provided like below.

$ gzip -l blender-2.80.tar.gz
List gz File Contents

Unzip gz File

The gz file can be unzipped by using the gzip command. The gzip command is provided by popular Linux distributions Ubuntu, Kali, Mint, Fedora, CentOS, and MacOSX, etc. The decompress option is -d to unzip gz files. By default, the gz file is deleted after unzipping it.

$ gzip -d blender-2.80.tar.gz

Keep Unzipped gz File

By defualt after unzipping the gz file the gz file is deleted automatically. But we can prevent this removal by using the -k option which preserves the gz file after decompression.

$ gzip -d -k blender-2.80.tar.gz

Unzip gz File with gunzip Command

The gunzip command can be also used to unzip the gz file. Actually the gunzip is the the gzip command with some decompression options. But it is easier to remember and easy to used as we do not need to provide any option. We just provide the gz file name and the file is unzipped.

$ gunzip < blender-2.80.tar.gz > blender.tar

Unzip gz File with zcat Command

The zcat is a comprassion command which is created for z compression. But it also supports other compression algorithms like gzip and gz files. We can use the zcat command in order to unzip the gz file. The zcat command

$ zcat blender-2.80.tar.gz > blender.tar

Leave a Comment