• 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 Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 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