How To Decompress or Extract tar.xz In Linux? – POFTUT

How To Decompress or Extract tar.xz In Linux?

Linux provides different compression format with different tools. But tar is defacto standard for Linux to put given file and folders into single file. Than the compression comes. xz is very efficient compression algorithm and tool better than gzip and bzip in general. In this tutorial we will look how to compress and decompress or extract tar.xz file in Linux.

Print File Type

We can start by checking wheter given tar.xz extension is in xz format with file command. We will provide the file name which is nmap.tar.xz in this case.

$ file nmap.tar.xz
Print File Type
Print File Type

Decompress With tar Command

tar command have builtin support for  most of the compression format. It also supports xz format. So we can use single tar command in order to decompress the tar.xz file.  We will provide xvf options to the tar command but v is optional which will list extracted file names to the terminal.

$ tar xvf nmap.tar.xz
Decompress With tar Command
Decompress With tar Command

Decompress with tar and xzcat Command

Another option to decompress tar.xz files is using tar and xz command separately. We will redirect xzcat command output to the tar command like below. xzcat is a wrapper which will use xz command simply decompress given file content to the standard output. We will provide x option to tar command in order to extract tar archive.

$ xzcat nmap.tar.xz | tar x


If we can to compress normal files or directories to the tar.xz format we can use tar command with c option which will create given file or directory tar to the standard output and than we will redirect it to the xz command to compress like below.

$ tar c nmap-7.60 | xz > nmap.tar.xz

LEARN MORE  Linux gunzip Command Tutorial with Examples

Leave a Comment