FactorPad
Build a Better Process

Linux gunzip Command Summary with Examples

Linux 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.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux gunzip, 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 Tip Next

/ factorpad.com / tech / linux-essentials / gunzip-command.html


An ad-free and cookie-free website.


Examples of the Linux gunzip Command

Beginner

Learn how to unzip files at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux gunzip Command summary with Examples (3:54)

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.

Common Linux gunzip Options
-options description
-h, --help Print help screen
-k, --keep Keep input files
-l, --list List information on compressed file

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.

Demonstration

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?

If you believe that learning and financial information should be accessible to more people, then please find a way to support our cause here.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / gunzip-command.html


gunzip examples
linux gunzip
gunzip linux
gzip unzip
unzip gz file
unzip gz file linux
linux unzip gz
unzip gz
gzip compression
open gz file
extract gz
gzip example
decompress files

A newly-updated free resource. Connect and refer a friend today.