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

Posted on in Categories , , last updated July 17, 2015

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
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: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

2 comment

  1. hi – do you know a tool called dtrx?

    this unpacks almost every archive with one command.

    try it out.

  2. A little tip for tar. Actually, modern tar takes care automatically of the type of compression when it decompress an archive. You don’t need to set it explicitly :

    tar xvf archive.tar tar xvf archive.tar
    tar xvf archive.tar.gz tar zxvf archive.tar
    tar xvf archive.tar.bz2 tar jxfv archive.tar

Comments are closed.