An ad-free and cookie-free website.
Learn to compress and decompress files at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux gzip Command Summary with Examples (4:01)
Our sixty-eighth word, or command to memorize is
gzip from our category
gzip allows you to compress and
||Print help screen|
||Report percent reduction in file size|
Recall from the last four videos on software packages and most are compressed, so now we'll focus our attention on file compression.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
gzip command has
18 options and the argument is the file or list to
compress. Several data compression algorithms exist, so it may get
confusing. And then also note that related commands include
Like most commands, help is available with double-dash
-d option decompresses files and
-v shows percent reduction.
So why is
gzip an important command?
Well, bandwidth and resources are limited, so getting to know how
compression works is vital.
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. Start with a
man command with a
--where to search for the location
of manual pages for the program
Notice how the file is given the extension .gz?
As it is with a program such as
So it is standard for
man pages to be
gzip. And that's good
Next, let's use that same command and create a file to compress.
Okay, let's copy
And there's a different way to do this of course, but I just wanted to
go through this illustration. Then
gzip -v video68b.txt.
And then do an
ls -og on
And then, notice how the size changed here, so notice the difference and it replaced the old file with the new.
And last, let's decompress with
ls -og video68* again.
So the takeaway here should be that, by default,
gzip compresses files in place.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
command. So in the
man page on
gzip. Read through it, and it details
additional functionality provided by
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you learned something today, please consider subscribing, following, joining and contributing to our group of smart folks who just get it.
aptitudecommand, hit Back.
gunzip, click Next.
A newly-updated free resource. Connect and refer a friend today.