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 original 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.
- bg command in Linux with Examples
- mv command in Linux with examples
- let command in Linux with Examples
- ip command in Linux with examples
- man command in Linux with Examples
- rev command in Linux with Examples
- fg command in Linux with examples
- du command in Linux with examples
- gs command in Linux with Examples
- pwd command in Linux with Examples
- id command in Linux with examples
- ar command in Linux with examples
- cp command in Linux with examples
- cut command in Linux with examples
- w 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.
Improved By : Akanksha_Rai