Linux – bz2 file and “This does not look like a tar archive”

archivinglinuxtar

I've seen other questions related to this error (like Extracting a tar.gz file returns, “This does not look like a tar archive.”), but I'm not sure how to apply them to my problem:

First, download file:

$ wget --no-check-certificate https://wxpython.org/Phoenix/tools/doxygen-1.8.8-linux.bz2
--2017-04-06 15:06:11--  https://wxpython.org/Phoenix/tools/doxygen-1.8.8-linux.bz2
Resolving wxpython.org (wxpython.org)... 85.234.150.54
Connecting to wxpython.org (wxpython.org)|85.234.150.54|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3961996 (3.8M) [application/x-bzip2]
Saving to: ‘doxygen-1.8.8-linux.bz2’

100%[==============================================================================>] 3,961,996    734KB/s   in 5.0s   

2017-04-06 15:06:16 (778 KB/s) - ‘doxygen-1.8.8-linux.bz2’ saved [3961996/3961996]

Then, check file type of file:

$ file doxygen-1.8.8-linux.bz2 
doxygen-1.8.8-linux.bz2: bzip2 compressed data, block size = 900k

Well, it's "bzip2 compressed data", let's unpack it?:

$ tar xjvf doxygen-1.8.8-linux.bz2
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains ‘\351\357\377I\211\304H\211’ where numeric mode_t value expected
tar: Archive contains ‘A\270\001\0\0\0H\211ǹ\001’ where numeric time_t value expected
tar: Archive contains ‘\307\350\216v)\0I\307’ where numeric uid_t value expected
tar: Archive contains ‘\004$P\254|\0\2770’ where numeric gid_t value expected
@\2678\350\330\351\357\377\2778
tar: @\2678\350\330\351\357\377\2778: Unknown file type '', extracted as normal file
tar: @�8������8: implausibly old time stamp 1970-01-01 00:59:59
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

And I get an empty file unpacked:

$ ls -la @�8������8 
-rwxrwxr-x 1 user user 0 Jan  1  1970 @?8??????8

Strangely, if I use file-roller (Archive Manager) and unpack from the GUI, I do get a file unpacked:

$ ls -la ~/Desktop/doxygen-1.8.8-linux 
-rw-rw-r-- 1 user user 12283548 Apr  6 15:13 /home/user/Desktop/doxygen-1.8.8-linux
$ file ~/Desktop/doxygen-1.8.8-linux 
/home/user/Desktop/doxygen-1.8.8-linux: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0eccee11d38322d5df3a1723651c2f18303e1188, not stripped

Ok, so what is going on here – why can't I unpack this from the command line, and how can I unpack this using the command line?


EDIT: actually I can unpack it with:

$ bzip2 -d doxygen-1.8.8-linux.bz2 
$ file doxygen-1.8.8-linux 
doxygen-1.8.8-linux: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0eccee11d38322d5df3a1723651c2f18303e1188, not stripped

… so the only question remaining is – why couldn't I have used tar for this, as I had always otherwise done?

Best Answer

tar is just copying files together to one big .tar file without compression. bzip2, gzip, xz are file compressors for single files ie. tar files. The extension is .tar.gz, .tar.xz, .tar.bz2 or .tbz(2), .txz, .tgz etc.

tar can only handle .tar files with or without compression with bzip2, xz, gzip. but not non tar'ed .bz2, .xz archives.

Non tar'ed bzip files can be extracted with bzip2 -d file.bz2.

Related Question