If you often catch Linux's information on the network, it is probably that these files that are downloaded are usually "compressed"! For what? It has been tasty it! Ha ha! The compressed file has the advantages of saving bandwidth, saving disk space, etc., and is convenient to carry! ^ _ ^! And you should also know that these compressed files, usually their attached names are "* .tar, * .tar.gz, * .tgz, * .gz, * .z, * .bz2", etc. Wait, why do you want to set these compressed archives with this model? This is because the instructions compressed on Linux are quite, and these compression instructions may not be able to solve each of the compressed files. After all, the current compression technique is five flowers, and each compression calculation is not exactly the same. So, when you caught a compressed file, you will naturally need to know that the instruction is that it is, it is used to compress it! ^ _ ^! That is, although the attribute of the Linux file is basically not absolute relationship with the file name, it is unable to perform related to his file properties, and the relationship with the file name is small! However, in order to help our small human head, the appropriate file name is still necessary! Therefore, there are currently some of the archlined names of the compressed files that are often seen! We only list the common a few things, give you the right to use:
· * .Z Compress program compressed file;
· * .Bz2 bzip2 program compressed file;
· * .Gz Gzip program compressed file;
· * .Tar TAR program packaged data, did not compress;
· * .Tar.gz tar program packaged file, where it is compressed by Gzip!
At present, common compression programs are mainly those instructions corresponding to the attached name mentioned above! The earliest thing to be compress, then, then, later GNU plans developed a new generation of compression instructions Gzip (gnu zip) to replace the old compression instructions of Compress, and then BZIP2 compression ratio is better compressed Directive! However, these instructions can only be compressed and unzipped against one file. In this way, each compression and decompression should be a big stack of files, do noter? At this time, the so-called "packaged software" is very important! In UNIX-LIKE, there is a software very fun, he is TAR this program! This TAR can make many files "package" a file! Even the directory can also play like this. However, the simple TAR function is only "packaged", that is, a lot of archives is set to a file. In fact, he does not provide compressed features. Later, GNU plans, combination of the entire TAR and compression Together, it is more convenient and more powerful compression and packaging function to provide users! Let's talk about these basic compression instructions under Linux! TAR grammar
Tar [-zxcvfpp] filename tar -n 'yyyy / mm / dd' / path -zcvf target.tar.gz source parameter description: -z: Does Gzip's properties at the same time? -X: Unlock the parameter instruction of a compressed file! -T: View the files inside TARFILE! -c: Create a parameter instruction of a compressed file Display files during compression! -F: Use the file name, please pay attention, immediately send a name immediately! Don't add parameters more! For example, using "tar -zcvfp tfile sfile is the wrong way of writing, to be written as" tar -zcvpf tfile sfile "! -p: The original attribute using the original file (attribute does not change according to the user) -p: You can use the absolute path - N: More than the date (YYYY / MM / DD) will be packaged New archives! --Exclude file: Do not pack the file in the process of compression! Example: [root @Test / root] # tar -cvf directory.tar Directory only packaged a directory into a file [root @Test / root] # tar -zcvf directory.tar.gz Directory In addition to packaging the directory, Gzip compression
[root @Test / root] # tar -zcvf filename.tar.gz / home / test / * Package all files in / home / test / this directory and compress into file files for filename.tar.gz
[root @Test / root] # TAR -XVF Directory.tar Solution TAR package, please note that because there is no role of gzip (.tar rather.tar.gz), just use -XVF! No need to add z, otherwise there is a problem!
[root @Test / root] # tar -zxvf directory.tar.gz This is the result of compressing Gzip! So you need to add -z!
[root @Test / root] # tar -ztvf directory.tar.gz This t can be used to view file information in Tar! And don't need to solve him!
[root @Test / root] # tar -zcvpf home.tar.gz / home The built-in compressed file file is an absolute path. Please note that when using this P, do not put the P back, because f To immediately join the name!
[root @Test / root] # tar -n '2002/06/25' -zcvf home.tar.gz / home is to say in / home this directory, more new files than 2002/06/25 Will be packaged into home.tar.gz this file!
[root @Test / root] # tar -zcvf host.tar.gz / --Exclude / mnt - Exclude / Proc is to say that all the data of the root directory is packaged into host.tar.gz this file, but / MNT and / Proc are not packaged! [root @Test / root] # tar -cvf - / home | tar -xvf - The above means "After packaging / home, directly decompress under / root! Hey! No need to build an intermediate file! However, it is best to use "absolute path" using the above syntax, and there will be no problem! This way is appropriate to do not want to build an intermediate file!