• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

gunzip Command Examples in Linux

by admin

The gzip program is used to compress one or more files. When executed, it replaces the original file with a compressed version of the original. The corresponding gunzip program is used to restore compressed files to their original, uncompressed form. Here is an example:

$ ls -l /etc > foo.txt
$ ls -l foo.*
-rw-r--r-- 1 me    me     15738 2012-10-14 07:15 foo.txt
$ gzip foo.txt
$ ls -l foo.*
-rw-r--r-- 1 me    me    3230 2012-10-14 07:15 foo.txt.gz
$ gunzip foo.txt
$ ls -l foo.*
-rw-r--r-- 1 me    me     15738 2012-10-14 07:15 foo.txt

In this example, we create a text file named foo.txt from a directory listing. Next, we run gzip, which replaces the original file with a compressed version named foo.txt.gz. In the directory listing of foo.*, we see that the original file has been replaced with the compressed version and that the compressed version is about one-fifth the size of the original. We can also see that the compressed file has the same permissions and time stamp as the original.

Next, we run the gunzip program to uncompress the file. Afterward, we can see that the compressed version of the file has been replaced with the original, again with the permissions and timestamp preserved.

gunzip Command Examples

1. To unzip any compressed file:

# gunzip file.gz

2. To get the License information:

# gunzip -L
# gunzip --license

3. To test the zipped files integrity:

# gunzip -t file.gz
# gunzip --test file.gz

4. To list the compressed files information:

# gunzip -l file.gz
# gunzip --list file.gz

5. To save the original name or server time stamp:

# gunzip -N file.gz
# gunzip --name file.gz

6. To operate in verbose mode:

# gunzip -v file.gz
# gunzip --verbose file.gz

7. To get the version info:

# gunzip -V
# gunzip --version

8. To get the better decompression:

# gunzip -9 file.gz
# gunzip --best file.gz

9. To get the faster decompression:

# gunzip -1 file.gz
# gunzip --faster file.gz

10. To read zipped file contents:

# gunzip -c file.gz

Filed Under: Linux

Some more articles you might also be interested in …

  1. What is HBA Queue Depth and How to Check the Current Queue Depth Value and how to Change it
  2. cut: command not found
  3. a2enconf Command Examples in Linux
  4. How to add swap space in linux
  5. atrm Command Examples in Linux
  6. How to Disable Ctrl+c or Ctrl+z Using the “trap” Command in Linux
  7. paste Command Examples in Linux
  8. certbot: command not found
  9. arch-chroot: command not found
  10. iotop Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright