Linux command details--tar

Source: Internet
Author: User
Tags bz2 rar

Tar-this manual page documents the GNU version of Tar, an archiving program designed to store and extract files fro  M an archive file known as a tarfile.  A tarfile may made on a tape drive, however, it's also common to write a tarfile to a normal file.  The first argument to Tar must is one of the options Acdrtux, followed by any optional functions.  The final arguments to tar is the names of the files or directories which should be archived. The use of a directory name is always implies that the subdirectories below should is included in the archive.

Role: To create files and directories for Linux, you can also change files in the file, or add new files to the file is used to compress and decompress files. The tar itself does not have compression capabilities. It is implemented by invoking the compression function

Syntax: tar[necessary parameters [selection parameters] [file]

Parameters:

The necessary parameters are as follows:

-A add compressed file to existing compression catenate
-B Set Chunk size Blocking-factor
-C Create a new compressed file create
-D Record File differences difference
-R add files to the already compressed file append
-u add changed and existing files to a compressed file that already exists update
-X extracting files from compressed files extract get
-T displays the contents of the compressed file list
-Z Support gzip decompression file gzip
-j support bzip2 Extract Files bzip2
-Z Support Compress unzip files
-V Show Operation procedure
-L File System boundary settings
-K Keep the original file without overwriting
-m reserved files are not overwritten
-W confirm the correctness of the compressed file
The optional parameters are as follows:
-B Set Number of blocks
-c switch to the specified directory
-f Specifies the compressed file
--HELP Display Help information
--version displaying version information

Discrimination: First of all to understand two concepts: packaging and compression. Packaging refers to a large number of files or directories into a total file, compression is a large file through some compression algorithm into a small file. Why should we differentiate between these two concepts? This is due to the many compression programs in Linux that can only be compressed for one file, so that when you want to compress a lot of files, you have to first make a package (Tar command) of the whole bunch of files, and then compress the program (gzip bzip2 command).

Common examples: frequently used pressure/compression commands

Tar
Unpacking: Tar xvf Filename.tar
Package: Tar cvf filename.tar DirName
(Note: Tar is packaged, not compressed!) )


. gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName

. tar.gz and. tgz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz DirName

. bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName

. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 DirName

. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown

. tar.bz
Decompression: Tar jxvf FileName.tar.bz
Compression: Unknown

. Z
Decompression: uncompress filename.z
Compression: Compress FileName

. Tar. Z
Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z DirName

. zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip DirName

. rar
Decompression: rar x Filename.rar
Compression: rar a Filename.rar DirName

Working with instances

Example 1: Package all files into a tar package

Command:

TAR-CVF Log.tar Log2012.log

TAR-ZCVF log.tar.gz Log2012.log

TAR-JCVF log.tar.bz2 Log2012.log

Output:

[Email protected] test]# Ls-al Log2012.log

---xrw-r--1 root root 302108 11-13 06:03 log2012.log

[Email protected] test]# TAR-CVF Log.tar log2012.log

Log2012.log

[Email protected] test]# TAR-ZCVF log.tar.gz log2012.log

Log2012.log

[Email protected] test]# TAR-JCVF log.tar.bz2 log2012.log

Log2012.log

[Email protected] test]# Ls-al *.tar*

-rw-r--r--1 root root 307200 11-29 17:54 Log.tar

-rw-r--r--1 root root 1413 11-29 17:55 log.tar.bz2

-rw-r--r--1 root root 1413 11-29 17:54 log.tar.gz

Description

TAR-CVF Log.tar Log2012.log Package only, do not compress!

TAR-ZCVF log.tar.gz log2012.log After packing, compress with gzip

TAR-JCVF log.tar.bz2 Log2012.log is packaged to bzip2 compression

The file name after the parameter F is taken by itself, and we are accustomed to using. Tar as an identification. If the z parameter is added, a. tar.gz or. tgz is used to represent the gzip compressed tar package, or the. tar.bz2 as the TAR package name if the J parameter is added.


This article is from the "Little Bunny" blog, make sure to keep this source http://10551983.blog.51cto.com/10541983/1681530

Linux command details--tar

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.