Assuming you would like a step-by-step answer to this question:
1. Use the tar command to create an archive of the directory that you would like to compress. For example, if the directory is named mydir, you would use the following command:
tar -cf mydir.tar mydir/
2. Use xz to compress the tar archive created in Step 1. For example, if the tar archive is named mydir.tar, you would use the following command:
xz -9e mydir.tar
3. Extract the contents of the compressed tar archive using one of two methods:
Method One: If you have xz installed on your system, use this command:
tar -xf mydir.tar.xz
Method Two: If you do not have xz installed on your system, first decompress the file using gunzip and then extract its contents using tar, like this:
gunzip -c mydir.tar | tar -xf -