How to extract files from a bz2 archive in Linux

If you’ve ever tried to decompress a file that ends in tar.bz2 using the tar command, you’ll have noticed that it doesn’t work. That’s because the tar command does not understand the binzip codec used in these archives.

Instead, we can use the bzip2 command like so:

bzip2 -d yourfile.tar.bz2

The -d switch stands for “decompress”. Notice that this will extract all files and delete the original .bz2 file by default. Very convenient indeed! If you’d like to keep it, just pass the -k switch (for “keep”), like this:

bzip2 -dk yourfile.tar.z2

Checkout man bzip2 for more details, or pass the –help for as quick overview.





Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices.

He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

You can leave a comment on my original post.