> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Using gunzip Command in Linux
- URL: https://linuxhandbook.com/gunzip-command/
- Published: 2023-01-24T06:32:55.000Z
- Updated: 2023-01-24T06:32:55.000Z
- Description: Learn to use the gunzip command in Linux with these practical examples.
- Author: Sagar Sharma
- Tags: Commands

Got a .gz file? It is a gzip-compressed archive file. Gzip reduces the file size better than the simple zip archive.

Now, to unzip a file, you have the unzip command in Linux. But you cannot use it on the gzip files.

To extract a .gz file, you need gunzip command.

It has a basic syntax: 

```
gunzip <options> filename
```

Where,

- `options` are used to tweak the default behavior of the utility.
- `filename` is where you append the file for decompression.

Let me share some examples of using gunzip on Linux. 

## Decompress files using gunzip on Linux

To decompress a file, all you need to do is append the filename to the gunzip command:

```
gunzip compressed_file
```

For reference, here I want to decompress a Debian ISO file, so I will be using the following command:

```
gunzip debian-testing-amd64-DVD-1.iso.gz
```

![decompress files in linux using gunzip command](https://linuxhandbook.com/content/images/2023/01/decompress-files-in-linux-using-gunzip-command.png)

But if you notice carefully, it replaces the original file so what if you want to have both?

## Decompress files while keeping the original intact

To keep the compressed file while using the gunzip command, you will have to use the `-k` option:

```
gunzip -k compressed_file
```

![keep original compressed file intact while decopressing it](https://linuxhandbook.com/content/images/2023/01/keep-original-compressed-file-intact-while-decopressing-it.png)

And as you can clearly see, the original compressed file is as it is in addition to the decompressed file I got here.

## Unzip files recursively

Imagine that your gzipped file has other gzipped files inside it. By default, the extracted file will have zipped folders inside it.

So if you want to decompress files recursively, you can specify the directory to the gunzip command with the `-r` option:

```
gunzip -r directory_name 
```

For example, Here I want to decompress every compressed file available inside the `compressed` directory so I will be using the following:

```
gunzip -rv compressed/
```

![decompress files recursively using gunzip command in linux](https://linuxhandbook.com/content/images/2023/01/decompress-files-recursively-using-gunzip-command-in-linux.png)

And if you are curious, the additional `-v` option was used to have verbose output.

## Force decompression

While decompression, if you have the file with the same name, it will ask you whether you want to override it or not:

![file already exists; do you wish to overwrite (y or n)?](https://linuxhandbook.com/content/images/2023/01/file-already-exists--do-you-wish-to-overwrite--y-or-n--.png)

And if you want to skip that warning, you can use the `-f` option to proceed for forceful decompression:

```
gunzip -f compressed_file
```

![Force decompression using the gunzip command in Linux](https://linuxhandbook.com/content/images/2023/01/Force-decompression-using-the-gunzip-command-in-Linux.png)

As you can see, when I used the `-f` option, it skipped the question part. A good solution if you are writing a script!

## But wait! What about the unzip command?

Well, we have already covered how you can use unzip command with practical examples:

[Unzip command in Linux: 8 Practical ExamplesGot a zip file in the terminal? Learn how to use the unzip command in Linux with these practical examples.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2020/06/unzip-command.png)](https://linuxhandbook.com/unzip-command/)

What's the difference between unzip and gunzip you may ask?

Well, in the most simple terms, [the unzip command](https://linuxhandbook.com/unzip-command/) is used to extract files with `.zip` extensions.

Whereas the gunzip command is used to deal with archives ending with `.gz`, `.tar`, etc. 

I hope you will find this guide helpful and if you have any queries, let me know in the comments.