Tar
Format: tar [options] [file directory list]
Function: Package A backup of the file directory
Options:
-C to create a new archive file
-R appending files to the end of the archive file
-X Extract files from archive
-O unlocking files to standard output
Output related information during-v processing
-F for normal file operations
-Z invokes gzip to compress archive file, call gzip to complete uncompressed when associated with-X
-Z calls compress to compress the archive, and call compress when it is associated with-X to complete the decompression
Example:
#范例一: Package All the files in the/etc directory into/tmp/etc.tar
TAR-CVF/TMP/ETC.TAR/ETC <== only packaged, not compressed!
Tar-zcvf/tmp/etc.tar.gz/etc <== after packaging to gzip compressed
Tar-jcvf/tmp/etc.tar.bz2/etc <== packaged to bzip2 compression
# Note that the file name after the parameter F is taken by itself, and we are accustomed to using the. Tar as an identification.
# If you add the z parameter, the. tar.gz or. tgz to represent the gzip-compressed tar file ~
# If you add the J parameter, use the. tar.bz2 as the file name.
# The above instruction will display a warning message when it is executed:
# "tar:removing leading '/' from member names" That's a special set of absolute paths.
#范例二: What documents are available in the above/tmp/etc.tar.gz document?
Tar-ztvf/tmp/etc.tar.gz
# because we use gzip compression, we need to check the files in the tar file
# We're going to have to add the Z parameter! It's very important!
#范例三: Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
Cd/usr/local/src
Tar-zxvf/tmp/etc.tar.gz
# in the preset case, we can release the compressed file anywhere! In this example,
# I first transform the working directory underneath the/USR/LOCAL/SRC and unlock the/tmp/etc.tar.gz,
# then untie the catalog will be in/USR/LOCAL/SRC/ETC! In addition, if you enter the/USR/LOCAL/SRC/ETC
# you will find that the file attributes in this directory may be different from the/etc/.
#范例四: Under/tmp, I just want to untie the etc/passwd in the/tmp/etc.tar.gz.
Cd/tmp
Tar-zxvf/tmp/etc.tar.gz etc/passwd
# I can check the file name in the Tarfile through TAR-ZTVF, if only one file
# you can make it through this way! Notice that! The root directory within the etc.tar.gz/was taken away!
#范例五: Back up all the files in the/etc/and save their permissions!
Tar-zxvpf/tmp/etc.tar.gz/etc
# This property of-p is important, especially if you want to preserve the properties of the original file!
#范例六: In/home, newer files are backed up than 2005/06/01
Tar-n ' 2005/06/01 '-ZCVF home.tar.gz/home
#范例七: I want to back up/home,/etc, but don't/home/dmtsai
Tar--exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc
#范例八: The/etc/will be packaged and unpacked directly below/tmp without producing a file!
Cd/tmp
TAR-CVF-/etc | TAR-XVF-
# This action is a bit like cp-r/etc/tmp ~ still has its use!
# The place to notice in the output file becomes-and the input file becomes-, and there's a | exist ~
# This separately represents standard output, standard input and Pipeline command!
# This part we'll be talking about again when we Bash the shell and explain it to everyone again??? br/>
#范例九: Extract to the specified directory
Tar-zxvf/home/images.tar.gz-c/specific dir
#范例十: Unpack to the specified directory
Tar xvf filename.tar-c/specific dir