I know there are many ways of doing it, however the below one is best as per me:
To create a compressed file:
1st way: If you would like to compress the whole folder, go to the folder and run the below command
tar cf – * | gzip > FIle_Name.tar.gz
2nd way: And if you would like to compress the folder from outside of the folder:
tar cf – folder_name | gzip > folder_name.tar.gz
To explode the file:
For 1st way:
Create a desired directory.
cd <directory_name>
gunzip < folder_name.tar.gz | tar xf –
For 2nd way:
And if you have created the .tar.gz file using the second way above go to any where run the below command it will create the directory automatically.
gunzip < folder_name.tar.gz | tar xf –
Hope it helps…