How to compress / extract tar files on Linux

Introduction

Problem description

Often the zip files have quite bad compression rate, or they have permission issues on Linux machines.

As a standard compress option, tar files have quite nice compression rate and speed on Linux systems.

Procedure

1 GUI method to compress

  1. Right-click on the folder / file, and choose compress.

    compress

  2. The zip options are displayed, select the tar.xz option.

    compress1

2 Terminal method to compress

Alternatively, you can use command to tar a file / folder:

tar -zcvf <name>.tar.gz <target_directory>

Compress into spitted chunks in certain cases when the single compressed file is too large (e.g. split the compressed files into 1024MB chunks):

tar -cvj large-files.avi | split -b 1024m -d - "large-split.tar.bz."

3 Extract

tar -zxvf archive_name.tar.gz

To extract connected chunks of compressed file:

cat large-split.tar.xz.* | tar -xzvf -

Note: the tar compress option has different variations, for example .gz, .xz, .bz. etc. Please change accordingly to your specific file type.