Linux platform uses different decompression commands.

Source: Internet
Author: User
Tags gz file

Linux platform uses different decompression commands.

Author: Guo Xiaoxing

Weibo: Guo Xiaoxing's Sina Weibo

Email: allenwells@163.com

Blog: http://blog.csdn.net/allenwells

Github: https://github.com/AllenWell

1. tar

Unpack

tar xvf FileName.tar

Package

tar cvf FileName.tar DirName

Note:Tar is packed, not compressed.

Ii. gz

Extract

gunzip FileName.gz

Or

gzip -d FileName.gz

Compression

gzip FileName
3. tar.gz and. tgz

Extract

tar zxvf FileName.tar.gz

Compression

tar zcvf FileName.tar.gz DirName
Iv. bz2

Extract

bzip2 -d FileName.bz2

Or

bunzip2 FileName.bz2

Compression

 bzip2 -z FileName
V.tar.bz2

Extract

tar jxvf FileName.tar.bz2

Compression

tar jcvf FileName.tar.bz2 DirName
Vi. bz

Extract

bzip2 -d FileName.bz

Or

bunzip2 FileName.bz
VII. tar. bz

Extract

tar jxvf FileName.tar.bz
VIII. Z

Extract

uncompress FileName.Z

Compression

compress FileName
IX. tar. Z

Extract

tar Zxvf FileName.tar.Z

Compression

tar Zcvf FileName.tar.Z DirName
10. Zip

Extract

unzip FileName.zip

Compression

zip FileName.zip DirName
11. rar

Extract

rar x FileName.rar

Compression

rar a FileName.rar DirName
12. lha

Extract

lha -e FileName.lha

Compression

lha -a FileName.lha FileName
13. rpm

Unpack

rpm2cpio FileName.rpm 
14. deb

Unpack

ar p FileName.deb

For packages in the following format

. Tar. tgz .tar.gz. tar. z. tar. bz .tar.bz2. zip. cpio. rpm. deb. slp. arj. rar. ace. lha. lzh. lzx. lzs. arc. sda. sfx. lnx. zoo. cab. kar. cpt. pit. sit. sea

Extract

sEx x FileName.*

Compression

sEx a FileName.* FileName

Note:SEx only calls related programs and does not support compression or decompression..

So which tool should we use if we compress files with so many tools? Next we will introduce a very useful decompression tool on the Linux platform.

Gzip command

There are two obvious advantages to reduce the file size. One is to reduce the storage space, and the other is to reduce the transmission time when the file is transmitted over the network. Gzip is a frequently used command in Linux to compress and decompress files, which is convenient and easy to use.

Syntax: gzip [Option] compressed (decompressed) file name

The options of this command are as follows:

  • -C writes the output to the standard output and keeps the original file.

  • -D. decompress the compressed file.

  • -L the following fields are displayed for each compressed file: the size of the compressed file, the size of the uncompressed file, the compression ratio, and the name of the uncompressed file.

  • -R recursively searches for the specified directory and compresses all the files or decompress the files.

  • -T test to check whether the compressed file is complete.

  • -V displays the file name and compression ratio for each compressed and decompressed file.

  • -Num: Use the specified numeric num to adjust the compression speed,

  • -1 or-fast indicates the fastest compression method (low compression ratio ),

  • -9 or-best indicates the slowest compression method (high compression ratio ). The default value is 6.

Example

Gzip * % compresses each file in the current directory into A. gz file. Gzip-dv * % decompress each compressed file in the current directory and list detailed information. Gzip-l * % detailed information of each compressed file in Example 1 is displayed without decompression. Gzip usr.tar %: the compressed tar backup file usr.tar. the extension name of the compressed file is .tar.gz.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.