Gzip Folder Recursively in Linux

Last updated on Dec 27, 2019 in Linux

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/
  • z uses gzip as a compression method to the tar archive
  • c creates a new archive file
  • v verbose output
  • f we 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.