Juicy lil' bytes

How to Unpack a tar.gz and tar.bz2 Archive on the Command Line

No matter how many times I use these commands, I always need to look up the switches to decompress and unpack a compressed tar archive. Here they are for those who have the same problem.

Decompress and Unpack a tar.gz Archive

Decompress and Unpack a tar.gz Archive
1
tar -xvzf <filename>

Decompress and Unpack a tar.bz2 Archive

Decompress and Unpack a tar.bz2 Archive
1
tar -xvjf <filename>

What the Switches Do

-x : extract the tar archive

-v : verbose output so that you see what files are being unpacked

-f : indicates that you are providing tar with an archive filename

-z : runs gunzip to decompress .gz files

-j : runs bunzip2 to decompress .bz2 files