Tuesday, March 2, 2010

tar.gz, tgz and tar.bz2

On linux distributions we commonly see files named tar, tgz, tar.gz and tar.bz2. This note tries to explain common operations on such files.

tar is used to create a Tape ARchive. ( tar is from the old unix era) The resulting file is known as a tarball. A tar ball concatenates files to a a sin get the files out of a tarball, you can extract a tarball using

tar -xvf something.tar

To create a tar archive , the following command can be used.

tar -c /home/mydir > mydir.tar

tgz and tar.gz

If the tarball has also been gzipped (compressed), the file will be named tar.gz or tgz .You can use the following command to extract it.

tar -xvfz something.tar.gz

If you want to create a tgz as below.
tar czvf myfolder.tar.gz myfolder/


A tar.bz2 uses bzip2 compression on a tarball. Generally the size will be less that a tar.gz file .If you have a .tar.bz2 file , issue this command: ( You need bzip2 installed)

tar -xvjf file-1.0.tar.bz2
If you want to create a tar.bz2 as below.
tar cjvf myfolder.tar.bz2 myfolder/


Chuck Maglaughlin said...

Congratulations...You are the 100th geek in a row who has failed to explain how to install anything downloaded as a tar file. Don't you people realize you don't make one bit of sense to someone who is sincerely trying to accomplish this and thus believe in Linux more than I do. Nobody can simply walk anyone through this. They always leave something out, so I just delete the file and swear never to waste my time downloading any such tar crap again. Please pass the word!

alfa said...

Amen to that Chuck! I'd like to switch permanently to Linux on my laptop, and I have it up and running now, but what a headache, especially with installing anything that's not available through the package manager.
If these Linux guys are so smart why on earth can't they get software installation sorted in the way that it is in Windows? It's analagous to using an old fashioned starting handle on a car rather than a key and starter motor.

Chuck Maglaughlin said...

I'm a glutton for punishment. I need to install a driver program for my erratic touchpad cursor. It is a tar bz2 read only file. I keep getting unrecoverable error, child returned status. I've spent days trying to find one place that will go step by step. Each answer is different, same result. I don't need to be educated, I just need the thing installed. Do I have some permissions problem? Where do I send the download? Please...anybody!!!