1, Tar-cvf/data/sc2.tar/data (package only, do not compress)
Pack the files under the/data into Sc.tar. All two of them are absolute paths.
tar-zcvf/data/sc2.tar.gz/data<== after packaging, compress with gzip
2. Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
[Email protected] ~]# CD/USR/LOCAL/SRC
[Email protected] src]# tar-zxvf/tmp/etc.tar.gz
---------------------
3, go to a directory, and then extract the other absolute path of the compressed files into this folder
Example
Cd/data/sc5
Tar-zxvf/data/sc6.tar.gz extract the files from this directory to the folder above "Note:. tar file not yet"
4, compress a folder, but exclude a folder under the
Tar--exclude/data/home-zcvf xin2.tar.gz/data "/data/home folder and the folder below is not compressed"
Another example:
I want to back up/home, etc, but don't/home/dmtsai
[Email protected] ~]# tar--exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc
tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter directive (the meaning of Create);
-x: Unlock the parameter instructions for a compressed file!
-T: View the files inside the Tarfile!
In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time!
Because it is not possible to compress and decompress simultaneously.
-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" Just right!
-P: Use original file properties (attributes are not changed according to user)
-P: You can use absolute path to compress!
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
--exclude file: In the process of compression, do not package file!