Example and detailed explanation of the tar packaging commands under Linux __linux

Source: Internet
Author: User
Tags bz2 gz file zend framework

Because you often download and install software, the software that provides the download is usually packaged and usually compressed, so it is very important to pack and compress the tar commands, from the Internet to find an article on the "Tar Packaging command samples and detailed Linux" articles, excerpts down for inquiries and learning

Brother Bird's private dishes have more detailed packaging compression decompression instructions, see http://linux.vbird.org/linux_basic/0240tarcompress.php

Tar command
[Root@linux ~]# tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter instruction (create meaning);
-X: Unlocks a parameter directive for a compressed file.
-T: View the files inside the tarfile.


In particular, it is noted that c/x/t can only exist in the release of a parameter. Cannot exist at the same time.
Because it is not possible to compress and decompress at the same time.
-Z: Whether to have gzip properties at the same time. That is, whether you need to use gzip compression.
-j: Whether to have bzip2 properties at the same time. That is to use bzip2 compression.
-V: Displays files during compression. This is commonly used, but is not recommended for use in background execution processes.
-F: Use file name, please note that after F to immediately pick up the file name Oh. Don't add any more parameters.
For example, the use of "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" is right.
-P: Use the original properties of the original file (properties will not be changed according to the user)
-P: You can use absolute paths to compress.
-N: Newer than the following date (YYYY/MM/DD) will be packaged into the newly created file.
--exclude file: Do not package file in the process of compression.

Tar Example:
Example one: Pack all the files in the/etc directory into/tmp/etc.tar
[Root@linux ~]# tar-cvf/tmp/etc.tar/etc <== packaged only, not compressed.
[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, gzip compressed
[Root@linux ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== after packaging to bzip2 compression
# Note that the file name after the parameter F is taken by itself, and we are accustomed to using the. Tar as an identification.
# If you add the z parameter, the. tar.gz or. tgz to represent the gzip-compressed tar file ~
# If you add the J parameter, use the. tar.bz2 as the file name.
# The above instruction will display a warning message when it is executed:
# "tar:removing leading '/' from member names" That's a special set of absolute paths.

Tar example two: Check the documents in the above/tmp/etc.tar.gz file.
[Root@linux ~]# tar-ztvf/tmp/etc.tar.gz
# Since we use gzip compression, we need to check the files in the tar file
# It's going to have to add the Z parameter. It's very important.

Tar example three: Unzip 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
# in a preset scenario, we can undo the compression file anywhere. In this example,
# I first transform the working directory underneath the/USR/LOCAL/SRC and unlock the/tmp/etc.tar.gz,
# then the unpacked catalogue will be in/USR/LOCAL/SRC/ETC. In addition, if you enter the/USR/LOCAL/SRC/ETC
# you will find that the file attributes in this directory may be different from the/etc/.

Tar example four: under/tmp, I just want to untie 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 check the file name in the Tarfile through TAR-ZTVF, if only one file
# It can be done in this way. noticed that. The root directory within the etc.tar.gz/was taken away.

Tar example five: Back up all the files in the/etc/and save their permissions.
[Root@linux ~]# Tar-zxvpf/tmp/etc.tar.gz/etc
# This property of-p is important, especially if you want to preserve the properties of the original file.

Tar example six: In/home, a new file is backed up in 2005/06/01
[Root@linux ~]# tar-n ' 2005/06/01 '-ZCVF home.tar.gz/home

Tar example seven: I want to back up/home,/etc, but don't/home/dmtsai
[Root@linux ~]# tar--exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc

Tar example eight: unpack the/etc/directly below/tmp without producing a file.
[Root@linux ~]# Cd/tmp
[Root@linux tmp]# TAR-CVF-/etc | TAR-XVF-
# This action is a bit like cp-r/etc/tmp ~ still has its use.
# The place to notice in the output file becomes-and the input file becomes-, and there's a | exist ~
# This separately represents standard output, standard input and Pipeline command.
# This Part we'll talk about this instruction again when we Bash the shell.  Collection: on a Topic: The usage of left Join,right Join,inner join,outer join in MySQL "Go" next topic: Linux copy CP delete rm move MV command parameters and instructions

-You might be interested in these articles. Random Article Recommendation: Html2utf8 can enter the purple characters of the violet Pinyin input method My first single, sour or comforting smarty error a case of pure PHP based on a single point of entry to the construction Bank's business hours (working time) collect the most obscene Chinese characters in the variable before adding & Comments need to be audited in order to be displayed, please do not repeat submissions, thank you * your name * Your email (we will keep it confidential does not appear on the page, will be contacted as your way) blog/or your homepage (sorry, we have temporarily turned off this feature) * Comment content *: (Unsupported HTML not supported UBB ) Verification code (please fill in the calculation of the left digit) do not forget the national humiliation alarm bells ringing support strong Chinese journal list Mood Diary (142) Learn notes (130) wonderful Abstracts (208) Assorted (116) My QQ signature (70) joke (24) listen to Song (6) PHP related (144) MySQL database (km) DIV+CSS layout Learning (19) I do little Things (6) WAP Development Learning Materials (2) Zend Framework (2) JavaScript Linux & Unix (7) Friendship link Rain simple log guangzhou dream Lisa hardware Jewelry factory guangzhou Yao Xin hardware jewelry factory tips eternal Sky Blankyao ' s blog

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.