Compression and decompression commands under Linux Gzip/gunzip

Source: Internet
Author: User
Tags gz file unpack

Yum Install Zip gzip    (--Install the compression tool)

gzip command

The gzip command is used to compress files. Gzip is a widely used compression program, after which the file is compressed, and its name is followed by a number of ". Gz" extensions.

Gzip is a frequently used Linux system command to compress and decompress files, which is both convenient and useful. Gzip not only compresses large, less-used files to conserve disk space, but also, together with the TAR commands, forms the most popular compressed file format in the Linux operating system. According to statistics, the gzip command has a 60%~70% compression rate for text files. There are two obvious benefits of reducing file size, one is to reduce storage space, and the other is to reduce transmission time when transferring files over the network.

Options:

-A: Use ASCII text mode;

-D: Unpack the compressed file;

-F: Forcibly compress the file. Ignores the existence of a file name or a hard connection and whether the file is a symbolic connection;

-H: Online help;

-L: Lists information about compressed files;

-L: Display version and copyright information;

-N: When compressing the file, the original file name and time stamp are not saved;

-N: Save the original file name and time stamp when compressing the file;

-Q: No warning message is displayed;

-R: Recursive processing, all files and subdirectories under the specified directory are processed together;

-S or < compress the tail string > or----suffix< compress the tail string;: Change the compressed word tail string;

-T: Test that the compressed file is correct;

-V: Displays the instruction execution process;

-V: Displays version information;

-< compression efficiency;: Compression efficiency is a value between 1~9, the default value is "6", specifying the larger the value, the higher the compression efficiency;

--best: The effect of this parameter is the same as specifying the "-9" parameter;

--fast: The effect of this parameter is the same as specifying the "-1" parameter.

Instance

1. Compress each file in the Test6 directory into a. gz file

Gzip *

2. Unzip each compressed file in the example above and list the detailed information

GZIP-DV *

3. Display the information of each compressed file in detail in Example 1, and

Gzip-l *

4. Compress a tar backup file, at which time the zip file has the extension. tar.gz

Gzip-r Log.tar

5. Recursive compression directory

GZIP-RV Test6

In this way, all the files below the test become *.gz, and the directory still exists just as the files in the directory become *.gz. This is compression, and packaging is different. Because it is a directory operation, you need to add the-r option so that you can recursively return subdirectories.

6. Recursively unzip the directory

GZIP-DR Test6

Gunzip command

The Gunzip command is used to extract the files. Gunzip is a widely used decompressor that unlocks files that have been compressed by gzip, which are preset with the last extension. gz. In fact Gunzip is the hard connection of gzip, so either compression or decompression can be done separately via the gzip instruction.

Options:

-A: Use ASCII text mode;

C: Output the extracted files to the standard output device;

-F: Forcibly unpack the compressed file, ignoring the existence of the file name or hard connection and whether the file is a symbolic connection;

-H: Online help;

-L: Lists information about compressed files;

-L: Display version and copyright information;

-N: When decompressed, if the compressed file contains the original file name and time stamp, it will ignore the non-processing;

-N: When decompressed, if the compressed file contains the original file name and time stamp, it will be stored back to the unpacked file;

-Q: No warning message is displayed;

-R: Recursive processing, all files and subdirectories under the specified directory are processed together;

-S or < compress the tail string > or----suffix< compress the tail string;: Change the compressed word tail string;

-T: Test that the compressed file is correct;

-V: Displays the instruction execution process;

-V: Displays version information;

Instance:

1. First compress all files and subdirectories in the/etc directory, back up the compressed package etc.zip to the/OPT directory, and then gzip compress the Etc.zip files, setting the compression level of gzip to 9.

Zip-r/root/test/iso.zip iso/

[Email protected] test]# gzip-9v iso.zip

2. View the compression information for the above etc.zip.gz file.

Gzip-l/opt/etc.zip.gz

Compressed uncompressed ratio uncompressed_name

11938745 12767265 6.5%/opt/etc.zip

3. Unzip the above etc.zip.gz file to the current directory.

[[Email protected] ~] #gzip –d/opt/etc.zip.gz

or perform

[[Email protected] ~] #gunzip/opt/etc.zip.gz

The above example lets you know that gzip–d is equivalent to the Gunzip command.

Compression and decompression commands under Linux Gzip/gunzip

Related Article

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.