Tar of Linux commands

Source: Internet
Author: User

The Action tar command is a reliable way to back up files in a unix/linux system. It is almost possible to work in any environment, and its use rights are for all users.

Grammar:

tar [main option + Secondary options] File or folder
Main options:
C Create a new archive file. (package) x release the file from the archive file. (unpacking) T lists archive contents The main option is only available at the same time as a
Auxiliary options:
The zgzip format, usually the file jbzip2 format with the suffix GZ, is usually a file with a suffix of bz2 v to display the command to run the process F using the archive name p using the original properties of the original file (will not be used in seclusion)--exclude file    in the compression process, do not package file


Demo Sample:
Package all files in the/etc folder into/tmp/etc.tar
TAR-CVF/TMP/ETC.TAR/ETC <== only packaged, not compressed!

Tar-zcvf/tmp/etc.tar.gz/etc <== after packing. After the TAR-JCVF/TMP/ETC.TAR.BZ2/ETC <== is packaged in gzip compression. BZIP2 Compression # Special Note that the file name after the number f is taken by yourself, and we are accustomed to using. Tar as an identification.

# Assuming that the Z-parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~# Assuming that a J-parameter is added, then use. tar.bz2 as the file name. ~# The above instruction will display a warning message when it is running: # "Tar:removin G Leading '/"from member names" That's a special setting for absolute paths.


See what files are in the/tmp/etc.tar.gz file above
tar-ztvf/tmp/etc.tar.gz# because we use gzip compression, so to check the files in the tar file, # will have to add Z this parameter!

It's very important!


Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
cd/usr/local/srctar-zxvf/tmp/etc.tar.gz# in the case of a preset, we are able to unzip the file wherever it is. In this example, I first transform the working folder to/usr/local/src, and the Unpacked/tmp/etc.tar.gz# folder will be in/usr/local/src/etc, in addition. Assuming you enter/usr/local/src/etc#, you will find that the file properties under this folder may be different from the/etc/.


Under/tmp, I just want to untie the etc/passwd in/tmp/etc.tar.gz.
cd/tmptar-zxvf/tmp/etc.tar.gz etc/passwd# I can check the file name in Tarfile through TAR-ZTVF. Suppose that a single file is only needed. # can be released in this way. Notice that!

The root folder within the etc.tar.gz/is taken away!


Backup/home,/etc, but do not/home/dmtsai
Tar--exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc

Unzip to the specified folder
Tar-zxvf/home/images.tar.gz-c/specific



Tar of Linux commands

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.