You can compress a file or a folder with tar command. Its good to know that, file.tar.gz is the same with file.tgz.
File compression using tar command:
tar -cvzf <name of tarball>.tgz /your file or folder directory
For instance to compress a file or folder you should type:
Tar -cvzf folder.tgz /home/user/folder
Or
Tar -cvzf file.tgz /home/user/folder/file.txt
Notice:
You can use tar cvzf instead tar -cvzf as well.
File Decompressing using tar:
To decompress or extract them, use the following command.
tar -xvzf file.tgz
or
tar -xvzf file.tar.gz
There is no priority using the flags.
-z: Compress archive using gzip program
-c: Create archive (compress)
-v: Verbose i.e display progress while creating archive
-f: Archive File name
-x :extract