How do I Compress a Whole Linux/UNIX Folder

This is task that you will do many times when working with Linux/UNIX. This can be automated or done just as a simple one time task. Best tool for this job is tar 

  • GNU tar  saves many files together into a single tape or disk archive, and can restore individual files from the archive.

GNU tar comes with many options but for my task i will use the following options only:

tar -zcvf wwww_aodba_bkp.tar.gz www/
  • this command will create gziped archive containing the entire content of the www/ folder called www_aodba_bkp.tar.gz.
Options  used and their purpose:
  • -z Compress archive using the gzip program
  • -c  Create archive
  • -v  Verbose i.e display progress while creating archive
  • -f  Archive File name

To extract the content of a tar archive use the following command:

  • -C Extract location
  • -x Extract the content
tar -zxvf wwww_aodba_bkp.tar.gz
  • this will extract to the current working directory.
tar -zxvf wwww_aodba_bkp.tar.gz -C /folder
  • this will extract the content into /folder directory.
GNU tar come very handy to be used on a daily basis by any system admin. Hops this was helpful