Extract a tar.xz file on CentOS and RedHat
This guide will show you how to extract a
tar.xz file on CentOS or RedHat, and probably other flavors of Linux as well. Traditionally compressed archive files are distributed on Linux systems as
tar.gz files which use
gzip for compression. Extracting them is as simple as passing
tar -xvf filename.tar.gz
If you try the same thing using a tar.xz file, you’ll find that it doesn’t work.
tar -xzf filename.tar.xz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error exit delayed from previous errors
On newer versions of tar, you can simply replace the
z with a
J to use the correct (de)compression library, but if you have version 1.15.1 or earlier, you’ll find that this doesn’t work either. Note that this is a capital “J” and not a lowercase “j” which would be used to specify
tar -xJf gnutls.tar.xz tar: invalid option -- J Try `tar --help' or `tar --usage' for more information.
Getting around this is as simple as using the
xz binary to first decompress the file, and then
tar to extract it. If you don’t already have it, you can install
yum -y install xz unxz filename.tar.xz tar -xf filename.tar
It works thankyou
Very good website – bookmarked
thanks , worked good
when i “unxz MPlayer-1.1.1.tar.xz”
the terminal say”no such file or directory”
There are a few things that could cause the binary to not be found. First make sure that it is installed (on CentOS run
yum remove -y xz && yum install -y xz). That should remove/reinstall
xzand set the proper file permissions and attributes, but if not make sure that the
unxzis in your page (or use the full path to the binary) and double check that it has execute permissions with
chmod +x unxz. It could also be that use are using a 32 bit binary on a 64 bit system, or vice versa.
you can do that as follows:
tar xJf filename.tar.xz // the “J” is uppercase.
You are correct – it’s mentioned in the second code section above – but unfortunately this option is not supported on `
tar` 1.15.1 or earlier. If you have one of these older version like I do on some of my legacy servers, the easiest thing to do is combine `
tar` with `