How to extract XZ compressed archive on Linux

XZ is another compression method used to compress data. There are several ways on how to decompress XZ archive on Linux. For a tarball XZ compressed archive first try a tar command with xf options. This way a tar command will try automatically guess a compression method. Before you run the above command firs install XZ tools:

# apt-get install xz-utils

Otherwise, you will receive error message output:

tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

To extract XZ tarball run:

$ tar xf myarchive.tar.xz

If from some reason tar command fails to detect a correct decompression method use J directly specify XZ compression:

$ tar xJf myarchive.tar.xz

Next, solutions is to use XZ decompression tool unxz. It will first decompress XZ compression and leave you with a uncompressed tarball:

$ unxz myarchive.tar.xz
$ ls
 myarchive.tar

Of course the last XZ decompression method will work not only for tarball but for any other XZ compressed data.



Comments and Discussions
Linux Forum