Learn to compress and decompress files at the Linux command line.
Linux xz command summary with examples (3:56)
Videos can also be accessed from the YouTube Playlist.
Our seventy-first word, or command to memorize is
xz from our category
xz allows you to compress and
Recall from the three videos on
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).
xz command has
over 30 options and the argument is the file or list
to process, for files with extensions .xz or
Like most commands, help is available with double-dash
-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
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
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
And compression says 0.344, which is equivalent to 65.6%, compared to,
what was it?
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
And you know the syntax for commands, options and arguments.
One last tip about the
command. So it's good that there are similarities across compression
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
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
As always, reach us on social media, including our YouTube Channel. Here's the easiest way to subscribe.
bzip2command, hit Back.
zipcommand, click Next.