Tar decompression command details

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.