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.
- atq command in linux with examples
- ip command in Linux with examples
- bg command in Linux with Examples
- dc command in Linux with examples
- fmt command in Linux with examples
- man command in Linux with Examples
- for command in Linux with Examples
- mv command in Linux with examples
- id command in Linux with examples
- apt-get command in Linux with Examples
- seq command in Linux with Examples
- fg command in Linux with examples
- tty command in Linux with examples
- until command in Linux with Examples
- Cat 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 email@example.com. 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.