Compression of Linux commands

Source: Internet
Author: User

Compression

1. The concept of compression

1) Purpose of compression

When you pass files over the network, you can compress the files and then pass the compressed files, reducing network bandwidth

After the recipient accepts the file, unzip it

2) Type of compression

lossy compression and lossless compression

A) lossy compression

such as MP4 video files, even if the compression process to reduce the number of frame data, the viewer is not affected. Of course MP3 music files are also lossy compression

b) Lossless compression

such as the compression of ordinary files, in order to ensure the correct delivery of information, do not want the file after compression or decompression, there is a problem.

Common compression commands under Linux

Section:

Compression of individual files we use gzip and bzip2

Multiple Files We use tar

Popular options for Gzip

-L (list) lists the contents of the compressed file

-K (keep) preserves input files when compressing or decompressing

-D (decompress) unzip the compressed file

1) View

Gzip-l Compressed file name

For example: Gzip-l pwd.1.gz

2) Unzip

GZIP-KD Compressed file name

GZIP-KD pwd.1.gz

The file is a single file that ends in. gz

3) compression

Gzip-k Source file name

Such as:

Gzip-k Mypwd.1

Got a zip file ending with a. gz

Note: 1) If Gzip does not have any option to compress at this time, a compressed file with the suffix. GZ is generated and the original file is deleted

Therefore, it is recommended to use Gzip-k to compress the source file

2) The same file content, different file names, compression size is also different

3) gzip can only compress individual files and cannot compress directories

Bzip2 compressing individual files

-K (keep) preserves input files when compressing or decompressing

-D (decompress) unzip the compressed file

1) compression

Bzip-k Source file name

Such as:

Bzip-k Mypwd.1

Get a zip file with a bz2 suffix

2) Unzip

BZIP-KD Source file name

Such as:

BZIP-KD mypwd.1.bz2

Attention:

1) If the bzip2 does not have any option, this time compression will generate a compressed file with the suffix. bz2 and delete the original file.

Therefore, it is recommended to use Bzip2-k to compress the source file

2) bzip2 can only compress a single file, cannot compress the directory

Compression of individual files using gzip or bzip2

Compression has two parameters: 1) compression time 2) Compression ratio

In general, small files with gzip compression; large files with bzip2 compression


This article from "Van Gogh said my brain is sick" blog, declined reprint!

Compression of Linux commands

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.