Did you just download a file from the internet ending in .xz on your Debian, Ubuntu, Rocky, Alma, or RHEL Linux system? Any file with .xz extension is a compressed archive, and its extraction is a breeze!. This guide will show you how to open the file in few simple steps.

What is a .xz file?

A .xz file is an archive compressed using the XZ format. It offers a higher and efficient compression resulting in a smaller file easy to store, distribute and download.

Extracting .xz file on Linux

The Linux distributions mentioned come with tar pre-installed. This is a powerful archives. To extract a .xz file, follow these simple steps:

In this example we are downloading Kali Linux VM image template that’s distributed in a tar.xz format.

wget https://kali.download/cloud-images/kali-2024.2/kali-linux-2024.2-cloud-genericcloud-amd64.tar.xz

We can check the file contents using tar -tf command.

$ tar -tf kali-linux-2024.2-cloud-genericcloud-amd64.tar.xz
disk.raw

The -t flag instructs tar to give a list of the file contents.

To extract a file we use -xf flags.

tar -xf kali-linux-2024.2-cloud-genericcloud-amd64.tar.xz

Or using tar -xJf

tar -xJf  kali-linux-2024.2-cloud-genericcloud-amd64.tar.xz

Options used:

  • -x: Tar option to extract archive
  • -J: To filter the archive file through xz.
  • -f: Use to specify file to be extracted.

From the list of contents in the file earlier, the file name will be as shown then.

$ file disk.raw
disk.raw: DOS/MBR boot sector, extended partition table (last)

You can now use the raw file after extracting it using tar from .xz original compressed archive.

LEAVE A REPLY

Please enter your comment!
Please enter your name here