How Can I zip an Entire Folder Using gzip?

Gzip is one of the most well-known and common tools which is used to compress and decompress files in Linux which becomes very useful especially if you are low on storage and want to save some space. But now you might be wondering, can I use this tool to zip an entire folder? 

If you are here to this question then we have covered all the relevant details regarding it in this article:

Is it Possible to Zip the Complete Folder Using gzip?

Zipping an entire folder using gzip utility is generally not possible as it is mainly used to zip files. Let’s show you the working of the gzip command while zipping the folder. 

The following folder is chosen which contains three subfolders and two text files:

Let’s apply the “gzip” utility on the “Documents‘ folder in a recursive manner (including the directories and sub-directories):  

$ gzip -r Documents

The output shows that only files are zipped while the three folders are unchanged. 

Zipping an Entire Folder 

There is another way to zip an entire folder that you can do by combining the tar command as shown below:

$ tar -czvf Documents

In the above command, “” will be the name of the zip folder, and the subfolders and files that it will compress. There are 4 different options also been used and their description is mentioned below:

  • c: This will tell the tar command to create an archive file.
  • z: Use the gzip compression.
  • v: This stands for verbose which lists the operation details (Not necessary for compression but recommended).
  • f: As we have provided the filename which is “” then you need to use this option.

As you can see in the command we have used the z option which follows the gzip compression, so this means that we are combining the gzip compression with the tar command.

Verify the Compression

Let’s verify the compression using the “ls” command: 

It can be seen in the above image that the entire folder has been compressed with the name “” and also the main Documents folder can also be seen.

Later the content can be verified by typing the command mentioned below

$ tar -xvf

In this way, you can compress the entire folder in Linux.


Users cannot zip an entire folder by using the gzip command alone as it is normally used to zip files only. If the gzip command is applied to compress the folder, it will consider only files inside that folder. To zip a folder in Linux, the users can use the tar command. 

This post has addressed the fact that gzip cannot zip complete folders and has also shown the working of the tar command to zip the complete folder.