bzip2 command in Linux/Unix

The bzip2 command in Linux is used for compressing and decompressing files.

  • It is like gzip command but takes a little more time to compress but compresses better.
  • It uses the Burrows-Wheeler block-sorting text compression algorithm and Huffman coding.
  • bzip2 command creates a compressed file with the extension “.bz2”.

Syntax for bzip2 command

bzip2 [OPTIONS] filename

Uses of bzip2 command

Check bzip2 command is already installed or not. To check this just type bzip2 in the terminal.

bzip2

bzip2 command in linux-unix with examples

Installing bzip2 command

The bzip2 command can be installed using following command

  • For Debian/Ubuntu
sudo apt install bzip2
  • For Contos/RHEL
sudo yum install  bzip2
  • For Fedora
sudo dnf install bzip2

sudo apt install bzip2

bzip2 Help

To get help for bzip2 command and find options available with bzip2 command, Use bzip2 --help command.

bzip2 --help

bzip2 --help

Version

TO check bzzip2 installed version, use command bzip2 --version

bzip2 --version

bzip2 --version

Convert file to bzip2 file

  • For single file

bzip2 command can be used to convert single file or multiple file

bzip2 filename
bzip2 123.txt

bzip2 filename

  • For Multiple file
bzip2 file1 file2 file3 ......
bzip2 abc.txt def.txt

bzip2 file1 file2

  • For files with same extension
bzip2 *.file_extension
bzip2 *.html

bzip2 file-pattern

Convert to bzip2 file without deleting original file

bzip2 -k filename
bzip2 -k 456.txt

bzip2 -k filename

bzip2 -v filename
bzip2 -v 789.txt

bzip2 -v filename

 

Unzip bzip2 file

bzip2 -d zip_filename
bzip2 -d 123.txt.bz2

bzip2 -d bzip2 file

Check Validity of bzip2 file

bzip2 -t 456.txt.bz2

bzip2 -t filename

bzip2 -v -t 456.txt.bz2

bzip2 -v -t filename

bzip2 -t 677.bz2

bzip2 -t zipfile-other

bzip2 -f 456.txt

bzip2 -f filename

bzip2 -cd 123.txt.bz2

bzip2 -cd bzip2-file

bzip2 -q -t 677.bz2

bzip2 -q -t other-zip2file

A
adduser | addgroup | alias | anacron | apt | aptitude | arp | at | atq | atrm | awk
B
basename | banner | batch | bc | bg | bzip
C
cat | cal | cd | chgrp | chown | cksum | chmod | clear | cmp | comm | cp
D
date | dd | df | diff | dir | dmidecode | du
E
echo | eject | env | exit | expr
F
factor | find | free
G
grep | groups | gunzip | gzip
H
head | history | hostname | hostnamectl | htop | hwclock | hwinfo
I
id | ifconfig | ionice | iostat | ip | iptables | iw | iwlist
J
K
kill | kmod
L
last | less | ln | locate | login | lp | ls | lshw | lscpu | lsof | lsusb
M
man | mdsum | mkdir | more| mv
N
nano | nc | neofetch | netcat | netstat | nice | nmap | nproc
O
openssl
P
passwd | pidof | ping | pr | ps | pwd | pstree
Q
R
rdiff-backup | reboot | rename | rm | rmdir | rnmod
S
scp | shred | shutdown | sleep | sort | split | ssh | stat | su | sudo | sum
T
tac | tail | talk | tar | tee | time | tree | top | touch | tr
U
unalias | uname | uniq | unzip | uptime | users
V
vim | vi
W
w | wall | watch | wc | wget | whatis | whereis | which | who | whoami
X
xargs
Y
yes | youtube-dl
Z
zcmp | zdiff | zip | zz

Sharing is Caring
Scroll to Top