In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to analyze the Linux command in the tar packaging command, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
There are many decompression commands in Linux, and each command is used in a slightly different way. Let's explain the Linux packaging command: tar
Tar command
Tar [- cxtzjvfpPN] files and directories. .
Parameters:
-c: create a parameter instruction for a compressed file (meaning create)
-x: unlock a parameter instruction for a compressed file!
-t: check the files in tarfile!
Pay special attention to that only one c/x/t can exist in the issue of parameters! Cannot exist at the same time!
Because it is impossible to compress and decompress at the same time.
-z: does it also have the properties of gzip? That is, is it necessary to use gzip compression?
-j: does it also have the properties of bzip2? That is, is it necessary to use bzip2 compression?
-v: display files in the process of compression! This is commonly used, but is not recommended in the background execution process!
-f: use the file name, please note that you should receive the file name immediately after f! No more parameters!
For example, using "tar-zcvfP tfile sfile" is the wrong way to write it.
"tar-zcvPf tfile sfile" is right!
-p: use the original properties of the original file (the attributes will not change based on the user)
-P: absolute path can be used to compress!
-N: it is newer than the following date (yyyy/mm/dd) before it is packaged into the new file!
-exclude FILE: don't package FILE during compression!
Example:
Example 1: package all the files in the entire / etc directory into / tmp/etc.tar
[root@linux ~] # tar-cvf / tmp/etc.tar / etc
[root@linux ~] # tar-zcvf / tmp/etc.tar.gz / etc
[root@linux ~] # tar-jcvf / tmp/etc.tar.bz2 / etc
# in particular, note that the file name after the parameter f is self-chosen, and we are used to using .tar for identification.
# if the z parameter is added, .tar.gz or .tgz is used to represent gzip compressed tar file ~
# if you add the j parameter, use .tar.bz2 as the file name ~
# when the above instructions are executed, a warning message will be displayed:
# "tar: Removing leading `/" from member names "that is a special setting for absolute paths.
Example 2: what documents are found in the above / tmp/etc.tar.gz file?
[root@linux ~] # tar-ztvf / tmp/etc.tar.gz
# because we use gzip compression, when we want to check the files in the tar file
# you have to add the parameter z! This is important!
Example 3: extract 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
# under default circumstances, we can unzip the zip file anywhere! Take this example.
# I will first change the working directory to / usr/local/src and unlock / tmp/etc.tar.gz
# the unlocked directory will be in / usr/local/src/etc! In addition, if you enter / usr/local/src/etc
# you will find that the file attributes in this directory may be different from / etc/!
Example 4: under / tmp, I just want to unlock the etc/passwd in / tmp/etc.tar.gz.
[root@linux ~] # cd / tmp
[root@linux tmp] # tar-zxvf / tmp/etc.tar.gz etc/passwd
# I can look up the file name in tarfile through tar-ztvf, if only one file is needed
# can be issued in this way! pay attention to! The root directory in etc.tar.gz / has been removed!
Example 5: back up all the files in / etc/ and save their permissions!
[root@linux ~] # tar-zxvpf / tmp/etc.tar.gz / etc
The attribute of # this-p is very important, especially if you want to keep the attribute of the original file!
Example 6: in / home, files that are newer than 2005-06-01 are backed up
[root@linux] # tar-N "2005-06-01"-zcvf home.tar.gz / home
Example 7: I want to back up / home, / etc, but not / home/dmtsai
[root@linux] # tar-exclude / home/dmtsai-zcvf myfile.tar.gz / home/* / etc
Example 8: package / etc/ and unpack it directly under / tmp without generating files!
[root@linux ~] # cd / tmp
[root@linux tmp] # tar-cvf-/ etc | tar-xvf-
# this action is a bit like cp-r / etc / tmp ~ it still has its uses!
# pay attention to the fact that the output file becomes-and the input file becomes -, and there is another | exist ~
# this represents standard output, standard input and pipeline commands, respectively!
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.