Summary: Tar is very powerful, you can compress, decompress, you can specify the compression of a directory after the date of the file, you can compress a directory and exclude a subdirectory inside and so on.
c = Create V = verbose detailed list of processed files F=file, archive
x = Extract
Note: In the subdirectory inside the compression, do not need to specify the full path, such as the current path has a RVDM, then compression is
TAR-ZCVF rvdm.tar.gz RVDM In this way, there is only one RVDM folder in the compressed package, which is the file, if executed
TAR-GCVF RVDM.TAR.GZ/HOME/KVMIMG/RVDM So, the inside of the compression package to the HOME/KVMIMG/RVDM level three directory
Example one: Package all the files in the/etc directory into a/tmp/etc.tar
[Root@linux ~]# tar-cvf/tmp/etc.tar/etc <== packaged only, not compressed.
[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, gzip compressed
[Root@linux ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== after packaging 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" is a special set of absolute paths.
Example two: Refer to the documents in the above/tmp/etc.tar.gz document.
[Root@linux ~]# tar-ztvf/tmp/etc.tar.gz
# Since we use gzip compression, we need to check the files in the tar file
# It's going to have to add the Z parameter. It's very important.
Example three: Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
[Root@linux ~]# CD/USR/LOCAL/SRC
[Root@linux src]# tar-zxvf/tmp/etc.tar.gz
# in a preset scenario, we can undo the compression file anywhere. In this example,
# I first transform the working directory underneath the/USR/LOCAL/SRC and unlock the/tmp/etc.tar.gz,
# then the unpacked catalogue 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/.
Example four: under/tmp, I just want to untie the etc/passwd in the/tmp/etc.tar.gz.
[Root@linux ~]# Cd/tmp
[Root@linux 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
# It can be done in this way. noticed that. The root directory within the etc.tar.gz/was taken away.
Example five: Back up all the files in the/etc/and save their permissions.
[Root@linux ~]# 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.
Example six: In/home, a new file is backed up in 2005/06/01
[Root@linux ~]# tar-n ' 2005/06/01′-ZCVF home.tar.gz/home
Example seven: I want to back up/home,/etc, but don't/home/dmtsai
[Root@linux ~]# TAR–EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc
Example eight: The/etc/is packaged and unpacked directly underneath/TMP without producing a file.
[Root@linux ~]# Cd/tmp
[Root@linux tmp]# tar-cvf–/etc | tar-xvf–
# This action is a bit like cp-r/etc/tmp ~ still has its use.
# The place to note is that the output file becomes – and the input file becomes – and there is a | exist ~
# This separately represents standard output, standard input and Pipeline command.
# This part we'll be talking about this instruction again when we Bash the shell and explain it to everyone again. Tar
Unpack: Tar xvf Filename.tar
Packing: Tar cvf filename.tar dirname
(Note: Tar is packed, not compressed.) )
———————————————
. gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName
. tar.gz and. tgz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz dirname
———————————————
. bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName
. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2 or Tar–bzip xvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 dirname
———————————————
. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown
. tar.bz
Decompression: Tar jxvf FileName.tar.bz
Compression: Unknown
———————————————
. Z
Decompression: uncompress filename.z
Compression: Compress FileName
. Tar. Z
Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z dirname
———————————————
. zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip dirname
Compresses a directory using the-r parameter,-R recursion. Example: $ zip-r filename.zip dirname
———————————————
. rar
Decompression: rar x Filename.rar
Compression: rar a filename.rar dirname
RAR please to: http://www.rarsoft.com/download.htm download.
After decompression, copy the rar_static to the/usr/bin directory (other directories specified by the $PATH environment variable can also)