How to compress / extract tar files on Linux
- 05 Mar 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
How to compress / extract tar files on Linux
- Updated on 05 Mar 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
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
Right-click on the folder / file, and choose compress.
The zip options are displayed, select the tar.xz option.
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?