A detailed description of the TAR compression decompression command under Linux

Source: Internet
Author: User
Tags bz2 diff posix ranges rar set time uncompress version control system

Source Address: http://blog.csdn.net/x_iya/article/details/72889456

Tar

-C: Create compressed archives
-X: Unzip
-T: View content
-r: Append files to the end of a compressed archive file
-U: Update files in original compressed package

These five are stand-alone commands, which use one of the compression decompression, and can be used with other commands but only one. The following parameters are optional when compressing or extracting files as needed.

-Z: With gzip properties
-j: With the bz2 attribute
-Z: With the Compress attribute
-V: Show All procedures
-O: Unpack the file to standard output

The following parameter-F is required

-F: Use the file name, remember that this parameter is the last parameter, can only be followed by the file name.

# TAR-CF All.tar *.jpg
This command is to make all. jpg files into a package named All.tar. -C is the file name that represents the generation of a new package,-f specifies the package.

# TAR-RF All.tar *.gif
This command adds all the. gif files to the All.tar package. -R is meant to increase the file.

# Tar-uf All.tar logo.gif
This command is to update the original tar package All.tar in the logo.gif file,-U is to indicate the meaning of the update file.

# TAR-TF All.tar
This command is to list all the files in the All.tar package,-T is to list the meaning of the file

# TAR-XF All.tar
This command is to solve all the files in the All.tar package,-T is to untie the meaning

Compression

TAR-CVF Jpg.tar *.jpg//package all JPG files in the directory into tar.jpg

TAR-CZF jpg.tar.gz *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in gzip to generate a gzip compressed package named jpg.tar.gz

TAR-CJF jpg.tar.bz2 *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in bzip2 to generate a bzip2 compressed package named jpg.tar.bz2

TAR-CZF jpg.tar.z *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in compress to generate a umcompress compressed package named Jpg.tar.z

RAR a jpg.rar *.jpg//rar format compression, you need to download RAR for Linux first

Zip jpg.zip *.jpg//zip format compression, need to download zip for Linux First

Extract

TAR-XVF File.tar//Unpacking the TAR Package

TAR-XZVF file.tar.gz//Decompression tar.gz

TAR-XJVF file.tar.bz2//Decompression tar.bz2

TAR-XZVF file.tar.z//Unzip tar. Z

Unrar e file.rar//decompression rar

Unzip File.zip//Unzip zip

Summarize

1, *.tar with TAR-XVF decompression

2, *.gz with gzip-d or gunzip decompression

3, *.tar.gz and *.tgz with TAR-XZF decompression

4, *.bz2 with bzip2-d or with BUNZIP2 decompression

5, *.tar.bz2 with TAR-XJF decompression

6, *. Z Extract with Uncompress

7, *.tar. Z Extract with Tar-xzf

8, *.rar with Unrar e decompression

9, *.zip with unzip decompression

Unzip the JDK to the specified folder:

TAR-XZVF jdk-8u131-linux-x64.tar.gz-c/usr/local/java

[Email protected]:~# tar--help
Usage: tar [options ...] [FILE] ...
GNU ' tar ' saves many files together into a single tape or disk archive, and can
Restore individual files from the archive.

Examples:
TAR-CF Archive.tar Foo Bar # Create Archive.tar from Files foo and bar.
TAR-TVF Archive.tar # List All files in Archive.tar verbosely.
TAR-XF Archive.tar # Extract all files from Archive.tar.

Main operating mode:

-A,--catenate,--concatenate append tar file to archive
-C,--create create a new archive
-D,--diff,--compare find the difference between archiving and file systems
--delete from archive (non-tape!) ) in the Delete
-R,--append append file to end of archive
-T,--list list archived content
--test-label Test Archive volume label and exit
-U,--update only append files that are newer than the copy in the archive
-X,--extract,--get to extract files from the archive

Manipulation modifiers:

--check-device checking the device number when creating an incremental archive (default)
-G,--listed-incremental=file handles incremental backups in the new GNU format
-G,--incremental handles incremental backups in the old GNU format
--ignore-failed-read
Do not exit with non-0 values when encountering unreadable files
--level=number the output level of the incremental list archive created by
-N,--seek archive can be retrieved
--no-check-device do not check the device number when creating an incremental archive
--no-seek Archive not searchable
--occurrence[=number] Processing only the number of each file in the archive
Only if--delete with the following subcommands.
--diff,--extract or--list.
This option is only valid when a union is used in a And regardless of whether the file list is given in the command line or through
The-t option is specified; The number value defaults to 1
--sparse-version=major[. MINOR]
Sets the discrete format version used (implied
--sparse)
-S,--sparse efficient processing of discrete files

Override control:

-K,--keep-old-files don ' t replace existing files when extracting,
Treat them as errors
--keep-directory-symlink Preserve existing symlinks to directories when
Extracting
--keep-newer-files
Do not replace an existing file that is newer than the copy in the archive
--no-overwrite-dir preserving metadata for existing directories
--one-top-level[=dir] Create a subdirectory to avoid have loose files
Extracted
--overwrite Overwrite existing files when extracting
--overwrite-dir rewriting metadata for existing directories (default)

--recursive-unlink clear the directory hierarchy before extracting the directory
--remove-files Delete files after they are added to the archive
--skip-old-files don ' t replace existing files when extracting,
Silently skip over them
-U,--unlink-first remove the files you want to overwrite before extracting them
-W,--verify attempts to validate the archive after writing

Select the output stream:

--ignore-command-error Ignore exit codes for child processes
--no-ignore-command-error
The non-0 exit code of the child process is considered to have an error
-O,--to-stdout extract files to standard output
--to-command=command
Transfer the extracted files to another program through the pipeline

Action file properties:

--atime-preserve[=method]
The access time is retained on the output file, either through the read (the default
method= ' replace ') after the restore time, or do not set the time for the first (method= ' system ')
--clamp-mtime only set time if the file is more recent than
What is given with--mtime
--delay-directory-restore
Set the modification time and permissions of the directory to be unpacked until the end of decompression
--group= name forced to
As the group owner of the file being added
--mode=changes force the added file (symbol) to be changed to a permission
Changes
--mtime=date-or-file settings for added files from the Date-or-file
Mtime
-M,--touch do not unzip the file modification time
--no-delay-directory-restore
Effect of canceling the--delay-directory-restore option
--no-same-owner
Unzip the file to all of you (this is the default for normal users)
--no-same-permissions
Use the user's mask bit when extracting permissions from the archive (default is normal User Service)
--numeric-owner always use numbers to represent the name of the user/group
--owner= name forced to
As the owner of the file being added
-P,--preserve-permissions,--same-permissions
Unzip the file permission information (by default only for Super User Service)
--preserve is the same as-p and-s
--same-owner
Keep the owner relationship consistent when trying to decompress (this is the default for super users)
-S,--preserve-order,--same-order
Member arguments is listed in the same order as
The files in the archive
--sort=order directory sorting Order:none (default), name or
Inode

Handling of Extended file attributes:

--acls Enable the POSIX ACLs support
--no-acls Disable the POSIX ACLs support
--no-selinux Disable the SELinux context support
--no-xattrs Disable Extended Attributes support
--selinux Enable the SELinux context support
--xattrs Enable Extended Attributes support
--xattrs-exclude=mask specify the exclude pattern for xattr keys
--xattrs-include=mask specify the include pattern for xattr keys

Device Selection and switching:

-F,--file=archive using an archive file or ARCHIVE device
--force-local
Even if the archive has a copy or it's considered a local archive
-F,--info-script= name,--new-volume-script= name
Run the script at the end of each tape (implied-m)
-L,--tape-length=number write NUMBERx1024 bytes and replace tape
-M,--multi-volume Create/List/extract multi-volume archive files
--rmt-command=command using the specified RMT command instead of RMT
--rsh-command=command using remote command instead of RSH
--volno-file=file using/updating the number of volumes in file

Device Sub-block:

-B,--blocking-factor=blocks per record BLOCKS x 512 bytes
-B,--read-full-records when read (only valid for 4.2BSD pipes)
-I,--ignore-zeros ignores 0-byte blocks in the archive (that is, end of file)
--record-size=number number of bytes per record multiplied by 512

Select an archive format:

-H,--format=format create the archive in the specified format

Format is one of the following formats:

GNU GNU Tar 1.13.x format
OLDGNU GNU format as per tar <= 1.12
Pax POSIX 1003.1-2001 (PAX) format
POSIX equates to Pax
Ustar POSIX 1003.1-1988 (ustar) format
V7 Old V7 tar format

--old-archive,--portability
Equivalent to--format=v7
--pax-option= keyword [[:]= value] [, keyword [[:]= value]] ...
Control pax Keyword
--posix equivalent to--format=posix
-V,--label=text creates a TEXT with the volume name
When listing/extracting, use the TEXT
The pattern string as the volume name

Compression options:

-A,--auto-compress uses the archive suffix name to determine the compression program
-I.,--use-compress-program=prog
Filter by PROG (must be able to accept-D
option of the program)
-j,--BZIP2 filter archive via bzip2
-j,--XZ filter archive via XZ
--lzip Filtering Archives via Lzip
--lzma via XZ Filter Archive
--lzop via XZ Filter Archive
--no-auto-compress does not use the archive suffix name to determine the compression program
-Z,--gzip,--gunzip,--ungzip archive via gzip filter
-Z,--compress,--uncompress filter archive via compress

Local File Selection:

--add-file=file adds the specified file-to-archive (if the name
It will be useful at first)
--backup[=control] Backup before delete, select CONTROL version
-C,--directory=dir change to directory dir
--exclude=pattern exclude files specified with the PATTERN
--exclude-backups excluding backup and lock files
--exclude-caches except for the identity file itself, exclude the containing
Cachedir. Content in the TAG's directory
--exclude-caches-all exclusion contains Cachedir. Directory of Tags
--exclude-caches-under exclusion contains Cachedir. TAG
All content in the directory
--exclude-ignore=file read exclude patterns for each directory from
FILE, if it exists
--exclude-ignore-recursive=file
Read exclude patterns for each directory and its
Subdirectories from FILE, if it exists
--exclude-tag=file excluding file itself, exclude file containing
The contents of the directory
--exclude-tag-all=file exclude directories that contain FILE
--exclude-tag-under=file exclude all content in a directory that contains FILE
--exclude-vcs exclude version control system directory
--exclude-vcs-ignores read exclude patterns from the VCs ignore files
-H,--dereference
Trace Symbolic links; archive and export the files they point to
--hard-dereference
Track hard links, archive and export the files they point to
-K,--starting-file=member-name
Begin at Member Member-name when reading the
Archive
--newer-mtime=date Compare data and time when only data changes
--no-null disable the last effect--null option
--no-recursion avoid automatic demotion in the directory
--no-unquote does not unquote input file or member names
--NULL-T read with null-terminated name,-c disabled
-N,--newer=date-or-file,--after-date=date-or-file
Save only files that are newer than date-or-file
--one-file-system saved in the local file system when the archive is created
-P,--absolute-names don ' t strip leading '/' s from file names
--recursion directory recursion (default)
--suffix=string is backed up before deletion, unless the environment variable
Simple_backup_suffix
Overwrite, otherwise overwrite common suffix (')
-T,--files-from=file from FILE
To extract or create a file by getting the filename
--unquote unquote input file or member names (default)
-X,--exclude-from=file excludes the pattern strings listed in FILE

File name Transformation:

--strip-components=number Remove number from file name when extracting
A boot section
--transform=expression,--xform=expression
Use SED instead of EXPRESSION
To change the file name

File name matching option (also affects exclusions and includes pattern strings):

--anchored pattern string matches file name header
--ignore-case ignoring case
--no-anchored patterns match after any '/' (the default for
Exclusion)
--no-ignore-case Match Case (default)
--no-wildcards Verbatim matching string
--no-wildcards-match-slash wildcards do not match '/'
--wildcards using wildcard characters (default to exclusion)
--wildcards-match-slash wildcards match '/' (Default for exclusion)

Prompt output:

--checkpoint[=number] every number
Records show progress information (default is 10)
--checkpoint-action=action execute action on each checkpoint
--full-time print in the file's original time format
--index-file=file send verbose output to file
-L,--check-links
Print information as long as not all links are output
--no-quote-chars=string to disable character references from STRING
--quote-chars=string additional reference characters from STRING
--quoting-style=style setting a name reference style; a valid style
Values see the following instructions
-R,--block-number each message shows the number of blocks in the archive
--show-defaults Show tar default options
--show-omitted-dirs
List or unzip, list the directories for each mismatch lookup criteria
--show-snapshot-field-ranges
Show valid ranges for snapshot-file fields
--show-transformed-names,--show-stored-names
Displays the transformed file name or archive name
--totals[=signal] The total number of bytes printed after processing the archive;
SIGNAL is triggered with parameters-
The total number of bytes printed, the allowed signal is:
SIGHUP,SIGQUIT,SIGINT,SIGUSR1 and
SIGUSR2, but also accept without SIG
The signal name of the prefix
--UTC to print file modification time in UTC format
-V,--verbose lists the processed files in detail
--warning=keyword Warning Control:
-W,--interactive,--confirmation
Require confirmation for each operation

Compatibility options:

-O When creating an archive, the equivalent
--old-archive; When an archive is expanded, the equivalent
--no-same-owner

Other options:

-?,--Help shows this list
--restrict disabling some potentially risky options
--usage Show a short usage note
--version Print Program version

The long option and the corresponding short option have the same mandatory parameters or optional parameters.

The backup suffix is ' ~ ', and unless set with--suffix or Simple_backup_suffix.
The version control May is set with--backup or Version_control, and values are:

None, off never make backups
T, numbered make numbered backups
Nil, existing numbered if numbered backups exist, simple otherwise
Never, simple and simple backups

Valid parameters for the--quoting-style option are:

Literal
Shell
Shell-always
C
C-maybe
Escape
Locale
Clocale

This tar defaults to:
--format=gnu-f--b20--quoting-style=escape--rmt-command=/usr/lib/tar/rmt
--rsh-command=/usr/bin/rsh

A detailed description of the TAR compression decompression command under Linux

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.