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

What is the Linux compressed file format?

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

Share

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

In this issue, the editor will bring you a summary of the Linux compressed file format. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

For those who have just come into contact with Linux, it is bound to confuse Linux with all kinds of file names. Not to mention, just taking compressed files as an example, we know that there are only two most common compressed files under Windows, one is zip, and the other is .rar. But Linux is different. It has .gz, .tar.gz, tgz, bz2, .Z, .tar and many other compressed file names. In addition, .zip and .rar under windows can also be used under Linux, but there are too few people using .zip and .rar in Linux.

Before summarizing all kinds of compressed files, we should first clarify two concepts: packaging and compression.

Packaging refers to turning a large pile of files or directories into a total file, while compression is turning a large file into a small file through some compression algorithms. Why distinguish between these two concepts? In fact, this is because many compression programs in Linux can only compress a file, so when you want to compress a lot of files, you have to use another tool to pack the pile of files into a package, and then compress the original compression program.

The most commonly used packaging program under Linux is tar. Packages typed by tar programs are often called tar packages, and commands for tar package files usually end with .tar. After you generate the tar package, you can compress it with other programs, so let's first talk about the basic usage of the tar command:

There are many options for the tar command (you can see them with man tar), but there are only a few commonly used options. Here's an example:

# tar-cf all.tar * .jpg

This command is to type all .jpg files into a package called all.tar. -c means to generate a new package, and-f specifies the file name of the package.

# tar-rf all.tar * .gif

This command adds all .gif files to the all.tar package. -r means to add files.

# tar-uf all.tar logo.gif

This command updates the logo.gif file in the original tar package all.tar, and-u means to update the file.

# tar-tf all.tar

This command lists all the files in the all.tar package.-t means to list files.

# tar-xf all.tar

This command is to unlock all the files in the all.tar package, and-x means to unlock the above is the most basic use of tar. In order to make it convenient for users to compress or extract files while packing and unpacking, tar provides a special function. This means that tar can call other compression programs, such as gzip, bzip2, etc., while packaging or unpacking.

1) tar calls gzip

Gzip is a compression program developed by GNU, and the file at the end of .gz is the result of gzip compression. And gzip

The relative decompression program is gunzip. The parameter-z is used in tar to call gzip. Here is an example:

# tar-czf all.tar.gz * .jpg

This command forms all .jpg files into a tar package and compresses it with gzip to generate a gzip-compressed package named all.tar.gz

# tar-xzf all.tar.gz

This command is to unlock the package generated above.

2) tar calls bzip2

Bzip2 is a more powerful compression program, and the file at the end of .bz2 is the result of bzip2 compression. The decompression program as opposed to bzip2 is bunzip2. The parameter-j is used in tar to call gzip. Here is an example:

# tar-cjf all.tar.bz2 * .jpg

This command forms all .jpg files into a tar package and compresses it with bzip2 to generate a bzip2-compressed package named all.tar.bz2

# tar-xjf all.tar.bz2

This command is to unlock the package generated above.

3) tar calls compress

Compress is also a compression program, but it seems that not as many people use compress as gzip and bzip2. The file at the end of .Z is the result of compress compression. The decompression program as opposed to compress is uncompress. The parameter-Z is used in tar to call compress. Here is an example:

# tar-cZf all.tar.Z * .jpg

This command is to package all .jpg files into a tar package and compress it with compress to generate

A uncompress compressed package named all.tar.Z

# tar-xZf all.tar.Z

With the above knowledge, you should be able to unlock a variety of compressed files. Here is a summary of the compressed files of the tar series:

1) for files at the end of .tar

Tar-xf all.tar

2) for files ending with .gz

Gzip-d all.gz

Gunzip all.gz

3) for files ending with .tgz or .tar.gz

Tar-xzf all.tar.gz

Tar-xzf all.tgz

4) for files at the end of .bz2

Bzip2-d all.bz2

Bunzip2 all.bz2

5) for files at the end of tar.bz2

Tar-xjf all.tar.bz2

6) for files ending with .Z

Uncompress all.Z

7) for files ending with .tar.Z

Tar-xZf all.tar.z

In addition, for the common compressed files .zip and .rar under Window, Linux also has methods to extract them:

1) for .zip

Zip and unzip programs are provided under linux. Zip is the compression program and unzip is the decompression program. There are many options for their parameters. Here is only a brief introduction, and an example is still given to illustrate their usage:

# zip all.zip * .jpg

This command compresses all .jpg files into a zip package

# unzip all.zip

This command unzips all the files in all.zip

2) for .rar

To process .rar files under linux, you need to install RARfor Linux, which you can download from the Internet, but remember, RARfor Linux is not free; download RARfor Linux 3.2.0 from http://www.rarsoft.com/download.htm, and then install:

# tar-xzpvf rarlinux-3.2.0.tar.gz

# cd rar

# make

After installation, there are two programs: rar and unrar. Rar is the compression program and unrar is the decompression program. There are many options for their parameters. Here is only a brief introduction, and an example is still given to illustrate their usage:

# rar an all * .jpg

This command compresses all .jpg files into a rar package called all.rar, which automatically appends the .rar extension to the package name.

# unrar e all.rar

This command unzips all the files in all.rar.

So far, we have introduced tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, rar, unrar and other software under linux, and you should be able to use them on .tar, .gz, .tar.gz, .tgz, .bz2, .tar.bz2. Z, .tar.Z, .zip, .rar

You should not need to worry about downloading a piece of software and not knowing how to unzip it under Linux. And the above methods are basically effective for Unix.

The above is the summary of the Linux compressed file format shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow 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

Servers

Wechat

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

12
Report