For example, if you use "tar-zcvfPtfilesfile", you must write it as "tar-zcvPftfilesfi ".
Format: tar option file directory list
Function: Package and back up the file directory.
Option:
-C create a new archive file
-R: append an object to the end of the archive object
-X solve the file from the archive file
-O unlocks the file to the standard output
-V output related information during processing
-F: use the file name. please note that the file name should be followed immediately after f! Do not add parameters!
For example, the use of "tar-zcvfP tfile sfile" is incorrect. you must write it as "tar-zcvPf tfile sfile ".
-Z calls gzip to compress the archive file, and calls gzip to decompress the archive file when it is used with-x.
-Z calls compress to compress the archive file, and calls compress to decompress the archive file when it is connected to-x.
-J: does it have bzip2 attributes at the same time? That is, do I need to use bzip2 for compression?
-P: use the original attributes of the original file (the attributes will not be changed based on the user)
-P: absolute paths can be used for compression!
-N: a new date (yyyy/mm/dd) will be packed into the new file!
-- Exclude FILE: Do not pack the FILE during compression!
-T: view the files in the tarfile!
For example:
1.compress all. txt files under the current directory and archive them to the this.tar.gz file. we can use
Tar czvf this.tar.gz./*. txt
2.decompress the files in this.tar.gz under the current directory to the current directory.
Tar xzvf this.tar.gz
3. check which of the above this.tar.gz files are available?
Tar-ztvf this.tar.gz
4. under/tmp, I only want to unbind the etc/passwd in/tmp/etc.tar.gz.
Tar-zxvf/tmp/etc.tar.gz etc/passwd
5. back up all files in/etc/and save their permissions! This-p attribute is very important.
Tar-zxvpf/tmp/etc.tar.gz/etc
6. only new files in/home are backed up.
Tar-N "2005/06/01"-zcvf home.tar.gz/home
7. I want to back up/home,/etc, but not/home/dmtsai
Tar -- exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc