Linux file packaging, compression detailed

Source: Internet
Author: User

Under the Linux platform, there are several common compression tools:

=========================================================================
工 具 文件扩展名 描述
-------------------------------------------------------------------------
bzip2 .bz2 采用Burrows-Wheeler块排序文本压缩算法和霍夫曼编码
compress .Z 原始的Unix文件压缩工具,逐渐消失中
gzip .gz GNU压缩工具,用Lempel-Ziv编码
zip .zip Windows上PKZIP工具的Unix实现
=========================================================================

1.bzip2
1) bzip2: Used to compress files
2) Bzcat: Used to display compressed text file contents
3) BUNZIP2: Used to decompress. bz2 files
4) Bzip2recover: Used to try to recover corrupted compressed files
Usage:

$ bzip2 file

By default, the BZIP2 command attempts to compress the original file and replace it with the compressed file (the same file name plus the. bz2 extension).
Extract:

$ bunzip2 file.bz2

If file is a text document, you can view it with Bzcat:

$ bzcat file.bz2

2.gzip
1) gzip: Compress files
2) Gzcat: View Compressed text file
3) Gunzip: Unzip the file
Usage is the same as bzip2.

3.tar
Command format for tar:

tar function [options] object1 object2

The

Function parameter defines what the tar command should do, such as the following table:

===================================================== =======================
Description of the full name of the feature
----------------------------------------------------------------------- -----
-A--concatenate to append an existing tar archive file to another existing tar archive
-C--create Create a new tar archive file
-d--diff Check the differences between the archive and the file system
--delete Remove the
-r--append append file from the existing tar archive file to the end of the existing tar archive
-T--list lists the contents of the existing tar archive
-u--update Append a new file with the same name as the one already in the TAR archive file to the TAR archive
-X--extract Extract the file from the existing tar archive
=========================================== =================================

Each feature is available with options to define a specific behavior for the TAR archive file. The following table lists the most common options that can be used with the tar command in these options.

==================================================================
选 项 描 述
------------------------------------------------------------------
-C dir 切换到指定目录
-f file 输出结果到文件或设备file
-j 将输出重定向给bzip2命令来压缩
-p 保留所有文件权限
-v 在处理文件时显示文件
-z 将输出重定向给gzip命令来压缩
==================================================================

Typically, these options are used together.
For example, you can create an archive file with the following command:

tar -cvf test.tar test/ test2/

The above command creates a Test.tar archive containing the contents of the test and test2 directories.
Then, with this command,

tar -tf test.tar

Lists the contents of the tar file Test.tar, but does not unzip it.
Finally, use the following command

tar -xvf test.tar

Extract content from Test.tar.

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.