Linux/Unix: How To Extract and Decompress a .bz2/.tbz2 File

I‘ve a file called How do I extract or decompress a .bz2 file on a Linux or Unix-like systems using command line options?

You can decompress .bz2, .bz, .tbz2, and .tbz file using bzip2 command on a Linux or Unix-like systems such as FreeBSD, OpenBSD, OS X and more.


How to decompress a .bz2 file

The syntax is:

bzip2 -d your-filename-here.bz2
bzip2 -d -v your-filename-here.bz2
bzip2 -d -k your-filename-here.bz2
bunzip2 filename.bz2


To extract a file called dfly-x86_64-4.2.0_REL.iso.bz2, enter:
bzip2 -d dfly-x86_64-4.2.0_REL.iso.bz2
To verify new file, enter:
ls -l dfly-x86_64-4.2.0_RE*
Sample outputs:

-rw-r--r--  1 vivek  wheel  634376192 Jul  1 15:57 dfly-x86_64-4.2.0_REL.iso

You can now use extracted file but this option will not preserve original archive file. To Keep (don’t delete) input files during decompression, use:
bzip2 -d -k dfly-x86_64-4.2.0_REL.iso.bz2
To see verbose output pass the -v option to the bzip2 command. The verbose mode show the compression ratio for each file processed. Further -v’s increase the verbosity level, spewing out lots of information which is primarily of interest for diagnostic purposes:
bzip2 -d -k -v dfly-x86_64-4.2.0_REL.iso.bz2
bzip2 -d -k -vv dfly-x86_64-4.2.0_REL.iso.bz2
Sample outputs:

    [1: huff+mtf rt+rld]
    [2: huff+mtf rt+rld]
    [631: huff+mtf rt+rld]
    [632: huff+mtf rt+rld]

Sample demo

Gif.01 Extract and Decompress a .bz2/.tbz2 File

Decompress a .tbz2 or .tbz or .tar.bz2 file

Use any one of the following syntax:

bzip2 -dc filename.tar.bz2 | tar xvf -
bzip2 -dc filename.tbz2 | tar xvf -
bzip2 -dc filename.tbz | tar xvf -

OR use gnu/tar command syntax:

tar -jxvf filename.tar.bz2
tar -jxvf filename.tbz2
tar -jxvf filename.tbz


  • bzip2 command options:
    • -d : Force decompression.
    • -c : Decompress to standard output so-that tar command can take input.
  • tar command options:
    • -j : Call bzip2 to decompress file.
    • -x : Extract file.
    • -v : Verbose mode
    • -f : Archive name.

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....