This is a silly1 but rather useful for me. I always forgot the options sometimes.
Compress a files/folder:
tar -czvf <destination filename to be saved> <target files / folder to be compressed>
Example:
tar -czvf filename.tar.gz /var/www/
decompress files / folder:
tar -zxvf <compressed filename to be extracted> <destination to be compressed>
tar -zxvf filename.tar.gz /var/www/
Also See:
2 users commented in " Howto: Linux compress / decompress files with Tar "
Follow-up comment rss or Leave a Trackbackyou also can use j to replace z, which is bzip2 with gzip. Bzip2 has greater compression compare to gzip
tar -cjvf filename.tar.bz2 /var/www/
tar -xjvf filename.tar.bz2 /var/www/
wow.. great sharing..
Bzip2 is much better, but slower then gzip. but bz2 will be better when you do some regular backup, save more space if you do your achieve.
Thanks.
Leave A Reply