The simplest way to extract to a specific directory:
For a .tar.gz:

Code:
tar -xvzf file.tar.gz -C directory

For a .tar.bz2:

Code:
tar -xvjf file.tar.bz2 -C directory

To extract a tar.bz2 file, use the command (note the j option)

Code:
tar -jxvf filename.tar.bz2

To extract a tar.gz file, the the command (note the z option)

Code:
tar -zxvf filename.tar.gz
Advertisements