Gunzip Command in Linux
2 min read
Gunzip is a command-line tool for decompressing Gzip files.
Gzip is one of the most popular compression algorithms that reduce the size of a file and keep the original file mode, ownership, and timestamp.
By convention, files compressed with Gzip are given either the
In this tutorial, we will explain how to use the
Decompressing Files with
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 wrapper to the
gzip command line options are applicable
To decompress a
gunzip, pass the compressed file name as an argument:
The 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.gz
To 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/filename
gunzip command also accept multiple files as arguments:
gunzip file1.gz file2.gz file3.gz
To recursively decompresses all files in a given directory, use the
gunzip -r directory
List the Compressed File Contents
When used with the
gunzip shows information about the given compressed files:
gunzip -l filename.gz
The 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% filename
For more verbose output, use the
gunzip -lv filename
method crc date time compressed uncompressed ratio uncompressed_name defla 4a4a3fb5 Aug 29 15:40 146 141 9.2% filename
gunzip command allows you to decompress
For more information about the
gunzip command, visit the Gnu gzip documentation page
If you have any questions, please leave a comment below.