gzip Compress a directory (folder)

Raymond Tang Raymond Tang 0 1568 1.11 index 8/12/2021

This code snippet shows how to compress a whole directory or folder using tarcommand.

Code snippet

tar -zcvf archive-file-name.tar.gz your-folder/ 

Use man tar to find out the details of the options of the above commands.

  • -z - compress it using the z (gzip) algorithm
  • -c - (create) an archive from the files in directory
  • -v - (verbosely) list all the files it adds to the archive
  • -f - store the output as archive-file-name.tar.gz

To unzip it, using the command below:

tar -zxvf archive-file-name.tar.gz

References

Can I zip an entire folder using gzip? - Unix & Linux Stack Exchange

shell

Join the Discussion

View or add your thoughts below

Comments