Working with XZ (Lossless Data Compression) Tool in Linux

XZ is another general purpose data compression tool with command line syntax similar to gzip and bzip2. xz compresses or decompresses each file according to the selected operation mode. It supports different formats to compress or decompress files.

XZ Command Examples in Linux

To create a compressed file you just need to use -z or –compress flag as follows. Keep in mind that it wont keep the input file.

$  xz  -z  file
    output will be:  file.xz

xz-create-compressed-file
xz-create-compressed-file

If you wan to keep the input file you can make use of option -k or –keep as follows.

$ xz  -zk  file
   output will be: file.xz  and input file will be saved.

xz-keep-input-files
xz-keep-input-files

To decompress the file you can use -d option or unxz utility.

$ xz  -d  file.xz
or
$ unxz  file.xz

xz-decompress-file
xz-decompress-file

if an operation fails, for instance a compressed file with same name exists, you can use the -f option to force the process.

$  xz  -zkf  file

There is also an option to specify the level of compression to be used. The compression level varies between 0 to 9 and the default is 6.
you can also specify –fast (least compression ratio) to compress fast or –best (highest compression ratio) but slower compression.

$  xz  -k  –fast  file
or
$  xz   -k  –best  file

Following is an example of using tar archiving utility with xz.

$  tar  -cJf  txt_files.tar.xz   *.txt

Finally, you can check the integrity of the compressed file using -t option and you can also display information using -l option.

$  xz  -t  txt_files.tar.xz

$  xz  -l  txt_files.tar.xz

XZ is powerful and so far the best compression tools available for Linux. In this tutorial we had a look at multiple examples on how to use xz. Use to comment section below to ask any question or to provide feedback.

1,221 Replies to “Working with XZ (Lossless Data Compression) Tool in Linux”

  1. I’ve been surfing on-line more than 3 hours today,
    but I by no means found any attention-grabbing article like yours.
    It is pretty worth enough for me. In my view, if all site owners and bloggers made excellent content material as you did,
    the internet will likely be a lot more useful than ever before.

  2. Hi, I do think this is a great website. I stumbledupon it 😉 I am going to return yet again since i have saved as a favorite it.
    Money and freedom is the best way to change, may you be rich and continue
    to help other people.

  3. I’ve been surfing online more than 4 hours today, yet I never found any interesting article
    like yours. It is pretty worth enough for me.
    In my opinion, if all web owners and bloggers made good content as you did, the internet will be much more useful than ever before.

  4. It is the best time to make some plans for the future and it is time to be
    happy. I’ve read this post and if I may just I desire to suggest you
    some fascinating issues or suggestions. Perhaps you can write next articles regarding this article.
    I desire to read even more things approximately it!

  5. Someone necessarily assist to make seriously articles I’d state.
    This is the first time I frequented your web page and so
    far? I amazed with the research you made to make this particular publish incredible.

    Fantastic process!

  6. Hmm it seems like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to the whole thing. Do you have any tips for inexperienced blog writers? I’d really appreciate it.| а

  7. It is perfect time to make some plans for the future and it’s time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Maybe you can write next articles referring to this article. I want to read more things about it!| а

  8. I do accept as true with all of the ideas you have introduced for your post. They’re really convincing and can definitely work. Nonetheless, the posts are too brief for novices. Could you please lengthen them a little from next time? Thank you for the post.| а

  9. First of all I would like to say awesome blog! I had a quick question in which I’d like to ask if you don’t mind. I was curious to find out how you center yourself and clear your head before writing. I’ve had difficulty clearing my thoughts in getting my thoughts out. I truly do enjoy writing however it just seems like the first 10 to 15 minutes tend to be lost just trying to figure out how to begin. Any ideas or hints? Appreciate it!| а

  10. Heya! I realize this is sort of off-topic but I had to ask. Does building a well-established website such as yours require a massive amount work? I’m brand new to running a blog however I do write in my journal every day. I’d like to start a blog so I can easily share my own experience and views online. Please let me know if you have any recommendations or tips for brand new aspiring bloggers. Thankyou!| а

  11. Woah! I’m really loving the template/theme of this blog. It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between user friendliness and appearance. I must say you’ve done a very good job with this. Additionally, the blog loads very fast for me on Safari. Superb Blog!| а

  12. Greetings from California! I’m bored at work so I decided to browse your blog on my iphone during lunch break. I really like the knowledge you present here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyways, very good blog!| а

  13. What i do not understood is in reality how you’re now not actually much more well-appreciated than you may be now. You’re very intelligent. You recognize therefore significantly in the case of this subject, produced me for my part imagine it from numerous numerous angles. Its like women and men aren’t involved unless it’s one thing to accomplish with Lady gaga! Your personal stuffs outstanding. All the time take care of it up!| а

  14. With havin so much content and articles do you ever run into any issues of plagorism or copyright infringement? My website has a lot of unique content I’ve either created myself or outsourced but it looks like a lot of it is popping it up all over the web without my authorization. Do you know any techniques to help reduce content from being ripped off? I’d truly appreciate it.| а

  15. First off I want to say wonderful blog! I had a quick question that I’d like to ask if you don’t mind. I was interested to know how you center yourself and clear your mind before writing. I’ve had a hard time clearing my mind in getting my ideas out. I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes are generally wasted simply just trying to figure out how to begin. Any recommendations or tips? Cheers!| а