/ factorpad.com / tech / linux-essentials / gzip-command.html
An ad-free and cookie-free website.
Beginner
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
Files.
gzip
allows you to compress and
decompress files.
-options | description |
---|---|
-h ,
--help |
Print help screen |
-d ,
--decompress |
Decompress files |
-v ,
--verbose |
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)
.
The 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
gunzip
and
zcat
.
Like most commands, help is available with double-dash
--help
. The
-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 gzip
.
Notice how the file is given the extension .gz?
As it is with a program such as vim
.
Or grep
.
So it is standard for man
pages to be
compressed with gzip
. And that's good
to know.
Next, let's use that same command and create a file to compress.
Okay, let's copy video68a.txt
to
video68b.txt
.
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
video68*
.
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 -d
and that 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 gzip
.
And you know the syntax for commands, options and arguments.
One last tip about the gzip
command. So in the man
page on
gzip
. Read through it, and it details
additional functionality provided by
gunzip
and
zcat
.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the gzip
command.
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.
aptitude
command,
hit Back.gunzip
, click Next.
/ factorpad.com / tech / linux-essentials / gzip-command.html
A newly-updated free resource. Connect and refer a friend today.