• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Gunzip Command in Linux

Written by Admin, Updated On October 25, 2020
gzip, terminal
Gunzip Command in Linux

Using Gunzip command-line tool you can decompressing Gzip files. Gzip is the popular compression algorithms to reduce the size of a file and keep the original file mode, ownership, and timestamp. In this tutorial, we will show you how to use the gunzip command.

Decompressing Files with gunzip#

Below is the basic syntax for the gunzip command:

gunzip [OPTION]... [FILE]...

The gunzip is a bash script wrapper to the gzip -d command in most Linux distributions, such as Ubuntu, CentOS, and Debian.

All gzip command line options are applicable gunzip. You can decompress a .gz file with gunzip by passing compressed file name:

gunzip filename.gz

It will restore the compressed file to its original name, owner, mode and timestamp.

After decompress, by default, gunzip will remove the compressed file. You can use the -k option to keep the file:

gunzip -k filename.gz

Use the -c option to write the output on the terminal.

gunzip -c filename.gz > /directory/path/filename

You can pass the multiple files as arguments with the gunzip command:

gunzip file1.gz file2.gz file3.gz

To recursively decompresses all files in a given directory, use the -r option:

gunzip -r directory

List the Compressed File Contents#

Use the -l option with gunzip, to show information about the given compressed files:

gunzip -l filename.gz

In output, it will show the uncompressed file name, the compressed and uncompressed size, and the compression ratio:

compressed        uncompressed  ratio uncompressed_name
       246                 282   8.2% filename

For more verbose output, use the -v option:

gunzip -lv filename
method  crc     date  time           compressed        uncompressed  ratio uncompressed_name
defla 8afa3fs5 Oct 24 11:40                 246                 282   8.2% filename

Conclusion#

The gunzip command is used to decompress .gz files. To learn more about the gunzip command, visit the Gnu gzip documentation page.

If you have any questions, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Compare Strings in Bash
Next Article   Bash Sequence Expression (Range)

Related Posts

  • How to Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 20.04 February 14, 2021
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook