How to compress / extract tar files on Linux
  • 05 Mar 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

How to compress / extract tar files on Linux

  • Dark
    Light
  • PDF

Article summary

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.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.