Extracting or Uncompressing tar.xz Files in Linux

By | 2014/01/07

tar.xz compression is becoming more popular. Here is how it works!


1. On Debian or Ubuntu, first install the package xz-utils
$ sudo apt-get install xz-utils


2. Extract a .tar.xz the same way you would extract any tar.__ file.
$ tar -xf file.tar.xz

Done.


1. To create a .tar.xz archive, use tack c
$ tar -cJf linux-3.12.6.tar.xz linux-3.12.6/

That’s $ tar -cJf [name of archive] [directory to compress]


Think x to extract, and c to create.
Rock on,

5 thoughts on “Extracting or Uncompressing tar.xz Files in Linux

  1. pticon

    In order to get rid of all those command line options, I personally use a bash wrapper:
    function extract()
    {
    local archive=”$1″

    [ -n “$archive” ] || return

    if [ -f $archive ] ; then
    case $archive in
    *.tbz2|*.tar.bz2)
    tar xjf $archive ;;

    *.tgz|*.tar.gz)
    tar xzf $archive ;;

    *.bz2)
    bunzip2 $archive ;;

    *.rar)
    rar x $archive ;;

    *.gz)
    gunzip $archive ;;

    *.tar)
    tar xf $archive ;;

    *.zip)
    unzip $archive ;;

    *.Z)
    uncompress $archive ;;

    *.tar.xz|*.txz)
    tar xfJ $archive ;;

    *)
    echo “‘$archive’ cannot be extracted via extract()” ;;
    esac
    else
    echo “‘$archive’ is not a valid file”
    fi
    }

    Reply
  2. unknown

    Thanks for the instructions! This helped me a lot!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.