The tar command is an uncompressed command in Linux. There are two concepts to be clear before using the tar command : 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). Since there are two kinds of compression methods (GZIP,BZIP2) Of course there are two methods of decompression, so when compressing the file, you need to show which compression method to use, and the tar command is called the TAR package, The TAR package files end with. Tar, so that the package that is compressed with the tar command ends with. tar.gz or. tar.bz2. Maybe we just hit a bag, don't want to compress it, how to do? Controlled by the command parameters of tar. The tar information is as follows:
1. Command format:
tar[necessary parameters [selection parameters] [file]
2. Command function:
Used to compress and decompress files. The tar itself does not have compression capabilities. is implemented by calling the compression function (-z,-j,-z in the command arguments), so as long as you do not specify these three parameters, just package the file, do not compress
3. Command parameters:
The necessary parameters are as follows:
-A add compressed file to existing compression
-B Set Chunk size
-C Create a new compressed file
-D Record File differences
-R Add a file to a file that has been compressed
-u add changed and existing files to a compressed file that already exists
-X extracting files from compressed files
-T displays the contents of the compressed file
-Z Support gzip unzip files
-j Support bzip2 Extract files
-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
For the tar command, the usual parameters are:
Necessary parameters:
Compression class:-Z gzip compression
-j bzip2 Compression
-Z Compass Compression
Decompression class:
-X Extract the file from the compressed file (corresponding to the-C parameter)
- C Create a new compressed file (the created compressed file is to be used, corresponding to the-x parameter )
-V Show the operation process (packaging, compression, decompression, you can see the process of operation, save the command line is not written wrong)
Optional Parameters:
-c switch to the specified directory (when decompression is used to switch to the directory where the extracted files are stored)
-f Specifies the compressed file (compression: Used to specify the name of the compressed file and the storage directory, unzip: Specify the name of the file to be extracted and the directory when extracting)
"-" is a command parameter prompt,-ZCF represents the tar's z,c,f parameter
Instance:
sudo tar - ZCF ./hadoop.. GZ ./hadoop compression
-zxf ~/hadooptar.-c /usr/ local extract the compressed file into the/usr/local, without the "-C" parameter will prompt "not found in the archive."
Reference:
Http://www.cnblogs.com/peida/archive/2012/11/30/2795656.html
Tar command--unzip