Home > Archive/Compression > gunzip

gunzip Command Guide: Decompressing gzip Files

The `gunzip` command is used to decompress files with the `.gz` extension that were compressed with `gzip`. It performs the same function as the `gzip -d` command and is used to restore a compressed file to its original state. Use this guide to learn the basics of `gunzip` and its useful options.

gunzip Overview

`gunzip` is a utility included in the `gzip` package, primarily used for decompressing a single file with the `.gz` extension. Just as the default behavior of `gzip` is to delete the original file and keep the compressed file, the default behavior of `gunzip` is to delete the compressed file and keep the decompressed original file. Therefore, when decompressing important compressed files, you should consider the 'preserve original file' option.

Role of gunzip

The `gunzip` command is mainly used for the following purposes:

Key Applications

  • Decompressing Files: Restores the contents of a `.gz` compressed file to its original state.
  • Restoring Backup Files: Decompresses backup files compressed with `gzip` to restore data.
  • Handling Downloaded Files: Decompresses software packages or data downloaded from the internet in `.gz` format.

Key gunzip Command Options

The `gunzip` command provides options to control the decompression process, such as preserving the original file, displaying detailed information, and performing recursive operations.

1. Basic Decompression Options

2. Recursive Processing and Information Output

Generated command:

Try combining the commands.

Description:

`gunzip` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn how to effectively decompress `.gz` files with various usage examples of the `gunzip` command.

Decompressing a single `.gz` file

gunzip document.txt.gz

Decompresses `document.txt.gz` to create `document.txt`, and deletes the original `.gz` file.

Decompressing and keeping the original `.gz` file

gunzip -k log_archive.gz

Decompresses `log_archive.gz` to create `log_archive`, but does not delete the `log_archive.gz` file.

Recursively decompressing all `.gz` files in a directory

gunzip -r downloads/

Decompresses all `.gz` files in the `downloads` directory and its subdirectories.

Checking detailed information of a compressed file

gunzip -l data.csv.gz

Checks the compressed/uncompressed size and compression ratio of `data.csv.gz`. This command does not decompress the file.

Viewing decompressed content through a pipe

gunzip -c access.log.gz | less

Views the decompressed content via a pipe (|) to the `less` command without directly decompressing the file. This is useful for temporary viewing.


Same category commands