bzip2 command in Linux is used to compress and decompress the files i.e. it helps in binding the files into a single file which takes less storage space as the original file use to take. It has a slower decompression time and higher memory use. It uses Burrows-Wheeler block sorting text compression algorithm, and Huffman Coding. Each file is replaced by a compressed version of itself, with the name original name of the file followed by extension bz2.
bzip2 [OPTIONS] filenames ...
- -z : This option forces compression. It is an opposite command of decompression i.e. -d Option.
$ bzip2 -z input.txt
Note: This option deletes the orignal file also.
- -k: This option does compression but does not deletes the original file.
$ bzip2 -k input.txt
- -d : This option is used for decompression of compressed files.
$ bzip2 -d input.txt.bz2
- -t : This option does the integrity check of the file and does not decompresses the file. It gives us the idea that the file is corrupt or not.
$ bzip2 -t input.txt.bz2
- -v : Verbose mode show the compression ratio for each file processed. It also increases the verbosity level, spewing out lots of information which is primarily of interest for diagnostic purposes.
$ bzip2 -v input.txt
- -h –help : To display the help message and exit.
- -L –license -V –version : It is used to display the software version, license terms, and conditions.
- -q –quiet : It will suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed.
- -f –force : It will force overwrite of output files.
- bc command in Linux with examples
- cpp command in Linux with Examples
- dir command in Linux with examples
- pwd command in Linux with Examples
- arp command in Linux with examples
- tar command in Linux with examples
- gdb command in Linux with examples
- which command in Linux with examples
- rev command in Linux with Examples
- for command in Linux with Examples
- mv command in Linux with examples
- cd command in Linux with Examples
- atq command in linux with examples
- let command in Linux with Examples
- cc command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.