Linux system management and maintenance -gzip/gunzip command

  
 

1. The function description compresses or decompresses the general file. The default extension of the compressed file is “.gz”, in fact, gunzip is a hard link to gzip, so whether it is compression or decompression can be achieved by gzip.

Note gzip can only compress files, not directories, even if you specify a compressed directory, you can only compress all files in the directory. The format is as follows: gzip [options] Compressed (decompressed) document name The options for the gzip command and their descriptions are shown in Table 4.29. Table 4.29 Options and Descriptions of the gzip Command

Option Meaning-d Decompress the compressed file -r Recursively compress all files in the specified directory and subdirectories -t Check the integrity of the compressed document -v Each compressed and decompressed document, showing the corresponding file name and compression ratio -l shows the compressed information of the compressed file, the display fields are compressed document size, uncompressed document size, compression ratio and uncompressed document name -num with the specified number num Configure the compression ratio, “-1” or “-fast” indicates the lowest compression ratio, “-9” or “-best” indicates the highest compression ratio. The system default compression ratio is 6. 2. For example, (1) first compress all the files and subdirectories in the /etc directory, back up the compressed package etc.zip to the /opt directory, and then gzip the etc.zip file to set the compression level of gzip to 9. [root@mylinux ~]#zip –r /opt/etc.zip /etc[root@mylinux ~]#gzip -9v /opt/etc.zipetc.zip: 6.5% -- replaced with etc.zip.gz( 2) View the compression information of the above etc.zip.gz file. [root@mylinux ~]# gzip -l /opt/etc.zip.gz compressed uncompressed ratio uncompressed_name11938745 12767265 6.5% /opt/etc.zip(3) Decompress the above etc.zip.gz file to the current directory. [root@mylinux ~]#gzip –d /opt/etc.zip.gz Or execute [root@mylinux ~]#gunzip /opt/etc.zip.gz by the above example to know "gzip –d" Equivalent to the “gunzip” command.

Copyright © Windows knowledge All Rights Reserved