tar [-cxtzjvfpPN] file and directory ….
parameters:
-c: create a compressed file parameters command (create mean);
-x: parameter instructions to unlock a compressed file!
-T: View file tarfile inside!
Special attention to the parameters issued, c / x / t only the existence of a! Not exist!
Because it is not possible at the same time compression and decompression.
-Z: whether gzip attributes? That is, the need to use gzip compression?
-J: whether bzip2 attributes? That is, the need to use the bzip2 compression?
-V: compressed file! This commonly used, but is not recommended for use in the background during the execution!
-F: use the file name, please pay attention to, and then to immediately after the f file name Oh! Do not plus Parameters!
???For example, the use of “tar-zcvfP tfile sfile” is the wrong wording to be written as
???”tar-zcvPf tfile sfile” fishes Oh!
-P: the original with the original file attributes (based on user attributes are not changed)
-P: You can use an absolute path compression!
-N: than followed by the date (yyyy / mm / dd) also will be packaged into a new file!
– Exclude FILE: In the process of compression, not to FILE packaging!
Example:
Example: all packaged into the file under the / etc directory / tmp / etc.tar
[root@rmohan.com to] # tar -cvf /tmp /etc.tar / etc <== only packaged not compressed!
[Root@rmohan.com ~] # tar-zcvf /tmp /etc.tar.gz / etc <== packed gzip compression
[root@rmohan.com ~] # tar-jcvf /tmp/bzip2 compression
# etc.tar.bz2 / etc <== packed special attention to, in the name of the file, after the parameter f taken their own, we are accustomed to using. tar as identification.
#
plus j parameters by. tar.bz2 as an attached file name ah plus z parameters by. tar.gz or. tgz to represent gzip compressed tar file ~~ # ~
# in the implementation of the above command when will display a warning message:
# tar: Removing leading `/” from member names “that a special set absolute path.
Example: inspection which files the above / tmp / etc.tar.gz file?
The [root@rmohan.com] # tar-ztvf / tmp / etc.tar.gz
# Since we use gzip compression, so you want to access the file within the tar file,
# you have to add z this parameter ! This is very important!
Example: / tmp / etc.tar.gz file decompression beneath / usr / local / src
[root@rmohan.com ~~] # cd / usr / local / src
[root@rmohan.com src ] # tar-zxvf / tmp / etc.tar.gz
# In the case of default, we can unlock the archive anywhere!
# My working directory first conversion to / usr / local / src underneath this example and untied / tmp / etc.tar.gz, and
# then unlock directory in / usr / local / src / etc too! Also, if you enter the / usr / local / src in / etc
# is found, the file attributes in the directory / etc / may be different Oh!
Example: / tmp under, I only want to / tmp / etc / passwd etc.tar.gz within untie.
[root@rmohan.com ~~] # cd the / tmp
[root@www.linuxidc. com tmp] # tar-zxvf / tmp / etc.tar.gz etc / passwd
# I can through tar-ztvf to access the file name in the tarfile if single for so long as a file
# can through issued Noticed! the root within etc.tar.gz catalog / is removed!
Example: backup all the files in the / etc / down, and save their permission!
[Root@rmohan.com to] # tar-zxvpf / tmp / etc.tar.gz / etc
#-p attribute is very important, especially when you want to keep the original file attributes!
EXAMPLE 6: in / home them than 2005/06/01 new file backup the
[root@rmohan.com] # tar-N “2005/06/01”-zcvf home.tar.gz / home
Example 7: I want to back up / home, / etc., but do not / home / dmtsai in
root@rmohan.com ~~] # tar – exclude / home / dmtsai-zcvf myfile.tar.gz / home / * / etc
Example 8: / etc / packaged under the / tmp, without producing documents direct unlock!
[Root@rmohan.com] # cd / tmp
[root@rmohan.com tmp] # tar-cvf – / etc | tar-xvf –
# This action is a bit like cp-r / etc / tmp! ~ still has its uses!
# To note is that the output file into the – input file has become – have a | ~
# represent the standard output, standard input and pipeline command exists friends!
Recent Comments