Linux Commands

Gunzip Command Tutorial

Files and folders are highly important for any operating system to work correctly. However, some files may take a lot of space, so it becomes essential to compress them accordingly. In Windows, the user needs to install a tool to compress the files, but in Linux, you can use gzip or gunzip commands.

Gunzip or gzip creates files with the suffix of gz, -gz, etc. z, -z, _z or .Z. If you also want a gunzip command tutorial, then read this guide. This guide will help you understand about gunzip commands with examples.

Let’s divide this section into two parts: first part is about compressing the files and the second part is related to decompressing files.

Gunzip Command to Compress a File

For compressing the file, use the following command in the terminal:

$ gunzip <filename>

Gunzip Command Tutorial

As you can see in the image above, we have used the command to compress the linuxhintfile.txt.

You can compress multiple files with the command given below:

$ gunzip <filename> <filename1>

Gunzip Command Tutorial

If you want to check the information available in the .gz file, then you can execute the following command:

$ gunzip -c <filename>.gz

Gunzip Command Tutorial

Here, we typed brackets in the text file so the terminal showed the above result.

You can get information about compressed files using the -l command:

$ gunzip -l <filename>

Gunzip Command Tutorial

Gunzip Command to Decompress a File

You can use the simple gunzip command to decompress the file from the terminal:

gunzip <filename>.gz

Gunzip Command Tutorial

In case you want to keep both compressed and decompressed files, then you can use -k with the command:

gunzip -k <filename>.gz

If you want to compress or decompress a file forcefully, you can use -f with the gunzip command:

gunzip -f <file-name>

To recursively decompress files using gunzip, use the -r option with the gunzip command:

gunzip -r  <filename>.gz

Valuable Tips for Gunzip Command

You can use the -h command to get the complete details about gunzip with its helpful options:

$ gunzip -h

Gunzip Command Tutorial

Use -V to get the version number and other information about the gunzip:

$ gunzip -V

Gunzip Command Tutorial

You can use the -L option with the command to get software license related information:

$ gunzip -L

Gunzip Command Tutorial


In this guide, we have explained everything about gunzip with the correct examples. We have also included all information about both compressing and decompressing the file. This guide will help you complete your task directly from the terminal by downloading no GUI tool into the system.

Leave a Reply

Your email address will not be published. Required fields are marked *