formats

Tar Bzip2 a Directory in Linux

Published on July 17, 2010, by + in linux, sysadmin.




How do I tar bzip2 a directory in Linux?

One of the better compressions is bzip2, and in one easy command you can compress a directory to .tar.bz2. I’ll show you how!

Simply do the below command. Here I’m compressing a directory called ‘stuff’.

(Though not required, I suggest using the option ‘p’ which will preserve file permissions.)

tar jcvpf stuff.tar.bz2 stuff/



To extract that, just issue this command:

tar jxvf stuff.tar.bz2



Or, specify where to extract that archive if needed:

tar jxvf stuff.tar.bz2 -C /extract/over/here






tar is NOT multi-threaded. :/ It is painful to watch tar use only one of your available CPUs, especially if you do the cpu-intensive bzip2 compression.

However if you find yourself needing to do this often, use pbzip2 which IS multi-threaded.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Home linux Tar Bzip2 a Directory in Linux