In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to compress Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
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 usually done through the tar command. Through man tar, you can get some information. Tar completes different actions by specifying different parameters, which are usually used. These two parameters, literally, are CCHQ create, create and subpackage extract, as well as some less commonly used parameters. For example, a, add tar to the end of another tar package, t, list the files in the package,-C, change the working directory to the specified directory, specify this parameter, you can put the extracted files in the specified directory, and so on. There is also an important parameter f, which can be packaged in a file.
Here are two simple examples to illustrate packaging and subcontracting extraction:
1. Package file, now there are 3 files, the file name is fiel1,file2,file3, package these three files into file.tar.
Tar-cf file.tar file1 file2 file3
-c, packaging mode, and-f specify the storage file of the packaging results to be created.
two。 Unpack the file, now there is a package file.tar, unpack it.
Tar-xf file.tar
-x, unpacking mode,-f specifies the tar package file.
After talking about packaging, there is no doubt about the role of compression, 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.
1. Operate with gzip
Compression: gzip file.tar (if you want to compress a file into a specified file, you can use "gzip-c file.tar > xxx", the following is the same)
Decompress: gunzip-c file.tar.gz > xfile.tar
two。 Operate with bzip2
Compression: bzip2-c file.tar > xifle.tar.bz2
Decompress: bunzip2-cv xfile.tar.bz2 > xfile.tar
3. Operate with xz
Compression: xz-c file.tar > xfile.tar.xz
Decompress: 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.
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 file1,file2,file3 into a compressed package
Tar-czvf file.tar.gz file {1pm 2pm 3}
two。 Use tar to call bzip2 to generate file1,file2,file3 into a compressed package
Tar-cjvf file.tar.bz2 file {1pm 2pm 3}
3. Use tar to call xz to generate file1,file2,file3 into a compressed package
Tar-cJvf file.tar.xz file {1pm 2pm 3}
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.
This is the end of the article on "how to compress Linux". 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 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.