How do I uncompress a tarball that uses .xz?

Ubuntu includes GNU tar, which recognizes the format by itself! One command works with any supported compression method, per the manual.

tar xf archive.tar.xz
tar xf archive.tar.gz
tar xf archive.tar

etc. If tar gives a Cannot exec error, you may need to sudo apt install xz-utils first.


Try

tar -xJf file.pkg.tar.xz

The -J is the flag that specifically deals with .xz files.


If for some reason the tar solutions don’t work (perhaps because you’re using the OS X built-ins), try this:

unxz < file.tar.xz > file.tar

…which is equivalent to:

xz -dc < file.tar.xz > file.tar

Then use tar to untar the file.