11th. Compression and packaging of Linux documents

Source: Internet
Author: User
Tags rar

1. Gzip, can bzip2 directly compress the directory?
No
2. Please write quickly, using gzip and bzip2 to compress and decompress a file command.
Compressed gzip 1.txt; Decompression gzip-d 1.txt.gz

bZIP 1.txt; unzip bzip-d 1.txt.bz2
3. When the tar is packaged, how do you want to exclude multiple files or directories?
TAR-CVF File.tar--exclude.a.txt--exclude b.txt 123/
4. Please experiment, if not add "-" is correct, such as tar zcvf 1.tar.gz 1.txt 2.txt?
That's right
5. How to package and unpack with tar. tar.gz,. tar.bz2 compression pack?
TAR-ZCVF 1.tar.gz 11 22

TAR-ZXVF 1.tar.gz

TAR-JCVF 1.tar.bz2 11 22

   TAR-JXVF 1.tar.bz2
6. Find a larger file, using tar to separate the file into a. tar.gz and. tar.bz2 compression package, compare which package will be smaller, so that the conclusion is gzip compression effect is good or bzip2 compression effect is good?
  > Theoretically, the compression packets of tar.bz2 are smaller, but at individual times, there is the opposite situation. But most of the time bzip2 compression effect is good.

7. When packing and compressing with tar, what is the default compression level? Think about how you can change the compression level? (Note that tar itself does not have this function oh, you can try to split packaging and compression)
when the tar package is compressed, it is based on the default compression level of gzip and bzip2, and the Gzip tool default compression level is 6,BZIP2 default compression level is 9.
change the default compression level you can do this, first tar packaging, and then use gzip or bzip2 compression tool to compress, compress the time to specify the compression level.  such as: Tar CVF 1.tar 123/; Gzip-2 1.tar

Extended Learning:
1. Under Windows common Compression package has RAR and zip, the default RAR under Linux does not support compression and decompression, but there are related tools can be installed on the Linux platform. The ZIP package is available on both the Linux platform and the Windows platform.
Use zip compression:
zip can be compressed directory can also compress files, compressed directory, you need to specify the directory of files Oh, see example:


    1. Zip 1.txt.zip 1.txt

    2. Zip Dir1.zip dir1/*


Description: Zip followed by the target file name, that is, the compressed custom compression package name, and then the file or directory to be compressed.
Study questions: What happens when I compress a directory and write only the directory name? And in the directory there are two level directory or even more levels of directory, can also be compressed in the two-level directory files?

after finishing the experiment, I believe you have come to a conclusion and see if the answer is consistent with Amin. The answer is, when there are two levels of directories and even more levels of directory, Zip does not put the level two directory of the file compression, and just the two-level directory itself compressed, there is no cascading options? Of course, that is:

    1. Zip-r Dir1.zip dir1/

This does not require dir1/*, so remember that you must add the-r option when using the ZIP compression directory.

OK, say the compression, also say how to extract it, unzip the command is not zip, but called unzip, decompression 1.txt.zip command:

    1. Unzip 1.txt.zip

2. Use of the Bzcat command:
For text documents that use BZIP2 compression, you can use the Bzcat command to view the contents of the document directly.


    1. cp/etc/passwd./11.txt

    2. Bzip2 11.txt

    3. Bzcat 11.txt.bz2


3. Compression principle under the computer

    • Principles of compression-rar



Practical Application:

using tar to copy data over the networkHttp://www.lishiming.net/thread-152-1-2.html
How to package, compress, and unzip the tar to a specified directoryHttp://www.lishiming.net/thread-96-1-3.html
uncompressed zip package larger than 4G is not supported under LinuxHttp://www.lishiming.net/thread-1813-1-1.html


11th. Compression and packaging of Linux documents

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.