linux--Compression and packaging operations

Source: Internet
Author: User
Tags bz2

2017-08-11 19:34:09 @ but may this heart have no grudge

A simple summary of the common methods for compressing and packaging files in Linux today

File compression is mainly compress, gzip, bzip2, XZ, zip

Since several of the commonly used compression command usages are roughly the same, I'll summarize them together and then differentiate between them separately.

Compression commands are commonly used as follows

Compress: suffix . z, available unconpress Decompression, maintain the original file permissions, available zcat Viewing the contents of a compressed file is not decompressed, so you can export it with a redirect, which is equivalent to keeping the source file uncompressed, but the permissions change because a new file is created.

Gzip: suffix . gz, you can specify the compression series -1 to -9. the greater the compression effect, the better it can be used Gunzip to decompress, use Zcat Keep The source file decompression operation with the above.

bzip2: suffix is . bz2, the spoken language specifies the compression series, can be decompressed using bunzip2 , can be bzcat with the above zcat The same operation,the-k option, which means to keep the source file and compress.

There are options for the 3 compression commands above :

-V shows the details of the operation

-D Decompression

-C View compressed file contents

XZ:- K means to keep the source files compressed;-D for decompression;xzcat with zcat and Bzcat, do not repeat.

Zip:zip-r Compressed after the name needs to compress the file

Unzip unzip filename

Test the individual compression commands as follows

/app Create a 5 25M file, respectively, using the 5 compression commands to compress, view the compression effect

can see in terms of compression effect XZ best, followed by bzip2, in time above, also xz faster, actually Man the xz Help document can also be found thatthe minimum compression ratio of XZ is also better than the rest of the compression effect, and faster.

Zip can be implemented in the packaging of files and compression, in fact, the operation of multiple files at the same time, other interested in their other usage of children's shoes can self-view documents or related Materials learning.

Tar for packaging operations

syntax format tar custom package name requires a packaged file name

Common function options are as follows

-C Create package

-F Specify a new name

-RF Append a new file to the package

-TF viewing files in a package

-V Listing details

--delete-f Deleting a file from a package

-X extracting files from the package

-C Specifies unpacking in the new directory

test below, copy four files to /app , and perform the following test operations

Package these four files and find that the source files are not deleted

Add the file createsh.sh to the package and find that the source file is not deleted

Delete the file createsh.sh in the package, implemented as follows

Extracting a file from a package passwd, the actual test finds that the file still exists in the package after extraction

Extracts all the files in the package to the Dir directory in the current directory, and the source package is not deleted

Extended: (also frequently used for packaging and compression operations)

-JCF packaged and compressed to . XZ

-JCF packaged and compressed to . bz2

-ZCF packaged and compressed to . GZ

Test as follows

Package and compress the operation, and then use the file command to view the type of document travel after the operation, as expected.

Ps:

1, Linux file name does not have a suffix limit, but for the above compression and packaging operation of the file name, we can test it yourself, if the name is not specified name can also be decompression operation, after the author test, if the name is not the corresponding suffix and decompression operations, Do not unzip the operation or keep the compressed file, regenerate an extracted file, interested children shoes can self-test.

2, for the above packaging compression operation, there is no change in the permissions of the file, if the use of a redirect to create a new file to extract the operation will change the permissions of the file, because the new file is generated, the permissions are the default permissions minus the value of umask, interested children's shoes can consult the relevant information.

linux--Compression and packaging operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.