Extract/Create .tar .tar.gz .tar.bz2
I have always been dumbfounded as to how to extract and create .tar .tar.gz and .tar.bz2 but I don't know why because there really isn't much to it.
First off what are these things? .tar is simply a bundle of files packaged into one. And .tar.gz and .tar.gz2 are compressed packages that can be considered the same for most peoples purposes. However, I believe .tar.gz2 can compress files further than .tar.gz but takes longer.
Checkout for more information check out http://en.wikipedia.org/wiki/Comparisonoffile_archivers
To extract and create you use the "tar" command combined with some options. The options are as follows and are combined together to create a single statement.
x = extract v = show what the computer is doing (verbose) f = you are providing a filename z = dealing with .tar.gz j = dealing with .tar.bz2 c = create Extraction of .tar.
tar xvf toBeExtracted.tar
As you type this command out. Type "tar" then "-" for options, "x" for extract, "v" to show me what is going on also known as 'verbose' and "f" because I am supplying a file name.
Extraction of .tar.gz
tar xzf toBeExtracted.tar.gz
same thing as before but with "z" added to it. Perhaps you could think "z" for zipped. With "v" for verbose left off this time.
Extraction of .tar.bz2
tar xvjf toBeExtracted.tar.bz2
Similar to above, but instead of "z" it is "j". It is always nice to have a story to remember something, and apparently .bz2 was invented by Julian Seward, so, "j" for Julian.
Creation of .tar
tar cfv resultingFile.tar folderOrFileToBeCompressed
"c" for create
Creation of .tar.gz
tar cfvz resultingFile.tar.gz folderOrFileToBeCompressed
Creation of .tar.bz2
tar cfvj resultingFile.tar.bz2 folderOrFileToBeCompressed
Summary
In sum, use the switches as listed above in combination (order is important) to achieve your goal. Once you study these commands a little bit you will feel far more comfortable with them.
For more information check out the manual page with the following command.
man tar