Compression:
tar.gz
To use gzip to create .gz package, you need to first create a container. For that tar can be used. Packaging files into a container and compression are two different things. gzip is mainly used for compression of a single file, which can be a container made from tar as well.
tar -cvf filename.tar dir-or-file
gzip filename.tar
tgz
Its same as tar.gz done using tar
tar -czvf filename.tgz file-or-dir
tar.bz2
tar -cvf filename.tar file-or-folderBoth gzip and bzip2 will delete the source file after compression.
bzip2 filename.tar
#OR
tar -cvjf filename.tar.bz2 file-or-folder
Decompression (expand):
tar.gz or tgz
tar -zxvf filename.tar.gz #or filename.tgz
tar.bz2
tar -xvjf filename.tar.bz2