Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use bzip2 under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you how to use bzip2 under Linux. The content is simple and easy to understand. It is clearly organized. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn how to use bzip2 under Linux.

bzip2 is a lossless compression software based on Burrows-Wheeler transform, compression effect is better than the traditional LZ77/LZ78 compression algorithm.

There are several file compression and decompression tools in Linux, such as gzip, 7-zip, Lrzip, PeaZip, etc.

bzip2 is a very famous compression tool and is available on most major Linux distributions, you can install it on your distribution with the appropriate command.

$ sudo apt install bzip2 [On Debian/Ubuntu]$ sudo yum install bzip2 [On CentOS/RHEL]$ sudo dnf install bzip2 [On Fedora 22+]

The general syntax for using bzip2 is:

$ bzip2 option(s) filenames

How to compress files using "bzip2" in Linux

You can compress a file as follows, using the-z flag to enable compression:

$ bzip2 filename or $ bzip2 -z filename

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

$ bzip2 -z backup.tar

Important: bzip2 deletes input files (original files) by default when compressing and decompressing files. To keep input files, use the-k or-keep option.

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

------To keep input files-----$ bzip2 -zk filename$ bzip2 -zk backup.tar

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

$ bzip2 -k1 Etcher-linux-x64.AppImage$ ls -lh Etcher-linux-x64.AppImage.bz2$ bzip2 -k9 Etcher-linux-x64.AppImage$ bzip2 -kf9 Etcher-linux-x64.AppImage$ ls -lh Etcher-linux-x64.AppImage.bz2

The screenshot below shows how to use options to preserve input files, force bzip2 to overwrite output files, and set block size in compression.

Using 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 option:

$ bzip2 -d filename.bz2

Note: This file must have a.bz2 extension for the above command to work.

$ bzip2 -vd Etcher-linux-x64.AppImage.bz2$ bzip2 -vfd Etcher-linux-x64.AppImage.bz2$ ls -l Etcher-linux-x64.AppImage

Unzip bzip2 file in Linux

To browse the help and man pages of bzip2, type the following command:

$ bzip2 -h$ man bzip2

Finally, with the above simple explanation, I believe you can now compress and decompress bz2 files in Linux. However, any questions and feedback can be left in the comments section.

Importantly, you may want to check out some important tar command examples in Linux to learn how to use tar to create compressed archives.

The above is "how to use bzip2 under Linux" all the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report