Linux tar command

Source: Internet
Author: User

The tar command is used to handle packaging and package settlement. The following commands are commonly required:

1. Unpack:

# tar -zxvf file.tar.gz

The preceding command decompress the package to the current directory. If you extract the package to another directory, use

# tar -zxvf file.tar.gz -C path

Path indicates the directory to which the files are extracted.

2. Packaging:

# tar -zcvf file.tar.gz path

File.tar.gz is the package name, while path is the package's target file path.

Note:

  • The parameter V is used to display the packaged file information. If the package is not displayed, no additional information is required.
  • The Parameter Z is the format of compression and decompression, and the general suffix is GZ. If you see the suffix gz2, replace the parameter Z with J.

3. view the compressed files.

# tar -tf file.tar.gz

4. In/home, a new file is backed up only when it is earlier

# tar -N "2012/05/30" -zcvf home.tar.gz /home

5. Back up home And/ECT, but do not back up the/home/Dante directory

# tar --exclude /home/dante -zcvf myfile.tar.gz /home/* /etc

6. Package/etc and decompress it to/tmp without generating compressed documents.

# tar -zcvf - /etc | tar -zxvf - -C /tmp

This action is a bit like CP-r/etc/tmp is still useful! Note that the output file is changed to-, the input file is also changed to-, and another | exists. This represents standard output, standard input, and pipeline commands respectively!

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.