CentOS Debian Manjaro Mint openSUSE Red Hat Ubuntu

How to Unzip the gz Files in Linux


Gzip is a widely used compression technique and tool for reducing the size of data. In Linux and Unix-based operating distributions, gzip compression is widely popular. The extension of gzip files is usually *.gz or *.z. In this article, we’ll show you how to extract or unzip gzip files using commands like gzip, gunzip, and zcat.

Unzip gz file in Linux

In Linux, there are two methods for unzipping your gz file:

  • Compressing and decompressing gz files using the Command-Line Interface
  • Compressing and decompressing gz files using the GUI method (Graphical User Interface)

The detailed description of both methods is stated below:

Method 1: Compressing and Decompressing Files Using a Command Line Interface

Before unzipping the gz file, you have to compress the file using the gzip command.

Compressing files

Gzip is a widely used compression method that preserves the original file mode, ownership, and date while compressing a file. Gzip also refers to the.gz file format, as well as the gzip tool for compressing and decompressing files.

Use the below-mentioned command to compress a single file:

$ gzip filename

The gzip creates a file named filename.gz and deletes the original.

By default, in a compressed file, gzip command saves the timestamp, ownership, and name of the original file.

Listing the contents of the gz file

We usually list the file contents, or files and directories, before unzipping or extracting the gz file. To view the list of contents of a gz file, you can use the gzip command. The -l option is available, as seen below:

$ gzip –l test.txt.gz

Unzip the gz archive

To unzip the gz file, you can use the gzip command. Popular Linux distributions such as Ubuntu, Kali, Mint, Fedora, CentOS, and MacOSX, among others, have the gzip command. To unzip gz files, use the -d decompress option. After unzipping, the gz file is erased by default:

$ gzip –d test.txt.gz

Keep the unzipped gz file

By default, when unzipping a gz file, the gz file is automatically erased. However, we can avoid this by specifying the -k option, which keeps the gz file after decompression.

$ gzip –d –k test.txt.gz

Decompress gz files using the gunzip command

The gz file can also be unzipped using the gunzip command. Gunzip is the gzip command with various decompression parameters added. However, because we do not need to supply any options, they are easier to know and utilize. The file is unzipped after we enter the gz file name.

$ gunzip test.txt.gz

Decompress gz file using the zcat command

The zcat command is a compression command designed for z compression. Other compression techniques, such as gzip and gz files, are also supported. To unzip the gz file, we can use the zcat command. The zcat command is a command that allows you to see what’s.

$ zcat test.txt.gz

Method 2: Compressing and decompressing files using the GUI Approach

Graphical desktop environments have everything you need if you don’t want to work in a terminal. In Gnome’s Files application, right-click the file that you want to zip and then select the Compress option.

Control-click the directories and/or files you wish to archive and compress, then right-click and choose “Compress.”

The file manager will prompt you to select a format. If you choose .zip, the zipped file will be straightforward to open on any operating system. You can also make advantage of .tar.xz or .7z, but you’ll need the necessary software on your Windows or Mac computer to do it.

Right-click the zipped file in Files again if you need to open it. You can select one of options provided in the drop-down menu. These options are: Open with Archive Manager, Extract Here, and Extract To.

Although the archive manager provides more alternatives, you’ll most likely want to utilize Extract here or Extract to.


This article will provide a fundamental understanding of gz files, their compression, and their decompression methods. This article also covers the two distinct methods for unzipping your gz file under Linux. These methods include command line and graphical user interface (GUI) approaches.

Similar Posts