What is a compressed file? What is the principle?
Simply said, is compressed software compressed files called compressed files, the principle of compression is the binary code of the file compression, the adjacent 0,1 code to reduce,
For example, there are 000000, you can turn it into 6 0 60来 reduce the file space, with the understanding of compression is the same principle to restore the data back.
What formats of compressed files are in the Linux environment?
Common compressed files are *.tar,*.tar.gz,*.tgz,*.gz,*. Z,*.BZ2, why are there so many compressed files? This is because Linux supports a very good number of compression commands,
and different commands use compression technology is not the same, of course, before each other may not be able to exchange compression/decompression.
The following are the compression programs for the compressed files in different formats:
650) this.width=650; "title=" image_thumb[2] "style=" BORDER:0PX;WIDTH:421PX;HEIGHT:137PX; "border=" 0 "alt=" Image_ THUMB[2] "src=" Http://img1.51cto.com/attachment/201407/1/8926377_1404232688DemJ.png "height=" 137 "width=" 421 " Hspace= "0" vspace= "0"/>
The common compression commands on Linux are gzip and bzip2, and compress is no longer popular!
Gzip Description:
Use: gzip [options] File name
Options:
650) this.width=650; "title=" image_thumb[6] "style=" border:0px;width:420px;height:140px; "border=" 0 "alt=" Image_ THUMB[6] "src=" http://img1.51cto.com/attachment/201407/1/8926377_1404232688L7K9.png "height=" "width=" 420 " Hspace= "0" vspace= "0"/>
Usage:
1. #gzip filename does not add parameters will delete the original file
2. #gzip –c filename > filename.gz The compressed file redirection output
3. #gzip –d filename.gz will unzip the file
4. #gunzip filename.gz will unzip the file, it will delete the original filename.gz file
5. #zcat filename.gz to view the file
BZIP2 Introduction:
Use: bzip2 [options] File name
Options:
650) this.width=650; "title=" image_thumb[9] "style=" BORDER:0PX;WIDTH:427PX;HEIGHT:147PX; "border=" 0 "alt=" Image_ THUMB[9] "src=" http://img1.51cto.com/attachment/201407/1/8926377_14042326898ewG.png "height=" 147 "width=" 427 " Hspace= "0" vspace= "0"/>
Usage:
1. #bzip2 filename does not add parameters will delete the original file
2. #bzip2 –c filename > filename.bz2 The compressed file redirection output
3. #bzip2 –d filename.bz2 will unzip the file
4. #bunbzip2 filename.bz2 will unzip the file, it will delete the original filename.bz2 file
5. #bzcat filename.bz2 to view the file
How do I compress a directory?
The compression program can compress a single file, but cannot compress the directory directly into a compressed file that needs to be packaged before it can be compressed, the packaging command is described here: tar
Tar Introduction:
Options:
650) this.width=650; "title=" image_thumb[12] "style=" border:0px;width:433px;height:162px; "border=" 0 "alt=" Image_ THUMB[12] "src=" Http://img1.51cto.com/attachment/201407/1/8926377_1404232689PKF5.png "height=" 162 "width=" 433 " Hspace= "0" vspace= "0"/>
Usage:
1. #tar-CF Directoryname.tar directoryname Create a package file
2. #tar-zcv-f directoryName.tar.gz directoryname First create a tar package file and then compress it with gzip and display a list of files
3. #tar-zcv-f directoryName.tar.gz directoryname First create a tar package file and then compress it with gzip and display a list of files
4. #tar-ztv-f filename.tar.gz See all the files in a packaged file list
5. #tar Zxv-f filename.tar.gz to unzip with gzip, and then expand the package file to the current directory
6. #tar zxv-f filename.tar.gz–c/tmp with gzip, and then expand the package file to the TMP directory