How to Use the gunzip Command in Linux

Gunzip is a command-line tool for decompressing Gzip files.
Gzip is one of the most popular compression algorithms that reduces the size of a file while preserving the original ownership, permissions, and timestamps.
By convention, files compressed with Gzip are given either the .gz or .z extension.
In this article, we will explain how to use the gunzip command.
Basic Syntax
The general syntax for the gunzip command is as follows:
gunzip [OPTION]... [FILE]...On most Linux distributions, such as Ubuntu, CentOS, and Debian, gunzip is a Bash script that calls the gzip -d
command.
All gzip command-line options work with gunzip as well.
Decompressing Files with gunzip
To decompress a .gz file
with gunzip, pass the compressed file name as an argument:
gunzip filename.gzThe command will restore the compressed file to its original name, owner, mode, and timestamp.
By default, once decompressed, gunzip will remove the compressed file. Use the -k option to keep the file:
gunzip -k filename.gzTo write the output on the terminal, use the -c option. This allows you to keep the compressed file and optionally decompress it to another location:
gunzip -c filename.gz > /directory/path/filenameThe gunzip command also accepts multiple files as arguments:
gunzip file1.gz file2.gz file3.gzTo recursively decompress all files in a given directory, use the -r option:
gunzip -r directoryList the Compressed File Contents
When used with the -l option, gunzip shows information about the given compressed files:
gunzip -l filename.gzThe output will include the uncompressed file name, the compressed and uncompressed size, and the compression ratio:
compressed uncompressed ratio uncompressed_name
146 141 9.2% filenameFor more verbose output (compression method, CRC, timestamp, etc.), use the -v option:
gunzip -lv filenamemethod crc date time compressed uncompressed ratio uncompressed_name
defla 4a4a3fb5 Aug 29 15:40 146 141 9.2% filenameReference Table
Conclusion
The gunzip command is a powerful tool for decompressing .gz files. You can use it to extract a single archive, inspect its contents, or decompress multiple files at once.
For more information about the gunzip command, visit the GNU gzip documentation page
.
Questions? Feel free to drop a comment below!
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page