Open In App

bzip2 command in Linux with Examples

Last Updated : 22 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Syntax:

bzip2 [OPTIONS] filenames ...

Options:

  • -z : This option forces compression. It is an opposite command of decompression i.e. -d Option.
    $ bzip2 -z input.txt

    Example:

    Note: This option deletes the original file also.

  • -k: This option does compression but does not deletes the original file.
    $ bzip2 -k input.txt

    Example:

  • -d : This option is used for decompression of compressed files.
    $ bzip2 -d input.txt.bz2

    Example:

  • -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

    Example:

  • -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

    Example:

  • -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.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads