Linux Tips & Tricks · January 13, 2022

bzip2: Cannot exec: No such file or directorybzip2: Cannot exec: No such file or directory

[Linux] bzip2: Cannot exec: No such file or directory

While creating a tarball with bzip2, you may run into this error: “bzip2: Cannot exec: No such file or directory

bzip2: Cannot exec: No such file or directory
bzip2: Cannot exec: No such file or directory
[root@gnuadmin ~]# tar -cjf bzip2.tar.gz data_file last.log system_logs 
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now

The error shows that you’ll need to install bzip2 package. You can use “apt-get install bzip2” or “yum install bzip2” or something else depending on your package manager.

After the installation, you can simply create tarballs with tar command using bzip2 algorithm.

[root@gnuadmin ~]# tar -cjf bzip2.tar.bz2 data_file last.log system_logs 
[root@gnuadmin ~]# file bzip2.tar.bz2 
bzip2.tar.bz2: bzip2 compressed data, block size = 900k