How To Use Gunzip Command.
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 .gz or .z extension.
In this tutorial, we will explain how to use the gunzip command.
Decompressing Files with gunzip
The general syntax for the gunzip command is as follows:
On most Linux distributions, such as Ubuntu, CentOS, and Debian, gunzip is a bash script wrapper to the gzip -d command.
All gzip command line options are applicable gunzip.
To decompress a .gz file with 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:
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:
The gunzip command also accept multiple files as arguments:
To recursively decompresses all files in a given directory, use the -r option:
List the Compressed File Contents
When used with the -l option, gunzip shows information about the given compressed files:
The output will include the uncompressed file name, the compressed and uncompressed size, and the compression ratio:
For more verbose output, use the -v option:
The gunzip command allows you to decompress .gz files.