Home » Linux Support » How to Extract tar xz File in Linux
extractz tar file

How to Extract tar xz File in Linux

n this brief guide, we will look at how you can compress and extract tar xz tarball files/directories with a .tar.xzfile extension in Linux.

The xz format is a single-file compression format that is based on the LZMA2 algorithm. It offers lossless compression, implying that it keeps the original data without compromising on its quality. This makes it ideal for shipping software application and image files. The xz compression is much slower but its decompression is quite fast.

Before we begin compressing or uncompressing files, first ensure that xz tools are installed. Newer Linux distributions come with xz tools already installed. However, if xz tools are missing, install using the following commands.

Install xz-utils on Debian/Ubuntu

To install xz tools in Ubuntu and Debian distros, run the command below

sudo apt install xz-utils

Output

install xz-utils

Install xz tool on CentOS/RHEL

For CentOS and RedHat distributions run

yum install xz

Output

yum install xz

Install xz tool on Fedora

For Fedora systems run

dnf install xz

Output

dnf install xz

How to Create xz compressed file

In this example, we are going to compress a directory data containing a few files

mkdir data and create files

To compress the directory, execute the command below

tar -cjcf data.tar.xz data/

You can confirm the creation of a .tar.xz file using the ls command as shown

Output

create tar xz file from a directory

How to extract/unzip xz tar file

To uncompress the xz tarball we just created, execute the command below

tar -xvf data.tar.xz

Output

extract tar xz file

As seen above, the command is the same as extracting a .tar.gz file

This short article illustrates how you can proceed to compress and unzip xz tarball files in Linux on the command line. Feel free to try out the commands and let us know how it went. Thanks!

Read Also:

  • 16 Tar Commands to Compress and Extract Files in Linux
x

Check Also

Kernel Panic on Boot

Best of Technical Support Various Issue #87, July 2001 Our experts answer your technical questions. ...