Linux compression helper bzip2

Source: Internet
Author: User

Linux compression helper bzip2
GuideTo compress a file, you can use a small number of bytes to encode the data in the file to significantly reduce the file size, and it is useful for cross-network file backup and transfer. On the other hand, decompression means that the data in the file is restored to the initial state.

Linux has several File compression and decompression tools, such as gzip, 7-zip, Lrzip, and PeaZip.

In this tutorial, we will introduce how to use the bzip2 tool in Linux to compress and decompress the. bz2 file.

Bzip2 is a well-known compression tool available in most mainstream Linux distributions. you can install it with appropriate commands on your release.

$sudoaptinstallbzip2[OnDebian/Ubuntu]$sudoyuminstallbzip2[OnCentOS/RHEL]$sudodnfinstallbzip2[OnFedora22+]

The general syntax for using bzip2 is:

$bzip2option(s)filenames
How to use "bzip2" to compress files in Linux

You can use the-z flag to enable compression for a file as follows:

$ Bzip2filename or $ bzip2-zfilename

To compress a. tar file, run the following command:

$bzip2-zbackup.tar

Important: bzip2 will delete the input file (original file) during File compression and decompression by default. to retain the input file, use the-k or -- keep option.

In addition, the-f or -- force flag forces bzip2 to overwrite existing output files.

--------To reserve the input file ------20.bzip2-zkfilename1_bzip2-zkbackup.tar

You can also set the block size, from 100 k to 900 k, respectively using-1 or -- fast to-9 or -- best:

$bzip2-k1Etcher-linux-x64.AppImage$ls-lhEtcher-linux-x64.AppImage.bz2$bzip2-k9Etcher-linux-x64.AppImage$bzip2-kf9Etcher-linux-x64.AppImage$ls-lhEtcher-linux-x64.AppImage.bz2

The screenshot below shows how to use options to retain the input file, force bzip2 to overwrite the output file, and set the block size during compression.

Use bzip2 to compress files in Linux

How to Extract files using "bzip2" in Linux

To decompress the. bz2 file, make sure to use the-d or -- decompress options:

$bzip2-dfilename.bz2

Note: This file extension is. bz2, which can only be used by the preceding command.

$bzip2-vdEtcher-linux-x64.AppImage.bz2$bzip2-vfdEtcher-linux-x64.AppImage.bz2$ls-lEtcher-linux-x64.AppImage

Decompress the bzip2 File in Linux

To view the bzip2 help and man page, enter the following command:

$bzip2-h$manbzip2

Finally, I believe that you can compress and decompress the bz2 file in Linux. However, if you have any questions or feedback, you can leave a message in the comment area.

Importantly, you may want to view some important tar command examples in Linux to learn how to use the tar command to create compressed archive files.

From: http:// OS .51cto.com/art/201611/521694.htm

Address: http://www.linuxprobe.com/linux-bz2-file.html


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.