The compression tool under Linux

Source: Internet
Author: User
Tags bz2 cpu usage

Introduction to the Compression tool

Compress the server's frequently accessed files, such as Web pages, to compress and save bandwidth resources
Linux packaging tools, suffix name in Linux does not mean the actual meaning, but in order to facilitate the separation of file types, the suffix name is a specification to name
. zip. gz. bz2. XZ compression format
. tar.gz. tar.bz2. TAR.XZ Packaging format

Gzip Compression Tool

-D Decompression
-C compress or decompress retain original file, specify directory path
First, prepare a larger file for the size comparison after compression

[[email protected] tmp]# du -h wen.txt           准备压缩的文件2.9M    wen.txt[[email protected] tmp]# gzip wen.txt [[email protected] tmp]# du -h wen.txt.gz            压缩文件后查看大小784K    wen.txt.gz[[email protected] tmp]# gzip -d wen.txt.gz          对文件解压缩[[email protected] tmp]# du -h wen.txt 2.9M    wen.txt
压缩级别:压缩对一个文件采取何种的压缩比,范围1-9,默认是6级别9和级别1的压缩比的大小比较[[email protected] tmp]# gzip -9 wen.txt [[email protected] tmp]# du -h wen.txt.gz 780K    wen.txt.gz                         9级别的压缩大小[[email protected] tmp]# gzip -d wen.txt.gz [[email protected] tmp]# gzip -1 wen.txt [[email protected] tmp]# du -h wen.txt.gz 912K    wen.txt.gz                          1级别的压缩大小

Gzip compression when extracting the original file with the-C option, Gzip cannot be used to compress the directory
Use Zcat to view the contents of a compressed file

[[email protected] tmp]# gzip -c wen.txt > wen.txt.gz[[email protected] tmp]# ll总用量 3732-rw-r--r-- 1 root root 3017434 6月 21 15:54 wen.txt-rw-r--r-- 1 root root 800660 6月 21 16:12 wen.txt.gz           压缩文件并保留了原文件[[email protected] tmp]# gzip -c -d wen.txt.gz  /tmp/wen.txt    gzip指定解压压缩文件到指定的目录
BZIP2 Compression Tool

BZIP2 compressed file than gzip compression ratio, same as gzip does not support compression directory, same with GZIP compression level, default Level 9
Options:
-D Decompression
-C compress or decompress retain original file, specify directory path
Bzcat compressing files; viewing compressed file contents

[[email protected] tmp]# bzip2 wen.txt[[email protected] tmp]# du -h wen.txt.bz2 288K    

XZ Compression Tool
XZ compression tool is larger than gzip, bzip2 compression ratio, natural CPU usage is also high, but the basic usage is similar, also does not support directory compression
Options:
-D decompression, UNXZ is also the decompression command
-C Specify the decompression location (keep the original file)
Compress a file

[[email protected] tmp]# xz wen.txt[[email protected] tmp]# du -h wen.txt.xz 52K wen.txt.xz

XZ specifies and extracts a compressed file to the specified directory and renames it

[[email protected] tmp]# xz -d -c wen.txt.xz > /usr/local/src/1.txt.xz[[email protected] tmp]# ll !$ll /usr/local/src/1.txt.xz-rw-r--r-- 1 root root 3017434 6月 21 16:51 /usr/local/src/1.txt.xz [[email protected] tmp]# file !$file /usr/local/src/1.txt.xz           这里重命名为.xz结尾的了,实质上是一个txt文档文件/usr/local/src/1.txt.xz: C source, UTF-8 Unicode text, with very long lines

These compression tools do not support directory compression, the same is the compression level of running, compression ratio of the largest tool is XZ, can be as small as possible to compress files

The compression tool under Linux

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.