Oct 16, 2023 4 min read

How to Extract (Unzip) tar.xz File

Extract(unzip) tar.xz files with our step-by-step tutorial.A tar.xz file is a compressed archive that combines the tar archiving format with the XZ.

Extract (Unzip) tar.xz File
Table of Contents


Before we begin talking about how to extract tar.xz file, let's briefly understand – What is a tar.xz file?

A tar.xz file is a compressed archive that combines the tar archiving format with the XZ compression algorithm. It is commonly used on Linux systems to compress and distribute files. To extract or unzip a tar.xz file, you need to follow specific steps using the appropriate tools.

You can use the tar command to create and extract tar archives. It is compatible with a wide variety of compression utilities, including gzip, bzip2, lzip, lzma, lzop, xz, and compress.

This tutorial will provide an overview of how to extract a tar.xz file in Linux, including the necessary commands and options.

Extracting tar.xz File

By default, all Linux distributions and macOS ship with tar utility pre-installed.

Use the tar command with the --extract (-x) option and the archive file name after the -f option to extract a tar.xz file:

tar -xf archive.tar.xz

tar automatically determines the archive's compression type and extracts it. The same command can be used to extract tar archives that have been compressed using other algorithms, such as .tar.gz or .tar.bz2.

Use the GUI File manager if the command line is not your thing. Simply right-click the file and choose “Extract” to extract (unzip) a tar.xz file. To extract tar.xz files, Windows users require the 7zip utility.

Using the -v option will produce a more verbose output. By selecting this option, tar will tell the terminal to show the names of the files it is extracting.

tar -xvf archive.tar.xz

The archive contents are by default extracted via tar into the current working directory. Use the --directory (-C) to extract archive files from a specific directory.

The example below demonstrates how to extract the archive's contents to the directory /home/linuxize/files:

tar -xf archive.tar.xz -C /home/linuxize/files

Extracting Specific Files from a tar.xz File

Add a list of file names to be extracted, separated by spaces, at the end of the tar.xz file to extract a specific file(s):

tar -xf archive.tar.xz file1 file2

When extracting files, you must use their precise names, including the path, as printed by tar when the --list (-t) option is used to invoke it.

Extraction of one or more directories from an archive is similar to extracting multiple files:

An error message similar to the one shown below will appear if you attempt to extract a file that does not exist in the archive:

tar -xf archive.tar.xz dir1 dir2
tar -xf archive.tar.xz README

tar: README: Not found in archive
tar: Exiting with failure status due to previous errors

You can use a wildcard pattern to extract files from a tar.xz file with the --wildcards option. To stop the shell from interpreting the pattern, it must be quoted.

For instance, the following would be used to extract only files whose names end in .png:

tar -xf archive.tar.xz --wildcards '*.png'

Extracting tar.xz File from stdin

You must specify the decompression option when extracting a compressed tar.xz file by reading the archive from standard input (often by piping). The -J option informs tar that the file is compressed with xz.

The following example uses the wget command to download the Linux kernel and pipes its output to the tar command:

wget -c https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.3.tar.xz -O - | sudo tar -xJ

If you do not provide a decompression option, tar will suggest one for you to use:


tar: Archive is compressed. Use -J option
tar: Error is not recoverable: exiting now

Listing tar.xz File Content

Use the --list (-t) option to list the contents of a tar.xz file:

tar -tf archive.tar.xz

The output should resemble this:



Adding the --verbose (-v) option may cause tar to print additional details, such as the file's owner, size, timestamp, etc:

tar -tvf archive.tar.xz

-rw-r--r-- linuxize/users       0 2020-02-15 01:19 file1
-rw-r--r-- linuxize/users       0 2020-02-15 01:19 file2
-rw-r--r-- linuxize/users       0 2020-02-15 01:19 file3

FAQs: Extracting a tar.xz File

Why do I need to extract a tar.xz file? 

You may need to extract a tar.xz file to access the files or directories it contains. Extracting a tar.xz file involves decompressing and unpacking its contents.

What tools do I need to extract a tar.xz file? 

You will need the tar command-line tool and the xz compression utility, both of which are commonly available on Linux systems.

How do I extract a tar.xz file? 

To extract a tar.xz file, you can use the tar command with specific options and arguments. The command typically involves the "x" flag for extraction and the "f" flag to specify the tar.xz file

Can I extract specific files or directories from a tar.xz file? 

Yes, the tar command allows you to extract specific files or directories from a tar.xz archive.

Can I specify the extraction path for a tar.xz file? 

Yes, you can specify the extraction path for the tar.xz file using the -C or --directory option followed by the desired directory path. This allows you to extract files and directories directly to a specific location.

Are there any GUI tools available for extracting tar.xz files? 

Yes, several file archivers and file managers in Linux offer GUI-based tools to extract tar.xz files. Examples include Filo, File Roller, and Ark.

Are the extraction steps the same across different Linux distributions? 

The basic extraction steps are the same across different Linux distributions. However, some distributions may use slightly different commands or package names for the required tools.


By following the steps and options outlined in this tutorial, you can successfully extract or unzip a tar.xz file on a Linux system. Understanding the extraction process and using the appropriate commands and options allows you to decompress the archive and access its contents efficiently.

If you have any queries, feel free to leave a comment below and we'll be happy to help.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.