How to extract xz archive in RHEL 5

I am unable to extract an xz tarball in RHEL 5.

# tar Jxvf my_archive.tar.xz
tar: invalid option -- J
Try `tar --help' or `tar --usage' for more information.
# tar --version
tar (GNU tar) 1.15.1

Use unxz to uncompress the file and extract it with tar xvf

unxz my_archive.tar.xz
tar xvf my_archive.tar

In RHEL 6 and 7, you can use tar Jxvf or just xvf. Newer tar can auto detect the format.

tar Jxvf my_archive.tar.xz

OR

tar xvf my_archive.tar.xz

# tar --version
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Support for xz compression was added to tar 1.22

wget http://ftp.gnu.org/gnu/tar/tar-1.22.tar.gz
tar zxvf tar-1.22.tar.gz
cat tar-1.22/NEWS
* Support for xz compression

Tar uses xz for compression if one of the following conditions is met:

 1. The option --xz or -J (see below) is used.
 2. The xz binary is set as compressor using --use-compress-program option.
 3. The file name of the archive being created ends in `.xz' and
 auto-compress option (-a) is used.

Xz is used for decompression if one of the following conditions is met:

 1. The option --xz or -J is used.
 2. The xz binary is set as compressor using --use-compress-program option.
 3. The file is recognized as xz compressed stream data.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s