Linux : Compress entire folder to .gz or .bz2

gzip / bzip2 can compress individual files. To compress entire folder structure ‘tar’ command comes to our rescue.

Compress to .gz 

tar -zcf </path/output.gz>  /sourcefolder/path

Compress to .bz2

tar -jcf </path/output.bz2> /sourcefolder/path

tar options :

-z : gzip
-c : compress
-f : filename
-j : bzip2


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: