In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail which compression commands are commonly used in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Packaging refers to putting multiple files or directories together to form a total package, so that it is easy to save and transfer, but the size does not change. Compression refers to one or more large files or directories through the compression algorithm to reduce the size of the file to achieve the purpose of compression, can save storage space, in compression is usually the first package and then compression.
About tar, Linux compression, Linux compression, those things.
Linux's compression command can only have one source file, which means that before compressing, you have to package all the files you want to compress into a package, and then compress the package to complete the compression of multiple files. So you must know the packaging command before you can understand the decompression. The packaging of Linux is generally completed through the tar command, and different actions are accomplished by specifying different parameters with tar, which is usually used. These two parameters literally mean "CQ tar, create and subpackage extract," as well as some commonly used parameters, such as an adding tar to the end of another tar package, and t listing the files in the package. -C changes the working directory to the specified directory, and by specifying this parameter, you can put the extracted files in the specified directory. There is also an important parameter f, which can be packaged in a file.
Tar packing and unpacking
1. Package Fil
Package fiel1,file2,file3 into file.tar:
Tar-cf file.tar file1 file2 file3
-c packaging mode-f specifies the packaging result storage file to be created
two。 Unpack a file
Now there is a package file.tar that unpacks it:
Tar-xf file.tar
-x unpacking mode-f specifies the tar package file
Brief introduction of Compression Software
GZIP was originally created by Jean-loup Gailly and Mark Adler for file compression on UN Ⅸ systems. We often use files with the suffix .gz in Linux, which are in GZIP format. Nowadays, it has become a very common data compression format, or a file format, which is widely used on Internet. Bzip2 is a lossless compression software based on Burrows-Wheeler transform, and the compression effect is better than the traditional LZ77/LZ78 compression algorithm. Bzip2 is capable of high-quality data compression. It uses advanced compression technology, can compress ordinary data files by 10% to 15%, and the compression speed and decompression efficiency are very high! Most compression formats are supported, including tar, gzip, and so on.
There is no doubt about the role of compression, once a thing becomes simpler, all aspects of the operation is more simple, Linux compression generally has several ways, they are gzip compression, bzip2 compression, xz compression. Their input is only one, the following is an example, respectively use these three compression methods to compress file.tar, and then decompress the compressed files in these three ways to generate xfile.tar, because the simple decompression and compression are not the focus of this article, so some parameters will not be introduced, but will be briefly introduced when needed.
Use of compression software
1. Operate with gzip
Compression: gzip file.tar (compress the file into the specified file, use "gzip-c file.tar > file.tar.gz") extract: gunzip file.tar.gz (compress the file into the specified file, use "gzip-c file.tar > file.tar.gz")
two。 Operate with bzip2
Compression: bzip2-c file.tar > xifle.tar.bz2 decompression: bunzip2-cv xfile.tar.bz2 > xfile.tar
3. Operate with xz
Compression: xz-c file.tar > xfile.tar.xz decompression: unxz-c xfile.tar.xz > xfile.tar
As far as compression is concerned, compression ratio is obviously the primary concern. In terms of compression ratio, xz > bzip2 > gzip, generally speaking, xz can achieve 15% higher compression ratio than bzip2 and 30% higher compression ratio than gzip, but there are other things that need to be concerned about in specific situations, such as CPU share. Although xz has a high compression ratio, it takes the most time, which means it takes up more CPU time slices. Therefore, when choosing the compression algorithm, we should also consider what is the primary concern now, so as to choose the compression algorithm.
Tar compression and decompression
The above described packaging and decompression of these two processes, but the two processes are separate, under normal circumstances, the two processes will not be separated, but with tar package step by step multiple files into a compressed package, the following will use the tar command to call these three compression methods to complete a step of multiple files packaged and compressed into a compressed package.
1. Use tar to call gzip to generate a compressed package of file1,file2,file3 and decompress it.
Compression: tar-czvf file.tar.gz file {1 ~ 2 ~ 5 ~ 3} decompression: tar-xzvf file.tar.gz
two。 Use tar to call bzip2 to generate a compressed package of file1,file2,file3 and decompress it.
Compression: tar-cjvf file.tar.gz file {1 ~ 2 ~ 5 ~ 3} decompression: tar-xjvf file.tar.gz
3. Use tar to call xz to generate a compressed package of file1,file2,file3 and decompress it.
Compression: tar-cJvf file.tar.gz file {1 ~ 2 ~ 5 ~ 3} decompression: tar-xJvf file.tar.gz
For the above text, it should be noted that the suffix name is not necessary, the suffix name in Linux is not necessary, this should be a basic point, the reason for specifying the suffix name is to facilitate the distinction, but also to facilitate some rough identification procedures.
About "what are the commonly used compression commands in Linux" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
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.