/ factorpad.com / tech / linux-essentials / xz-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 YouTube Linux Essentials Playlist on YouTube.
Linux xz Command Summary with Examples (3:56)
Our seventy-first word, or command to memorize is
xz
from our category
Files.
xz
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 three videos on gzip
,
gunzip
, and
bzip2
, we've been evaluating
compression algorithms and noting some consistencies between their
usage. Now without going too deep, I'll introduce another.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The xz
command has
over 30 options and the argument is the file or list
to process, for files with extensions .xz or
.lzma.
Like most commands, help is available with double-dash
--help
,
-d
decompresses and
-v
shows file compression details.
So why is xz
an important command?
Well, if your organization compresses files with .xz
or .lzma extensions then you need to be able to
handle 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. First I'll take you to the
man
page for
xz
for a quick point.
Notice in the synopsis here, all 5 of these commands are covered in
this one man page and all have these
xz
equivalents, which can be
confusing. (Hit
q
to quit)
Next, for consistency across videos, let's copy that same file
video69b.txt
and call it
video71.txt
, and compress it with
xz -v
And compression says 0.344, which is equivalent to 65.6%, compared to,
what was it?
64% for gzip
and 67% for
bzip2
. For some this is a meaningful
difference but for most it isn't.
And last, let's decompress using
xz -dk
on
video71.txt.xz
, keeping the old
file, and an ls -og video71*
and like
before we should see two files.
Okay now you know how to use xz
.
And you know the syntax for commands, options and arguments.
One last tip about the xz
command. So it's good that there are similarities across compression
choices,
however, many related commands do the same thing as we saw in the
man
command. So I advise, if
possible select one and stick with it.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the xz
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Don't miss new content, join, follow and subscribe.
bzip2
command,
hit Back.zip
command, click Next./ factorpad.com / tech / linux-essentials / xz-command.html
A newly-updated free resource. Connect and refer a friend today.