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

Example Analysis of File Compression and Packaging in Linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail the sample analysis of file compression and packaging in Linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Introduction to compressed Packaging

Common compressed files

Windows .rar .zip .7z

Linux .zip, .gz, .bz2, .xz, .tar.gz, .tar.bz2, .tar.xz

2. Gzip Compression tool

Eg. Gzip and gzip-d instance

In the following example, you can see that after compression, the actual size of the decompression has changed from 1.6m to 1.3m and the number of rows remains the same.

Gzip-# represents the compression level 1.txt (range 1-9, default 6 enhanced from 1 to 9)

Zacat 1.txt.gz is the command to view the compressed file. The operation process is to decompress the file first and then view it.

Gzip-c 1.txt > / root/1.txt.gz means to extract 1.txt to root and keep the original 1.txt file.

Bzip2 Compression tool

Compared with gzip, the compression strength is larger and the algorithm is different. The greater the compression strength, the more cpu resources are consumed. The default level specified by bizp is 9.

Note the following example, which proves that the compressed file can be changed to another name. If the txt file is prompted to be binary, you should be used to using file to view the file first.

Xz Compression tool

Not commonly used, but will encounter .tar.xz in the tar package, the compression strength is stronger than bzip

Zip Compression tool

The characteristic of zip is that the original files will not be deleted after compression.

The compressed package of zip has no way to view the content. It can only view the list of files through unzip-l, not the content.

Tar Packaging tool

What is more commonly used on Linux is the tar tool. Tar was originally just a packaging tool, but at the same time, it also implemented support for tools such as 7zMagneGzipDifference, which can only compress files or directories (files in separate compressed directories), but not files, so we do not need to learn other tools alone. The decompression and compression of tar are the same command. It is convenient to use as long as the parameters are different.

Packaging does not change much to the size of the file. The purpose is to integrate all types of files into one large file for easy transfer.

Tar-tf fred.tar views a list of files, which is equivalent to unzip-l

Package and compress, unpack and decompress

This is the end of this article on "sample analysis of file compression and packaging in 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 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.

Share To

Servers

Wechat

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

12
Report