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.
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | None |
Time | 2m |
How to decompress a .bz2 file
The syntax is:
bzip2 -d your-filename-here.bz2
OR
bzip2 -d -v your-filename-here.bz2
OR
bzip2 -d -k your-filename-here.bz2
OR
bunzip2 filename.bz2
Examples
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
OR
bzip2 -d -k -vv dfly-x86_64-4.2.0_REL.iso.bz2
Sample outputs:
dfly-x86_64-4.2.0_REL.iso.bz2: [1: huff+mtf rt+rld] [2: huff+mtf rt+rld] .... ... .... [631: huff+mtf rt+rld] [632: huff+mtf rt+rld] done
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
Where,
- 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.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
hi – do you know a tool called dtrx?
this unpacks almost every archive with one command.
try it out.
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