Linux Uncompressed tar command __linux

Source: Internet
Author: User
Tags bz2 diff gz file uncompress

Ext: http://blog.csdn.net/teamlet/archive/2008/02/18/2104262.aspx

This article cites two parts of Tar, the first part is an example of using tar. The second part is a detailed parameter description.

The first part:

Tar command

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.
Example:
Example one: Package all the files in the/etc directory into a/tmp/etc.tar
[Root@linux ~]# tar-cvf/tmp/etc.tar/etc<== is packaged only, not compressed.
[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc<== after packaging, 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" is a special set of absolute paths.

Example two: Refer to the documents in the above/tmp/etc.tar.gz document.
[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.

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/.

Example four: under/tmp, I just want to untie the etc/passwd in the/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.

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.

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

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

Example eight: The/etc/is packaged and unpacked directly underneath/TMP without producing a file.
[Root@linux ~]# Cd/tmp
[Root@linux tmp]# TAR-CVF-/etc | TAR-XVF-
# It's kind of like a cp-r/etc/tmp
# The place to notice in the with the output file becomes-and the input file also becomes-, and there's a | Exist
# This represents standard output, standard input and pipeline commands respectively.

=====================================================

Part II:

Tar command

The GNU version of the TAR archive file management program. Here's what it means to each individual

General overview

Tar [-] A--catenate--concatenate | C--create | D--diff--compare | R--append | T--list | U--update | X-extract--get [--atime-preserve] [-B,--block-size N] [-B,--read-full-blocks] [-C,--directory DIR] [--CHECKP OINT]
[F,--file [hostname:]f] [--force-local]
[F,--info-script F--new-volume-script F] [G,--incremental] [G,--listed-incremental F] [H,--dereference] [-I,--ignore-zeros] [-I,--bzip] [--ignore-failed-read] [k,--keep-old-files] [k,--starting-file F] [-L,--one-file-system] [-L,--tape-length N] [M,--modification-time] [M,--multi-volume] [-N,--after-date date,--newer Date] [-O,--old-archive,--portability] [-O,--to-stdout] [-P,--same-permissions,--preserve-permissions] [-P,--absolute-paths] [--preserve]
[-R,--record-number] [--remove-files] [-S,--same-order,--preserve-order] [--same-owner] [-S,--sparse] [-T,--files-from F] [--null]
[--totals]
[-V,--verbose] [-V,--label NAME] [--version]
[W,--interactive,--confirmation] [-W,--verify]
[--exclude FILE] [-X,--exclude-from FILE] [Z,--compress,--uncompress] [Z,--gzip,--ungzip]
[--use-compress-program PROG] [--block-compress] [-[0-7][LMH]]

filename1 [Filename2, ... filenamen]
Directory1 [Directory2, ... Directoryn]


Describe

The TAR program is used to store or expand the tar archive file. The archive file can be placed on disk or stored as a normal file. Tar requires parameters, the optional parameters are a, C, D, r, T, u, x, you must first specify at least one parameter for tar when you use tar, and then you must specify the files or directories you want to work with. If you specify a directory, all subdirectories in that directory are added to the archive.
Application Examples:

1) Expand abc.tar.gz Use command: Tar xvzf abc.tar.gz expand abc.tar Use command: Tar xvf abc.tar

2 Save the Man directory and its subdirectories under the current directory as archived Man.tar tar CF Man.tar./man
Parameter description
When you run tar, you must have at least one of the following parameters to run

-A,--catenate,--concatenate
Merge an archive with an existing archive
-C,--create
Create a new archive
D,--diff,--compare
Compare the archive with the current file
--delete
Remove from archive
-R,--append
Append to end of archive
-T,--list
Lists the directories of files in the archive
-U,--update
Attach only newer files to the archive
-X,--extract,--get
Expand Files from archive


Other parameters

--atime-preserve
Do not change the access time of the dump file

-B,--block-size N
Specifies that the block size is Nx512 byte (default n=20)

-B,--read-full-blocks
When reading a reorganization block (...). )

-C,--directory DIR

Go to the specified directory

--checkpoint
Display directory name when reading archive

-F,--file [hostname:]f
Specify an archive or device (default is/dev/rmt0)

--force-local
Force local archive, even if there is a clone

-F,--info-script F--new-volume-script F
Use script F at end of each disk (implied-m)

-G,--incremental
Build the old GNU format backup

-G,--listed-incremental F
Build a new GNU format backup

-H,--dereference
Do not dump dynamic links, dumping files that the dynamic link points to.

-I,--ignore-zeros
Ignores 0-byte blocks in the archive (usually means end of file)

--ignore-failed-read
Make 0 tags in an unreadable file before exiting ...

-K,--keep-old-files
Save an existing file, expand from archive without overwriting

-K,--starting-file F
Starting from archive file F

-L,--one-file-system
Create an archive in the local file system

-L,--tape-length N
Pause after writing the n*1024 word, waiting for a replacement disk

-M,--modification-time
When you restore files from one file, you do not use the new Time label

-M,--multi-volume
Set up a multiple-volume archive for storage on several disks

-N,--after-date date,--newer date
Save only files with newer time

-O,--old-archive,--portability
Archive in V7 format without ANSI format

-O,--to-stdout
Expand a file to standard output

-P,--same-permissions,--preserve-permissions
Expand All Protection information

-P,--absolute-paths
Do not remove '/' from filename

--preserve
Like-p-S
Similar to the-p-s

-R,--record-number
Display the number of records in the archive while displaying information

--remove-files
Delete source files After an archive is established

-S,--same-order,--preserve-order
。。。
--same-owner
Expand to make all files belong to the same owner

-S,--sparse
Efficient handling

-T,--files-from F
Get the file name you want to expand or create from the file

--null
Read the null-terminated file name so that-C fails

--totals
Displays the total number of bytes written with the--create parameter

-V,--verbose
Detailed display of processed files

-V,--label NAME
To specify a volume label for an archive

--version
Displays the version number of the TAR program

W,--interactive,--confirmation
Each operation requires confirmation

-W,--verify
Verify after writing to archive

--exclude FILE
Do not include the specified file

-X,--exclude-from FILE
Read the list of files that you do not want to include from the specified file

-Y,--bzip2,--bunzip2
Compress or decompress the archive with bzip2

-Z,--compress,--uncompress
Compress or decompress the archive with compress

-Z,--gzip,--ungzip
Compress or decompress the archive with Gzip

--use-compress-program PROG
Archive compression or decompression with PROG (PROG must be able to accept-D parameters)

--block-compress
Archive by block log for easy disk storage

-[0-7][LMH]
Specify drive and density [high school low]

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.