Here we will discuss how to create and compress the folder into the .tar.gz file
Compress the file or folder:
sudo tar -zcvf /var/www/html/example.tar.gz /var/www/html/example
I had used the sudo before tar command because it will not have any permission issue.
Here are the switches actually mean:
-c: Create an archive
-v: It is used for display the progress on the screen.It is optional so you can skip it
-z: Compress the archive
-f: Allow to specify the filename
Extract the file:
sudo tar -zxvf /var/www/html/example.tar.gz
Here are the switch mean:
-x: Extract file
After executing the above command I will get example folder in /var/www/html directory.