54

I tried to extract the tar.bz2 file in Fedora 17 OS. I used the command:

# tar -xvjf myfile.tar.bz2

I received this error message:

tar (child):bzip2: Cannot exec :Nosuch of file or directory
tar (child): Error is not recoverable: exitng now
tar: Child returned status 2
tar:Error is not recoverable: exitng now

How can I resolve this?

Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76
Vincent Huang
  • 543
  • 1
  • 4
  • 5

9 Answers9

89

Ensure that you have the bzip2 and bzip2-libs RPMs installed.

It looks like the tar command defers to the bzip2 command which the bzip2 RPM provides (/usr/bin/bzip2). In your case, tar specifically tries to call bzip2 -d to decompress the bzipped archive.

Also, a couple of tips:

  • The -v option is not necessary. It just gives verbose output, which means that it lists the files that were extracted from the archive. Most of the time this prints useless data to your terminal.

  • As @Skynet said, it is helpful to run the file command on your bzip2 archive to ensure that it is actually in bzip2 format.

  • As @Odin said, it appears that you don't need to specify the -j option when extracting the archive, as the tar command seems to be smart enough to figure this out.

Kevin S
  • 2,713
  • 24
  • 31
62

I solved it using:

aptitude install bzip2
Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
vsxen
  • 731
  • 5
  • 5
15

I found the same error as you in CentOS 7. It looks like this:

tar -jxvf target_gile.tar.bz2
 <br>tar (child): bzip2: Cannot exec: No such file or directory
<br>tar (child): Error is not recoverable: exiting now
<br>tar: Child returned status 2
<br>tar: Error is not recoverable: exiting now

Then I installed bzip2 package : yum install bzip2

After that, I extracted again using this command: tar -jxvf target_gile.tar.bz2

Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76
efendimansur
  • 171
  • 1
  • 7
11

You may need to install the bzip2 on your system.

yum -y install bzip2

I got the same problem . I have two server.

A: CentOS 7.6 Min install

B: Fedora 29 Workstation

On B:create a tarball with:

tar -jcvf  XXX.tar.bz2   /Path_to_my_dir

Then scp this tarball to A server to decrompress it, but when I want to decompression it I got the same error.Finally it turns out that, tar could work with bzip2 but you have to install it first .

Fan Fan
  • 111
  • 1
  • 2
3

This worked for my file:

binutils-2.15.tar.bz2 (Found at http://ftp.gnu.org/gnu/binutils/)

bunzip2 your-tar-file.tar.bz2

Your file now looks like this:

your-tar-file.tar

tar xvf your-tar-file.tar

File will finish extracting

Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76
Mark Frick
  • 61
  • 1
  • 5
1

First you need to install lbzip2 package:

yum install lbzip2

then untar the file

tar file.tar.bz2

Regards

0

You can extract either tar.gz or tar.bz2 with this command:

tar -xvf ~/sometar.tar.bz2
Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
Odin
  • 580
  • 11
  • 24
0

this error come also if you use some wrong alias in your .bashrc/.zshrc as:

alias tar='tar -cf'

when you execute in terminal

$ tar -xf file.tar

it's been

$ tar -cf -xf file.tar

tar (child):bzip2: Cannot exec :Nosuch of file or directory
tar (child): Error is not recoverable: exitng now
tar: Child returned status 2
tar:Error is not recoverable: exitng now

so, you should not use an alias for tar or do

$ unalias tar
$ tar -xf file.tar
nextloop
  • 166
  • 9
-12

For bz2 you need to execute like this,

tar -jxvf

Alternatively, you can also execute like this

bunzip2 myfile.tar.bz2

For more information you should check it,

tar --help

If in doubt, run file on the archive to make sure it actually is compressed in bz2 format.

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
  • 5
    I don't believe that you need to follow an order of operations for the `bzip2` format with the `tar` command. Calling `tar -xjf` and `tar -jxf` work. I think the only argument that requires ordering is the `-f` option that requires the file name immediately after it. – Kevin S Jul 21 '15 at 13:11