Faster Learning Tutorials

Linux gunzip command summary with examples

gunzip allows you to decompress files.
  1. Purpose - Learn what gunzip is for an how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with gunzip.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, November 5, 2016
Updated: July 23, 2018
In this tutorial, 69 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / gunzip command

The Linux gunzip command


Learn how to unzip files at the Linux command line.

Video Tutorial

Linux gunzip command summary with examples (3:54)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our sixty-ninth word, or command to memorize is gunzip from our category Files.

gunzip allows you to decompress files.

Recall from the last video on gzip we compressed a file, and now we'll focus on a tool that not only decompresses .gz files but other formats as well.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The gunzip command has 14 options and the argument is the file or list to decompress.

Like most commands, help is available with double-dash --help. The -k option keeps the input file and -l shows file details.

So why is gunzip an important command? Well, at times you're given compressed files in a variety of formats and you need to decompress them. And now you know how to do that.


Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. As in the last video, do a man command on gunzip and write it to a file video69a.txt.

$ man gunzip > video69a.txt

Then copy it and this will take a second to gzip that new file video69b.txt.

$ cp video69a.txt video69b.txt $ gzip video69b.txt

Then ls -og on video69* to see what we have.

$ ls -og video69* -rw-r--r-- 1 17752 Nov 5 19:15 video69a.txt -rw-r--r-- 1 6366 Nov 5 19:15 video69b.txt.gz

And there's a compressed file. Next, use gunzip -l on video69b.txt.gz, to see the stats and contents as well.

$ gunzip -l video69b.txt.gz compressed uncompressed ratio uncompressed_name 6366 17752 64.3% video69b.txt

Now, you may ask, if gzip -d from the last video decompresses files, then why do we need to learn gunzip? Well that's a good question, because gunzip can also unzip additional file formats, which we will see in coming videos.

And last, let's use the gunzip -k option, keeping the old file.

$ gunzip -k video69b.txt.gz $ ls -og video69* -rw-r--r-- 1 17752 Nov 5 19:15 video69a.txt -rw-r--r-- 1 17752 Nov 5 19:15 video69b.txt -rw-r--r-- 1 6366 Nov 5 19:15 video69b.txt.gz

And then ls -og and we should see 3 videos for this video 69, right?

A Final Tip

Okay now you know how to use gunzip. And you know the syntax for commands, options and arguments.

One last tip about the gunzip command. So again, you'll have to spend time in the man page on gzip and gunzip, which are actually the same page. And then also tune in for the next video or two, where we'll see other compression tools.

Okay, thanks for visiting today. I hope this was a helpful introduction to the gunzip command.

Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:

What's Next?

Have questions? Reach out to us on our YouTube Channel. Here's one of those subscription buttons.

  • To see the Outline of all 100 tutorials, click Outline.
  • To go back to the gzip command, hit Back.
  • To try out another compression tool bzip2 and see if it improves on the compression statistics, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / gunzip command

Linux gunzip command
gunzip Linux
unzip gz file
decompress files
decompress directories
decompress multiple formats
compression algorithm
open gz file
extract gz
gzip example
file compression