How do I Compress a Whole Folder Linux?

How can I compress a whole directory under a Linux command prompt?

You will be using tar command to compress a folder in linux:

tar -zcvf archive-name.tar.gz your-directory-name


  • -z : Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

For example, you have a direcotrey called in /var/www/html, the code would be $ tar -zcvf /var/www/html/

Editorial Staff

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.