In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to compress and extract files in Linux", the content of the explanation in the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to compress and extract files in Linux"!
Compressing a file can significantly reduce the file size by encoding the data in the file with fewer bytes, and is useful when backing up and transferring files across the network. On the other hand, unzipping the file means restoring the data in the file to its original state.
There are several file compression and decompression tools in Linux, such as gzip, 7-zip, Lrzip, PeaZip, and so on.
In this tutorial, we will show you how to use the bzip2 tool to compress and extract .bz2 files in Linux.
Bzip2 is a very famous compression tool and is available on most major Linux distributions, so 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 use "bzip2" to compress files in Linux
You can compress a file as follows and use the-z flag to enable compression:
$bzip2 filename or $bzip2-z filename
To compress a .tar file, use the command:
$bzip2-z backup.tar
Important: bzip2 deletes the input file (the original file) by default when compressing and unzipping the file. To keep the input file, use the-k or-- keep option.
In addition, the-f or-- force flag forces bzip2 to overwrite existing output files.
-to keep the input file-$bzip2-zk filename $bzip2-zk backup.tar
You can also set the size of the block, from 100k to 900k, using-1 or-- fast to-9 or-- best:
$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 the option to retain the input file, force bzip2 to overwrite the output file, and set the block size in compression.
Use bzip2 to compress files in Linux
How to use "bzip2" to extract files in Linux
To extract the .bz2 file, be sure to use the-d or-- decompress option:
$bzip2-d filename.bz2
Note: this file must be a .bz2 extension for the above command to be used.
$bzip2-vd Etcher-linux-x64.AppImage.bz2 $bzip2-vfd Etcher-linux-x64.AppImage.bz2 $ls-l Etcher-linux-x64.AppImage
Extract the bzip2 file in Linux
To browse the bzip2 help and man page, enter the following command:
$bzip2-h $man bzip2 thank you for reading, the above is "how to compress and extract files in Linux" of the content, after the study of this article, I believe you on how to compress and extract files in Linux this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.