Linux tar details

Source: Internet
Author: User
Tags compress archive uncompress

Tar
Command name
Tar-tar file management Program . The following sections describe their meanings one by one.
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] [-- checkpoint]
[-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, -- 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]

 

Description
The tar program is used to store or expand tar archive files. Archive files can be stored on disks or as common files. Tar requires parameters. Optional parameters include a, c, d, R, T, U, and X. You must specify at least one parameter for tar before using tar, you must specify the file or directory to process. If a directory is specified, all subdirectories under the directory will be added to the archive.
Example:

1) Expand abc.tar.gz run the command tar xvzf abc.tar.gz expand abc.tar run the command tar xvf abc.tar

2) Save the man directory and Its subdirectories in the current directory as an archive man.tar CF man.tar./man
Parameter description
To run tar, you must have at least one of the following parameters.

-A, -- catenate, -- concatenate
Merge an archive with an existing archive
-C, -- create
Create a new archive
-D, -- diff, -- compare
Compare the differences between an archive and the current file
-- Delete
Delete from archive
-R, -- append
Append to end of Archive
-T, -- list
List directories of files in an archive
-U, -- Update
Only append newer files to the Archive
-X, -- Extract, -- get
Expand an object from an archive

Other parameters

-- Atime-Preserve
Do not change the access time of the dump file

-B, -- block-size N
Specify the block size as nx512 bytes (n = 20)

-B, -- read-full-Blocks
Reorganize the block when reading (???!!!)

-C, -- directory dir

Go to the specified directory

-- Checkpoint
Displays the directory name when reading the archive.

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

-- Force-Local
Use a local archive forcibly, even if a clone exists

-F, -- info-script f -- New-volume-script F
Use the script F (implicit-m) at the end of each disk)

-G, -- incremental
Create a backup in the old GNU format

-G, -- listed-incremental F
Create a new GNU backup

-H, -- Dereference
Do not dump the dynamic link. Dump the file that the dynamic link points.

-I, -- ignore-Zeros
Ignore the 0-byte block in the archive (usually means the end of the file)

-- Ignore-failed-read
Mark 0 in the unreadable file before exiting ???

-K, -- keep-old-Files
Save existing files; Do not overwrite them when expanding from the archive

-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 N * 1024 bytes and wait for disk replacement

-M, -- modification-time
When a file is recovered from an archive, no new time tag is used.

-M, -- multi-volume
Create a multi-volume archive for storage on several disks

-N, -- After-date, -- newer date
Only store new files

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

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

-P, -- same-permissions, -- preserve-Permissions
Expand All Protection Information

-P, -- absolute-paths
Do not remove '/' from the file name '/'

-- Preserve
Like-p-S
Similar to-p-S

-R, -- Record-Number
Displays the number of records in the archive at the same time.

-- Remove-Files
Delete source files after creating an archive

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

-S, -- sparse
Efficient processing

-T, -- files-from F
Obtain the name of the file to be expanded or created from the file.

-- Null
Read an empty ending file name to invalidate-C.

-- Totals
Displays the total number of bytes written with the -- create parameter.

-V, -- verbose
Detailed display of processed files

-V, -- Label name
Specify the volume label for the archive

-- Version
Displays the version number of the TAR program.

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

-W, -- verify
Verify after writing to the Archive

-- Exclude file
Does not include the specified file

-X, -- exclude-from File
Reads the list of files not included from the specified file

-Y, -- Bzip2, -- bunzip2
Use Bzip2 to compress or decompress the archive

-Z, -- compress, -- uncompress
Compress archive compression or decompression

-Z, -- gzip, -- ungzip
Use gzip to compress or decompress the archive

-- Use-compress-program prog
Use prog to compress or decompress the archive (the prog must accept the-D parameter)

-- Block-compress
Archive records by block for ease of disk storage

-[0-7] [LMH]
Specify the drive and density [High and Low]

Package: tar-CF soft.tar soft

Unpack: tar-XF soft.tar soft

Compressed directory

Compressed: Tar czvf usr.tar.gz/home

Decompress: Tar xzvf usr.tar.gz

Compressed file (invalid directory)

Compression: Zip good.zip good1 good2

Decompress: unzip good.zip

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.