How to Decompress file using Bunzip2 Command usage Linux

How to Decompress file using Bunzip2 Command usage Linux

 

Bunzip2 command is used on Linux servers to compress and decompress files. You should use “-d” or “–decompress” option to decompress the *.bz2 file. Command syntax is pasted below

bunzip2 -d [filename]

OR

bunzip2 –decompress [filename]

Bunzip2 Decompress example is pasted below. I want to decompress the file testfile.txt.bz2 in /usr/local/src directory.
 

root@server [/usr/local/src]# bunzip2 -d testfile.txt.bz2

-rw-r–r– 1 root root 1489235 May 11 02:36 testfile.txt

 
The Above commmand will not preserve the original *.bz2 file while decompressing. Use “-k” option to keep the original file while decompressing. Example is given below :
 

root@server [/usr/local/src]# bunzip2 –decompress –keep testfile.txt.bz2
root@server [/usr/local/src]#

OR

root@server [/usr/local/src]# bunzip2 -dk testfile.txt.bz2
root@server [/usr/local/src]# ll
-rw-r–r– 1 root root 1489235 May 11 02:36 testfile.txt
-rw-r–r– 1 root root 112194 May 11 02:36 testfile.txt.bz2