- slide 1 of 2
What is TAR? Why is it Used?
TAR is actually two things: a packaging file format and the program that handles these types of files. TAR is actually an acronym for “Tape ARchiver" and was first used to backup data to tape devices. In time, TAR has become the standard in the UNIX and Linux world as a de facto standard for the distribution and archiving of files.
TAR has a very important feature: it preserves file system information such as user and group permissions, date and time information and directory structures.
After you pack everything in a TAR file, you go on to compress it. The compression formats that are used with TAR are as follows:
- GZip (GNU Zip): The files end with gz extension. With tar, they end with tar.gz or tgz.
- BZip2: The files end with bz2 extension. With tar, they end with tar.bz2, tbz, tbz2 or tb2.
- Z: Files are compressed with the compress command have a Z extension. If they are tar’red in advance, the extension becomes tar.Z.
- LZMA (Lempel-Ziv-Markov chain Algorithm): The files which are compressed with LZMA have the lzma extension. If the files are tar’red before they are compressed, the file extension becomes tlz or tar.lzma.
- slide 2 of 2
How do I Open These Files?
The best way to open these files is through the command line, but many users shy away from typing commands. Most probably, you also will want to work with a program that has a Graphical User Interface (GUI).
At this point, 7-zip comes as a very handy program to work with compressed files, unfortunately you can only run it using Wine. You need to install p7zip and p7zip-full packages, and it is best to install these using your distribution’s package manager. When done, you can right click on the compressed file and select “Extract here" or double-click and open it with the Archive Manager and extract individual files. Usually Archive Manager can handle compressed files without any problems.
If you want to go with the command-line option, first navigate to the directory where you have saved the file with cd directory_name and then issue the relevant command:
- Gzip files: gunzip file.gz or tar -zxvf filename.tar.gz (or filename.tgz) if the file is tar’red.
- BZip2 files: bunzip2 filename.bz2 or tar -jxvf filename.tar.bz2 (or filename.tbz / filename.tbz2 / filename.tb2) if the file is tar’red.
- Z files: you need to have ncompress package installed. If not, go and install it from your package manager. Then you can open the archive with uncompress filename.Z or if tar’red, tar -Zxvf filename.tar.Z. Be careful! The Z in the options is the capital Z!
- LZMA files: You need to have lzma-utils package installed. You can install it from your distribution’s package manager. Then you can open the lzma file with unlzma -c filename.lzma. If the file extension is tar.lzma, then you can go for tar --lzma -xvf filename.tar.lzma or if the file is an old archive lzma -cd filename.tar.lzma | tar -xvf.
Linux File Compression - TAR, GZIP, Z, LZMA Files
In this article series we look at the various compression formats present in the Linux world and the ways to handle them. We also look at the most common error with the compressed archives, the CRC Check Error.