In order to compress an entire folder with Gzip, you first need to create a tar file which you can compress with gzip. Fortunately this can be accomplished with a single one-liner command.
Let’s assume your folder is named
my-folder. Type following command in terminal:
$ tar -zcvf my-folder.tar.gz my-folder/
zuses gzip as a compression method to the tar archive
ccreates a new archive file
fwe enter the new filename for the archive after this parameter
To check the contents of the newly created my-folder.tar.gz, you can enter:
$ tar -tf my-folder.tar.gz
This should output your folder contents.