How to use ‘tar’ command to Extract .xz file packages in Linux?

If you are a regular reader at Techglimpse, then you might have read our article on How to extract .xz file packages in Linux. Well, that tutorial was primarily aimed at installing XZ utils to read .xz file packages in Linux. But you can also use ‘tar‘ command to read and extract .xz files. To do that, you need to have a ‘tar‘ command that supports .xz file formats.

For example, assume that you have tar version 1.15.1, then surely it’s not going to help you un-compress .xz files.

Check the version of tar as below:

#tar --version
tar (GNU tar) 1.15.1

Try extracting .xz file package – Assume you want to extract Python source package.

# tar xf Python-3.5.0.tar.xz
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: Read 1420 bytes from Python-3.5.0.tar.xz
tar: Error exit delayed from previous errors

So, let us install latest version of tar command.

tar xz files

How to use ‘tar’ command to extract .xz file format

You can install ‘tar‘ via yum or by compiling it from source.

Update ‘tar‘ using yum

# yum update tar

In case if ‘yum update‘ shows below message, then you need to compile it from source.

# yum update tar
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * elrepo: hkg.mirror.rackspace.com
 * epel: epel.mirror.net.in
 * extras: centos.excellmedia.net
 * remi: remi.mirrors.arminco.com
 * remi-php55: remi.mirrors.arminco.com
 * updates: centos.excellmedia.net
Skipping security plugin, no data
Setting up Update Process
No Packages marked for Update

Compiling ‘tar’ from source

1. Download latest version of ‘tar‘ from here.

2. Extract the downloaded ‘tar’ package

# tar xvzf tar-latest.tar.gz
# cd tar-1.28/
#./configure
# make
# make install

Are you getting this error message during ‘make’?

"Dwarf Error: found dwarf version ‘4’, this reader only handles version 2 information"

Solution: Check this guide for the solution.

Once installed, check the version of the tar and try extracting the ‘.xz‘ files as below:

$ /usr/local/bin/tar --version
tar (GNU tar) 1.28

Extract .xz file formats using tar

$tar xf Python-3.5.0.tar.xz
Guess?

It’s time to guess now, How do you extract .7z package in Linux?

Updated on September 27, 2017

Was this article helpful?

Related Articles

Leave a Comment