How can I untar a tar.bz file in unix? How can I untar a tar.bz file in unix? bash bash

How can I untar a tar.bz file in unix?


use the -j option of tar.

tar -xjf /path/to/archive.tar.bz


According to the man pages for bzip2

   If  the  file  does  not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the   name of the original file, and uses the original name with .out appended.

Based on this, I'm guessing that '.bz' is considered a valid suffix for bzip2 compressed files. Also, keep in mind that the original file name was probably generated by hand, something like this:

tar jcf archive.tar.bz /path/to/files

Rather than doing this:

tar cf archive.tar /path/to/files && bzip2 archive.tar

Which would force the filename to be archive.tar.bz2.

Unless the file that you're unpacking is older than, say 1998 (bzip2 was released in 1996), I'm guessing that you're actually looking at a bz2 file.

If you're interested in the history of bzip vs bzip2 and the technical differences between the two, there's good discussion on the Wikipedia Bzip2 page as well as the archive of the bzip2 home page. The latter includes a link to the original bzip source, which is not compatible with bzip2 because the it would require patent encumbered code to de-compress files compressed with the original bzip.

The file types differ by magic number, bzip2 uses BZh, the original bzip uses BZ0.


If it's really an old bzip 1 archive, try:

bunzip archive.tar.bz

and you'll have a standard tar file.Otherwise, it's the same as with .tar.bz2 files.