How to compress / extract tar files on Linux

Prev Next

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.


FAQ

What is the main problem with zip files on Linux machines?

Zip files often have a poor compression rate and may encounter permission issues on Linux systems.

What is a recommended compression option for Linux systems?

Tar files are recommended as they offer a good compression rate and speed on Linux systems.

How can I compress a folder or file using the GUI method?

Right-click on the folder or file, select 'compress', and then choose the tar.xz option.

What command do I use to compress a file or folder in the terminal?

You can use the command 'tar -zcvf .tar.gz ' to compress a file or folder.

How can I extract a tar.gz file?

You can extract a tar.gz file using the command 'tar -zxvf archive_name.tar.gz'.

Is it possible to split a large compressed file into smaller chunks?

Yes, you can split a large compressed file into chunks using the command 'tar -cvj large-files.avi | split -b 1024m -d - "large-split.tar.b."'.

What should I do to extract connected chunks of a compressed file?

To extract connected chunks, use the command 'cat large-split.tar.xz.* | tar -xzvf -'.

Are there different variations of the tar compress option?

Yes, the tar compress option has different variations such as .gz, .xz, .bz, etc.

Can I use the terminal method for compression on Linux?

Yes, the terminal method is a valid option for compressing files and folders on Linux.